diff --git a/src/Dockerfile b/src/Dockerfile index a2c4807c9..b9ade041c 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -28,7 +28,7 @@ ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \ WORKDIR /app EXPOSE 8080 -RUN apk add --update --no-cache wget libpcap icu-data-full icu-libs ca-certificates libgdiplus && \ +RUN apk add --update --no-cache wget libpcap icu-data-full icu-libs ca-certificates libgdiplus tzdata && \ update-ca-certificates COPY --from=publish /app/publish . diff --git a/src/GZCTF/Dockerfile b/src/GZCTF/Dockerfile index 68ed4dcde..a86f655ca 100644 --- a/src/GZCTF/Dockerfile +++ b/src/GZCTF/Dockerfile @@ -10,7 +10,7 @@ ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \ WORKDIR /app EXPOSE 8080 -RUN apk add --update --no-cache wget libpcap icu-data-full icu-libs ca-certificates libgdiplus && \ +RUN apk add --update --no-cache wget libpcap icu-data-full icu-libs ca-certificates libgdiplus tzdata && \ update-ca-certificates COPY --from=build /publish . diff --git a/src/GZCTF/Extensions/CacheExtensions.cs b/src/GZCTF/Extensions/CacheExtensions.cs index 03a300d9d..da8b44cee 100644 --- a/src/GZCTF/Extensions/CacheExtensions.cs +++ b/src/GZCTF/Extensions/CacheExtensions.cs @@ -6,8 +6,8 @@ namespace GZCTF.Extensions; public static class CacheExtensions { /// - /// 获取缓存或重新构建,如果缓存不存在会阻塞 - /// 使用 CacheMaker 和 CacheRequest 代替处理耗时更久的缓存 + /// Get or create cache, if cache not exists will block + /// Use CacheMaker and CacheRequest to replace handling longer time operation /// public static async Task GetOrCreateAsync(this IDistributedCache cache, ILogger logger, @@ -15,6 +15,7 @@ public static async Task GetOrCreateAsync(this IDistr Func> func, CancellationToken token = default) { + var cacheTime = DateTimeOffset.Now; var value = await cache.GetAsync(key, token); TResult? result = default; @@ -38,8 +39,11 @@ public static async Task GetOrCreateAsync(this IDistr var bytes = MemoryPackSerializer.Serialize(result); await cache.SetAsync(key, bytes, cacheOptions, token); - logger.SystemLog(Program.StaticLocalizer[nameof(Resources.Program.Cache_Rebuilt), key, bytes.Length], - TaskStatus.Success, LogLevel.Debug); + + logger.SystemLog(Program.StaticLocalizer[ + nameof(Resources.Program.Cache_Updated), + key, cacheTime.ToString("HH:mm:ss.fff"), bytes.Length + ], TaskStatus.Success, LogLevel.Debug); return result; } diff --git a/src/GZCTF/Resources/Program.en-US.resx b/src/GZCTF/Resources/Program.en-US.resx index d45ca91c3..99be4761b 100644 --- a/src/GZCTF/Resources/Program.en-US.resx +++ b/src/GZCTF/Resources/Program.en-US.resx @@ -59,7 +59,9 @@ : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> - + @@ -112,10 +114,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + Available email suffix: {0} @@ -267,14 +271,11 @@ No matching request found for cache worker: {0} - - Rebuild cache: {0} @ {1} bytes - Cache update has been stopped - Cache updated: {0} @ {1} bytes + Cache updated: {0}[{1}] @ {2} bytes Cache update failed: {0} @ {1} @@ -754,7 +755,7 @@ Send mail: {0} - <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/></head><body><div style="max-width: 544px; margin: 0 auto; padding: 20px"> <h2 style="text-align: center">{title}</h2> <p>Hello, {userName}!</p> <p style="text-indent: 2em">{information}</p> <p style="text-align: center; padding: 20px"> <a href="{url}" style=" font: 1rem Arial; white-space: nowrap; text-decoration: none; background-color: #000000; color: #ffffff; padding: 10px 20px 10px 20px; border: 1px solid #888888; border-radius: 7px; margin: 10px auto; " > {btnmsg} </a> </p> <div style="font-size: 0.8rem"> <p> If the above button is not valid, please copy this link to your browser: <br/><span style="word-break: break-all; font: 0.8em monospace" >{url} </span> </p> <p>If you have not done so, please ignore this email. </p> </div> <p style="font-size: 0.7em; text-align: right; color: #333">{platform} @ {nowtime}</p></div></body> + <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/></head><body><div style="max-width: 544px; margin: 0 auto; padding: 20px"> <h2 style="text-align: center">{title}</h2> <p>Hello, {userName}!</p> <p style="text-indent: 2em">{information}</p> <p style="text-align: center; padding: 20px"> <a href="{url}" style=" font: 1rem Arial; white-space: nowrap; text-decoration: none; background-color: #000000; color: #ffffff; padding: 10px 20px 10px 20px; border: 1px solid #888888; border-radius: 7px; margin: 10px auto; " > {btnmsg} </a> </p> <div style="font-size: 0.8rem"> <p> If the above button is not valid, please copy this link to your browser: <br/><span style="word-break: break-all; font: 0.8em monospace" >{url} </span> </p> <p>If you have not done so, please ignore this email. </p> </div> <p style="font-size: 0.7em; text-align: right; color: #333">{platform} @ {nowtime}</p></div></body> Verify Email @@ -1033,12 +1034,12 @@ Internal server error - Failed to update logo + Failed to update logo - Successfully connected to SMTP server: {0} + Successfully connected to SMTP server: {0} - Invalid email configuration, but email authentication is enabled + Invalid email configuration, but email authentication is enabled diff --git a/src/GZCTF/Resources/Program.ja-JP.resx b/src/GZCTF/Resources/Program.ja-JP.resx index 38de1b2b6..e5437beea 100644 --- a/src/GZCTF/Resources/Program.ja-JP.resx +++ b/src/GZCTF/Resources/Program.ja-JP.resx @@ -59,7 +59,9 @@ : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> - + @@ -112,10 +114,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 有効なメールドメイン:{0} @@ -267,14 +271,11 @@ キャッシュ更新ワーカーに一致するリクエストが見つかりませんでした:{0} - - キャッシュが再構築されました:{0} @ {1} bytes - キャッシュの更新が停止されました - キャッシュが更新されました:{0} @ {1} bytes + キャッシュが更新されました:{0}[{1}] @ {2} bytes キャッシュ更新ワーカーが更新に失敗しました:{0} @ {1} @@ -754,7 +755,7 @@ {0} にメールを送信します - <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/></head><body><div style="max-width: 544px; margin: 0 auto; padding: 20px"> <h2 style="text-align: center">{title}</h2> <p>ようこそ,{userName}!</p> <p style="text-indent: 2em">{information}</p> <p style="text-align: center; padding: 20px"> <a href="{url}" style=" font: 1rem Arial; white-space: nowrap; text-decoration: none; background-color: #000000; color: #ffffff; padding: 10px 20px 10px 20px; border: 1px solid #888888; border-radius: 7px; margin: 10px auto; " > {btnmsg} </a> </p> <div style="font-size: 0.8rem"> <p> 上のボタンが機能しない場合は、このリンクをブラウザにコピーしてアクセスしてください:<br/><span style="word-break: break-all; font: 0.8em monospace" >{url} </span> </p> <p>このメールに心当たりがない場合はこのメールを無視してください。</p> </div> <p style="font-size: 0.7em; text-align: right; color: #333">{platform} @ {nowtime}</p></div></body> + <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/></head><body><div style="max-width: 544px; margin: 0 auto; padding: 20px"> <h2 style="text-align: center">{title}</h2> <p>ようこそ,{userName}!</p> <p style="text-indent: 2em">{information}</p> <p style="text-align: center; padding: 20px"> <a href="{url}" style=" font: 1rem Arial; white-space: nowrap; text-decoration: none; background-color: #000000; color: #ffffff; padding: 10px 20px 10px 20px; border: 1px solid #888888; border-radius: 7px; margin: 10px auto; " > {btnmsg} </a> </p> <div style="font-size: 0.8rem"> <p> 上のボタンが機能しない場合は、このリンクをブラウザにコピーしてアクセスしてください:<br/><span style="word-break: break-all; font: 0.8em monospace" >{url} </span> </p> <p>このメールに心当たりがない場合はこのメールを無視してください。</p> </div> <p style="font-size: 0.7em; text-align: right; color: #333">{platform} @ {nowtime}</p></div></body> メールを確認する @@ -1033,12 +1034,12 @@ サーバーで内部エラーが発生しました - プラットフォームアイコンの更新に失敗しました + プラットフォームアイコンの更新に失敗しました - SMTPサーバーへの接続に成功しました:{0} + SMTPサーバーへの接続に成功しました:{0} - 無効な電子メール設定ですが、電子メール認証は有効です + 無効な電子メール設定ですが、電子メール認証は有効です diff --git a/src/GZCTF/Resources/Program.resx b/src/GZCTF/Resources/Program.resx index 411b1ccbb..e48600930 100644 --- a/src/GZCTF/Resources/Program.resx +++ b/src/GZCTF/Resources/Program.resx @@ -59,7 +59,9 @@ : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> - + @@ -112,10 +114,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 可用邮箱后缀:{0} @@ -267,14 +271,11 @@ 缓存更新线程未找到匹配的请求:{0} - - 重建缓存:{0} @ {1} bytes - 缓存更新已停用 - 缓存已更新:{0} @ {1} bytes + 缓存已更新:{0}[{1}] @ {2} bytes 缓存更新线程更新失败:{0} @ {1} @@ -754,7 +755,7 @@ 发送邮件:{0} - <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/></head><body><div style="max-width: 544px; margin: 0 auto; padding: 20px"> <h2 style="text-align: center">{title}</h2> <p>你好,{userName}!</p> <p style="text-indent: 2em">{information}</p> <p style="text-align: center; padding: 20px"> <a href="{url}" style=" font: 1rem Arial; white-space: nowrap; text-decoration: none; background-color: #000000; color: #ffffff; padding: 10px 20px 10px 20px; border: 1px solid #888888; border-radius: 7px; margin: 10px auto; " > {btnmsg} </a> </p> <div style="font-size: 0.8rem"> <p> 如果以上按钮无效,请复制此链接到浏览器访问:<br/><span style="word-break: break-all; font: 0.8em monospace" >{url} </span> </p> <p>如果你没有进行相关操作,请忽略此封邮件。</p> </div> <p style="font-size: 0.7em; text-align: right; color: #333">{platform} @ {nowtime}</p></div></body> + <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/></head><body><div style="max-width: 544px; margin: 0 auto; padding: 20px"> <h2 style="text-align: center">{title}</h2> <p>你好,{userName}!</p> <p style="text-indent: 2em">{information}</p> <p style="text-align: center; padding: 20px"> <a href="{url}" style=" font: 1rem Arial; white-space: nowrap; text-decoration: none; background-color: #000000; color: #ffffff; padding: 10px 20px 10px 20px; border: 1px solid #888888; border-radius: 7px; margin: 10px auto; " > {btnmsg} </a> </p> <div style="font-size: 0.8rem"> <p> 如果以上按钮无效,请复制此链接到浏览器访问:<br/><span style="word-break: break-all; font: 0.8em monospace" >{url} </span> </p> <p>如果你没有进行相关操作,请忽略此封邮件。</p> </div> <p style="font-size: 0.7em; text-align: right; color: #333">{platform} @ {nowtime}</p></div></body> 确认验证邮箱 @@ -1033,12 +1034,12 @@ 服务器发生内部错误 - 平台 Logo 更新失败 + 平台 Logo 更新失败 - 成功连接到 SMTP 服务器:{0} + 成功连接到 SMTP 服务器:{0} - 无效的邮件配置,但邮件验证已启用 + 无效的邮件配置,但邮件验证已启用 diff --git a/src/GZCTF/Services/Cache/CacheMaker.cs b/src/GZCTF/Services/Cache/CacheMaker.cs index b0ce071b5..0f1ea975c 100644 --- a/src/GZCTF/Services/Cache/CacheMaker.cs +++ b/src/GZCTF/Services/Cache/CacheMaker.cs @@ -129,9 +129,10 @@ await cache.SetAsync(updateLock, [], { await cache.SetAsync(key, bytes, item.Options ?? new DistributedCacheEntryOptions(), token); logger.SystemLog( - Program.StaticLocalizer[nameof(Resources.Program.Cache_Updated), key, bytes.Length], - TaskStatus.Success, - LogLevel.Debug); + Program.StaticLocalizer[ + nameof(Resources.Program.Cache_Updated), + key, item.Time.ToString("HH:mm:ss.fff"), bytes.Length + ], TaskStatus.Success, LogLevel.Debug); } else { diff --git a/src/GZCTF/Services/Mail/MailSender.cs b/src/GZCTF/Services/Mail/MailSender.cs index bc7cf4870..6fc70b5b0 100644 --- a/src/GZCTF/Services/Mail/MailSender.cs +++ b/src/GZCTF/Services/Mail/MailSender.cs @@ -23,7 +23,7 @@ public sealed class MailSender : IMailSender, IDisposable bool _disposed; public MailSender( - IOptionsSnapshot accountPolicy, + IOptions accountPolicy, IOptions options, ILogger logger) {