Skip to content

Commit

Permalink
没有启用加速也可开启加速单独启用脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbadmin committed May 3, 2021
1 parent c51e85f commit 0f730aa
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/ST.Client.Desktop/Services/Mvvm/ProxyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,31 +132,19 @@ public bool ProxyStatus
{
if (value)
{
if (!EnableProxyDomains.Any_Nullable())
if (EnableProxyDomains.Any_Nullable())
{
Toast.Show(AppResources.CommunityFix_NoSelectAcceleration);
return;
//Toast.Show(AppResources.CommunityFix_NoSelectAcceleration);
//return;
httpProxyService.ProxyDomains = EnableProxyDomains;
this.RaisePropertyChanged(nameof(EnableProxyDomains));
}
httpProxyService.ProxyDomains = EnableProxyDomains;
httpProxyService.Scripts = EnableProxyScripts;
httpProxyService.IsEnableScript = ProxySettings.IsEnableScript.Value;
httpProxyService.IsOnlyWorkSteamBrowser = ProxySettings.IsOnlyWorkSteamBrowser.Value;
this.RaisePropertyChanged(nameof(EnableProxyDomains));
this.RaisePropertyChanged(nameof(EnableProxyScripts));

var hosts = httpProxyService.ProxyDomains.SelectMany(s =>
{
return s?.HostsArray.Select(host =>
{
if (host.Contains(" "))
{
var h = host.Split(' ');
return (h[0], h[1]);
}
return (IPAddress.Loopback.ToString(), host);
});
}).Where(w => !string.IsNullOrEmpty(w.Item1));

if (!ProxySettings.EnableWindowsProxy.Value)
{
if (httpProxyService.PortInUse(443))
Expand All @@ -172,12 +160,28 @@ public bool ProxyStatus
{
if (!ProxySettings.EnableWindowsProxy.Value)
{
var r = IHostsFileService.Instance.UpdateHosts(hosts);
if (r.ResultType != OperationResultType.Success)
if (httpProxyService.ProxyDomains.Any_Nullable())
{
Toast.Show(SR.OperationHostsError_.Format(r.Message));
httpProxyService.StopProxy();
return;
var hosts = httpProxyService.ProxyDomains.SelectMany(s =>
{
return s?.HostsArray.Select(host =>
{
if (host.Contains(" "))
{
var h = host.Split(' ');
return (h[0], h[1]);
}
return (IPAddress.Loopback.ToString(), host);
});
}).Where(w => !string.IsNullOrEmpty(w.Item1));

var r = IHostsFileService.Instance.UpdateHosts(hosts);
if (r.ResultType != OperationResultType.Success)
{
Toast.Show(SR.OperationHostsError_.Format(r.Message));
httpProxyService.StopProxy();
return;
}
}
}
StartTiming();
Expand Down

0 comments on commit 0f730aa

Please sign in to comment.