From 2a14c766a2244dad1b77b9e746adfb9064ef84bc Mon Sep 17 00:00:00 2001 From: Archeb Date: Sat, 2 Sep 2023 20:27:41 +0800 Subject: [PATCH] support custom pow provider --- NextTraceWrapper.cs | 1 + OpenTrace.csproj | 2 +- PreferencesDialog.xeto | 7 +++++++ Program.cs | 21 +++++++++++---------- Properties/Resources.Designer.cs | 27 +++++++++++++++++++++++++++ Properties/Resources.resx | 9 +++++++++ Properties/Resources.zh-CN.resx | 9 +++++++++ Properties/Resources.zh-HK.resx | 9 +++++++++ Properties/Resources.zh-TW.resx | 9 +++++++++ UserSettings.cs | 3 +++ 10 files changed, 86 insertions(+), 11 deletions(-) diff --git a/NextTraceWrapper.cs b/NextTraceWrapper.cs index fb5fd47..7de7c69 100644 --- a/NextTraceWrapper.cs +++ b/NextTraceWrapper.cs @@ -158,6 +158,7 @@ public void Run(string host,bool MTRMode, params string[] extraArgs) if (UserSettings.ChunZhenEndpoint != "") _process.StartInfo.EnvironmentVariables.Add("NEXTTRACE_CHUNZHENURL", UserSettings.ChunZhenEndpoint); if (UserSettings.LeoMoeAPI_HOSTPORT != "") _process.StartInfo.EnvironmentVariables.Add("NEXTTRACE_HOSTPORT", UserSettings.LeoMoeAPI_HOSTPORT); if (UserSettings.NextTraceProxy != "") _process.StartInfo.EnvironmentVariables.Add("NEXTTRACE_PROXY", UserSettings.NextTraceProxy); + if (UserSettings.POWProvider != "") _process.StartInfo.EnvironmentVariables.Add("NEXTTRACE_POWPROVIDER", UserSettings.POWProvider); if (MTRMode) // 添加环境变量让NextTrace进入持续追踪模式 _process.StartInfo.EnvironmentVariables.Add("NEXTTRACE_UNINTERRUPTED", "1"); diff --git a/OpenTrace.csproj b/OpenTrace.csproj index 165c0da..1a2deeb 100644 --- a/OpenTrace.csproj +++ b/OpenTrace.csproj @@ -14,7 +14,7 @@ OpenTrace icon.ico icon.png - 1.3.0.0 + 1.3.0.1 diff --git a/PreferencesDialog.xeto b/PreferencesDialog.xeto index 495247d..095a17f 100644 --- a/PreferencesDialog.xeto +++ b/PreferencesDialog.xeto @@ -116,6 +116,13 @@ + + + + + + + diff --git a/Program.cs b/Program.cs index f50b7dc..b16b7d2 100644 --- a/Program.cs +++ b/Program.cs @@ -2,6 +2,7 @@ using Eto.Drawing; using Eto.Forms; using System; +using System.Collections.ObjectModel; using System.Configuration; using System.Globalization; using System.Runtime.InteropServices; @@ -20,17 +21,17 @@ static void Main(string[] args) { System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(UserSettings.language); } - if(UserSettings.mapProvider == "" && UserSettings.mapProvider != null) + + // 本地化设置 + if (System.Threading.Thread.CurrentThread.CurrentUICulture.Name == "zh-CN" && TimeZoneInfo.Local.Id == "China Standard Time") + { + if (UserSettings.mapProvider == "" && UserSettings.mapProvider != null) UserSettings.mapProvider = "baidu"; + if (UserSettings.POWProvider == "" && UserSettings.POWProvider != null) UserSettings.POWProvider = "sakura"; + } + else { - // 本地化地图供应商设置 - if (System.Threading.Thread.CurrentThread.CurrentUICulture.Name == "zh-CN") - { - UserSettings.mapProvider = "baidu"; - } - else - { - UserSettings.mapProvider = "google"; - } + if (UserSettings.mapProvider == "" && UserSettings.mapProvider != null) UserSettings.mapProvider = "google"; + if (UserSettings.POWProvider == "" && UserSettings.POWProvider != null) UserSettings.POWProvider = "api.leo.moe"; } new Application(Eto.Platform.Detect).Run(new MainForm()); diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 86fac57..6c44122 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -693,6 +693,33 @@ public static string PARALLEL_REQ { } } + /// + /// 查找类似 LeoMoeAPI PoW Provider 的本地化字符串。 + /// + public static string POW_PROVIDER { + get { + return ResourceManager.GetString("POW_PROVIDER", resourceCulture); + } + } + + /// + /// 查找类似 api.leo.moe (Default) 的本地化字符串。 + /// + public static string POW_PROVIDER_LEOMOE { + get { + return ResourceManager.GetString("POW_PROVIDER_LEOMOE", resourceCulture); + } + } + + /// + /// 查找类似 Nya Labs (China Mainland Optimized) 的本地化字符串。 + /// + public static string POW_PROVIDER_SAKURA { + get { + return ResourceManager.GetString("POW_PROVIDER_SAKURA", resourceCulture); + } + } + /// /// 查找类似 Preferences 的本地化字符串。 /// diff --git a/Properties/Resources.resx b/Properties/Resources.resx index c572293..8c0a2f6 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -333,6 +333,15 @@ To use an offline database, please refer to the NextTrace documentation to set i Parallel Requests + + LeoMoeAPI PoW Provider + + + api.leo.moe (Default) + + + Nya Labs (China Mainland Optimized) + Preferences diff --git a/Properties/Resources.zh-CN.resx b/Properties/Resources.zh-CN.resx index 3476e72..2bb2bf5 100644 --- a/Properties/Resources.zh-CN.resx +++ b/Properties/Resources.zh-CN.resx @@ -327,6 +327,15 @@ sudo chmod +sx /path/to/nexttrace 并行请求数 + + LeoMoeAPI PoW 服务器 + + + api.leo.moe (默认) + + + Nya Labs (中国大陆优化) + 设置 diff --git a/Properties/Resources.zh-HK.resx b/Properties/Resources.zh-HK.resx index 6082eb9..783ae23 100644 --- a/Properties/Resources.zh-HK.resx +++ b/Properties/Resources.zh-HK.resx @@ -324,6 +324,15 @@ sudo chmod +sx /path/to/nexttrace 並行請求數 + + LeoMoeAPI PoW 服務器 + + + api.leo.moe (默認) + + + Nya Labs (中國大陸優化) + 設置 diff --git a/Properties/Resources.zh-TW.resx b/Properties/Resources.zh-TW.resx index ce4d1c0..d102838 100644 --- a/Properties/Resources.zh-TW.resx +++ b/Properties/Resources.zh-TW.resx @@ -324,6 +324,15 @@ sudo chmod +sx /path/to/nexttrace 並行請求數 + + LeoMoeAPI PoW 伺服器 + + + api.leo.moe (默認) + + + Nya Labs (中國大陸優化) + 設定 diff --git a/UserSettings.cs b/UserSettings.cs index b1b9ef7..738feb4 100644 --- a/UserSettings.cs +++ b/UserSettings.cs @@ -90,5 +90,8 @@ internal class UserSettings : Advexp.Settings [Setting(Name = "customDNSResolvers", Default = "8.8.8.8#Google DNS\nhttps://cloudflare-dns.com/dns-query#CloudFlare DoH")] public static string customDNSResolvers { get; set; } + + [Setting(Name = "POWProvider", Default = "")] + public static string POWProvider { get; set; } } }