Skip to content

Commit

Permalink
support custom pow provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Archeb committed Sep 2, 2023
1 parent 4759b4d commit 2a14c76
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 11 deletions.
1 change: 1 addition & 0 deletions NextTraceWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion OpenTrace.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<Title>OpenTrace</Title>
<ApplicationIcon>icon.ico</ApplicationIcon>
<PackageIcon>icon.png</PackageIcon>
<Version>1.3.0.0</Version>
<Version>1.3.0.1</Version>

</PropertyGroup>

Expand Down
7 changes: 7 additions & 0 deletions PreferencesDialog.xeto
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@
<Label Text="{x:Static resource:Resources.LEOMOEAPI_HOSTPORT}"></Label>
<TextBox x:Name="LeoMoeAPI_HOSTPORT" Text=""></TextBox>
</TableRow>
<TableRow>
<Label Text="{x:Static resource:Resources.POW_PROVIDER}"></Label>
<DropDown x:Name="POWProvider" SelectedIndex="0">
<ListItem Text="{x:Static resource:Resources.POW_PROVIDER_LEOMOE}" Key="api.leo.moe"></ListItem>
<ListItem Text="{x:Static resource:Resources.POW_PROVIDER_SAKURA}" Key="sakura"></ListItem>
</DropDown>
</TableRow>
<TableRow>
<Label Text="{x:Static resource:Resources.NEXTTRACE_PROXY}"></Label>
<TextBox x:Name="NextTraceProxy" PlaceholderText="protocol://username:password@host:port" Text=""></TextBox>
Expand Down
21 changes: 11 additions & 10 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand Down
27 changes: 27 additions & 0 deletions Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,15 @@ To use an offline database, please refer to the NextTrace documentation to set i
<data name="PARALLEL_REQ" xml:space="preserve">
<value>Parallel Requests</value>
</data>
<data name="POW_PROVIDER" xml:space="preserve">
<value>LeoMoeAPI PoW Provider</value>
</data>
<data name="POW_PROVIDER_LEOMOE" xml:space="preserve">
<value>api.leo.moe (Default)</value>
</data>
<data name="POW_PROVIDER_SAKURA" xml:space="preserve">
<value>Nya Labs (China Mainland Optimized)</value>
</data>
<data name="PREFERENCES" xml:space="preserve">
<value>Preferences</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions Properties/Resources.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ sudo chmod +sx /path/to/nexttrace
<data name="PARALLEL_REQ" xml:space="preserve">
<value>并行请求数</value>
</data>
<data name="POW_PROVIDER" xml:space="preserve">
<value>LeoMoeAPI PoW 服务器</value>
</data>
<data name="POW_PROVIDER_LEOMOE" xml:space="preserve">
<value>api.leo.moe (默认)</value>
</data>
<data name="POW_PROVIDER_SAKURA" xml:space="preserve">
<value>Nya Labs (中国大陆优化)</value>
</data>
<data name="PREFERENCES" xml:space="preserve">
<value>设置</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions Properties/Resources.zh-HK.resx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,15 @@ sudo chmod +sx /path/to/nexttrace
<data name="PARALLEL_REQ" xml:space="preserve">
<value>並行請求數</value>
</data>
<data name="POW_PROVIDER" xml:space="preserve">
<value>LeoMoeAPI PoW 服務器</value>
</data>
<data name="POW_PROVIDER_LEOMOE" xml:space="preserve">
<value>api.leo.moe (默認)</value>
</data>
<data name="POW_PROVIDER_SAKURA" xml:space="preserve">
<value>Nya Labs (中國大陸優化)</value>
</data>
<data name="PREFERENCES" xml:space="preserve">
<value>設置</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions Properties/Resources.zh-TW.resx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,15 @@ sudo chmod +sx /path/to/nexttrace
<data name="PARALLEL_REQ" xml:space="preserve">
<value>並行請求數</value>
</data>
<data name="POW_PROVIDER" xml:space="preserve">
<value>LeoMoeAPI PoW 伺服器</value>
</data>
<data name="POW_PROVIDER_LEOMOE" xml:space="preserve">
<value>api.leo.moe (默認)</value>
</data>
<data name="POW_PROVIDER_SAKURA" xml:space="preserve">
<value>Nya Labs (中國大陸優化)</value>
</data>
<data name="PREFERENCES" xml:space="preserve">
<value>設定</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,8 @@ internal class UserSettings : Advexp.Settings<UserSettings>

[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; }
}
}

0 comments on commit 2a14c76

Please sign in to comment.