Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfb5796

Browse files
committed
1 parent faecc2b commit cfb5796

7 files changed

Lines changed: 33 additions & 4 deletions

File tree

src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/CommunityProxyPage/ProxySettingsWindow.axaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@
6060
<ToggleSwitch
6161
IsChecked="{ReflectionBinding Source={x:Static ms:ProxySettings.OnlyEnableProxyScript},Path=Value, Mode=TwoWay}"/>
6262
</DockPanel>
63-
63+
64+
<DockPanel>
65+
<TextBlock Text="{ReflectionBinding Path=Res.CommunityFix_EnableHttpProxyToHttps,Mode=OneWay,Source={x:Static resx:R.Current}}" ></TextBlock>
66+
<ToggleSwitch
67+
IsChecked="{ReflectionBinding Source={x:Static ms:ProxySettings.EnableHttpProxyToHttps},Path=Value, Mode=TwoWay}"/>
68+
</DockPanel>
69+
6470
<!--<DockPanel>
6571
<Label Content="自定义根证书密码"></Label>
6672
<TextBox></TextBox>

src/ST.Client/Services/IHttpProxyService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public interface IHttpProxyService : IDisposable
5959

6060
bool Socks5ProxyEnable { get; set; }
6161

62+
bool EnableHttpProxyToHttps { get; set; }
63+
6264
int Socks5ProxyPortId { get; set; }
6365

6466
bool TwoLevelAgentEnable { get; set; }

src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ sealed class HttpProxyServiceImpl : IHttpProxyService
5757

5858
public bool Socks5ProxyEnable { get; set; }
5959

60+
public bool EnableHttpProxyToHttps { get; set; }
61+
6062
public int Socks5ProxyPortId { get; set; }
6163

6264
public bool TwoLevelAgentEnable { get; set; }
@@ -499,10 +501,10 @@ public void DeleteCer()
499501
using (var store = new X509Store(StoreName.My, StoreLocation.CurrentUser))
500502
{
501503
store.Open(OpenFlags.ReadOnly);
502-
X509Certificate2Collection collection = store.Certificates.Find(X509FindType.FindByIssuerName, RootCertificateName, false);
504+
X509Certificate2Collection collection = store.Certificates.Find(X509FindType.FindByIssuerName, RootCertificateName, false);
503505
foreach (var item in collection)
504506
{
505-
if (item != null)
507+
if (item != null)
506508
IPlatformService.Instance.RunShell($"security delete-certificate -Z {item.GetCertHashString()}", true);
507509
}
508510
}
@@ -609,7 +611,7 @@ public async Task<bool> StartProxy()
609611

610612
try
611613
{
612-
if (PortInUse(80) == false)
614+
if (EnableHttpProxyToHttps && PortInUse(80) == false)
613615
proxyServer.AddEndPoint(new TransparentProxyEndPoint(ProxyIp, 80, false));
614616
}
615617
catch { }

src/ST.Client/Services/Mvvm/ProxyService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ await EnableProxyScripts.ContinueWith(e =>
100100
httpProxyService.TwoLevelAgentPassword = ProxySettings.TwoLevelAgentPassword.Value;
101101

102102
httpProxyService.ProxyDNS = IPAddress2.TryParse(ProxySettings.ProxyMasterDns.Value, out var dns) ? dns : null;
103+
httpProxyService.EnableHttpProxyToHttps = ProxySettings.EnableHttpProxyToHttps.Value;
103104

104105
this.RaisePropertyChanged(nameof(EnableProxyDomains));
105106
this.RaisePropertyChanged(nameof(EnableProxyScripts));

src/ST.Client/Settings/ProxySettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ public sealed partial class ProxySettings : SettingsHost2<ProxySettings>
6565
/// </summary>
6666
public static SerializableProperty<string?> ProxyMasterDns { get; }
6767
= GetProperty<string?>(defaultValue: "223.5.5.5", autoSave: false);
68+
69+
/// <summary>
70+
/// 启用Http链接转发到Https
71+
/// </summary>
72+
public static SerializableProperty<bool> EnableHttpProxyToHttps { get; }
73+
= GetProperty(defaultValue: true, autoSave: true);
6874
#endregion
6975

7076
#region 本地代理设置

src/ST.Client/UI/Resx/AppResources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ST.Client/UI/Resx/AppResources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,9 @@ AAAAA-BBBBB-CCCC3</value>
18041804
<data name="CommunityFix_ProxyOnlyOnScript" xml:space="preserve">
18051805
<value>代理仅启用脚本功能</value>
18061806
</data>
1807+
<data name="CommunityFix_EnableHttpProxyToHttps" xml:space="preserve">
1808+
<value>启用Http协议转发到Https(需监听80端口)</value>
1809+
</data>
18071810
<data name="About_AppReview" xml:space="preserve">
18081811
<value>打分&amp;评价</value>
18091812
</data>

0 commit comments

Comments
 (0)