Bug fix for Dsktop

pull/5853/head
2dust 1 month ago
parent 74f980aab1
commit a5122b656d

@ -115,11 +115,13 @@
}; };
public static readonly List<string> GeoFilesSources = new() { public static readonly List<string> GeoFilesSources = new() {
"",
GeoUrl, GeoUrl,
@"https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/{0}.dat", @"https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/{0}.dat",
}; };
public static readonly List<string> SingboxRulesetSources = new() { public static readonly List<string> SingboxRulesetSources = new() {
"",
SingboxRulesetUrl, SingboxRulesetUrl,
@"https://raw.githubusercontent.com/runetfreedom/russia-v2ray-rules-dat/refs/heads/release/sing-box/rule-set-{0}/{1}.srs", @"https://raw.githubusercontent.com/runetfreedom/russia-v2ray-rules-dat/refs/heads/release/sing-box/rule-set-{0}/{1}.srs",
}; };

@ -44,10 +44,6 @@
#region Init #region Init
public AppHandler()
{
}
public bool InitApp() public bool InitApp()
{ {
if (ConfigHandler.LoadConfig(ref _config) != 0) if (ConfigHandler.LoadConfig(ref _config) != 0)
@ -61,6 +57,13 @@
{ {
Environment.SetEnvironmentVariable("DOTNET_EnableWriteXorExecute", "0", EnvironmentVariableTarget.User); Environment.SetEnvironmentVariable("DOTNET_EnableWriteXorExecute", "0", EnvironmentVariableTarget.User);
} }
SQLiteHelper.Instance.CreateTable<SubItem>();
SQLiteHelper.Instance.CreateTable<ProfileItem>();
SQLiteHelper.Instance.CreateTable<ServerStatItem>();
SQLiteHelper.Instance.CreateTable<RoutingItem>();
SQLiteHelper.Instance.CreateTable<ProfileExItem>();
SQLiteHelper.Instance.CreateTable<DNSItem>();
return true; return true;
} }
@ -72,13 +75,6 @@
Logging.SaveLog($"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}"); Logging.SaveLog($"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}");
Logging.ClearLogs(); Logging.ClearLogs();
SQLiteHelper.Instance.CreateTable<SubItem>();
SQLiteHelper.Instance.CreateTable<ProfileItem>();
SQLiteHelper.Instance.CreateTable<ServerStatItem>();
SQLiteHelper.Instance.CreateTable<RoutingItem>();
SQLiteHelper.Instance.CreateTable<ProfileExItem>();
SQLiteHelper.Instance.CreateTable<DNSItem>();
return true; return true;
} }

@ -17,67 +17,59 @@ namespace ServiceLib.Handler.SysProxy
{ {
var port = AppHandler.Instance.GetLocalPort(EInboundProtocol.http); var port = AppHandler.Instance.GetLocalPort(EInboundProtocol.http);
var portSocks = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks); var portSocks = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks);
var portPac = AppHandler.Instance.GetLocalPort(EInboundProtocol.pac);
if (port <= 0) if (port <= 0)
{ {
return false; return false;
} }
if (type == ESysProxyType.ForcedChange) switch (type)
{ {
if (Utils.IsWindows()) case ESysProxyType.ForcedChange when Utils.IsWindows():
{
var strExceptions = "";
if (config.systemProxyItem.notProxyLocalAddress)
{ {
strExceptions = $"<local>;{config.constItem.defIEProxyExceptions};{config.systemProxyItem.systemProxyExceptions}"; GetWindowsProxyString(config, port, portSocks, out var strProxy, out var strExceptions);
ProxySettingWindows.SetProxy(strProxy, strExceptions, 2);
break;
} }
case ESysProxyType.ForcedChange when Utils.IsLinux():
await ProxySettingLinux.SetProxy(Global.Loopback, port);
break;
var strProxy = string.Empty; case ESysProxyType.ForcedChange:
if (Utils.IsNullOrEmpty(config.systemProxyItem.systemProxyAdvancedProtocol))
{
strProxy = $"{Global.Loopback}:{port}";
}
else
{ {
strProxy = config.systemProxyItem.systemProxyAdvancedProtocol if (Utils.IsOSX())
.Replace("{ip}", Global.Loopback) {
.Replace("{http_port}", port.ToString()) await ProxySettingOSX.SetProxy(Global.Loopback, port);
.Replace("{socks_port}", portSocks.ToString()); }
break;
} }
ProxySettingWindows.SetProxy(strProxy, strExceptions, 2); case ESysProxyType.ForcedClear when Utils.IsWindows():
}
else if (Utils.IsLinux())
{
await ProxySettingLinux.SetProxy(Global.Loopback, port);
}
else if (Utils.IsOSX())
{
await ProxySettingOSX.SetProxy(Global.Loopback, port);
}
}
else if (type == ESysProxyType.ForcedClear)
{
if (Utils.IsWindows())
{
ProxySettingWindows.UnsetProxy(); ProxySettingWindows.UnsetProxy();
} break;
else if (Utils.IsLinux())
{ case ESysProxyType.ForcedClear when Utils.IsLinux():
await ProxySettingLinux.UnsetProxy(); await ProxySettingLinux.UnsetProxy();
} break;
else if (Utils.IsOSX())
{ case ESysProxyType.ForcedClear:
await ProxySettingOSX.UnsetProxy(); {
} if (Utils.IsOSX())
} {
else if (type == ESysProxyType.Pac) await ProxySettingOSX.UnsetProxy();
{ }
PacHandler.Start(Utils.GetConfigPath(), port, portPac);
var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}"; break;
ProxySettingWindows.SetProxy(strProxy, "", 4); }
case ESysProxyType.Pac when Utils.IsWindows():
{
var portPac = AppHandler.Instance.GetLocalPort(EInboundProtocol.pac);
PacHandler.Start(Utils.GetConfigPath(), port, portPac);
var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
ProxySettingWindows.SetProxy(strProxy, "", 4);
break;
}
} }
if (type != ESysProxyType.Pac) if (type != ESysProxyType.Pac && Utils.IsWindows())
{ {
PacHandler.Stop(); PacHandler.Stop();
} }
@ -88,5 +80,27 @@ namespace ServiceLib.Handler.SysProxy
} }
return true; return true;
} }
private static void GetWindowsProxyString(Config config, int port, int portSocks, out string strProxy, out string strExceptions)
{
strExceptions = "";
if (config.systemProxyItem.notProxyLocalAddress)
{
strExceptions = $"<local>;{config.constItem.defIEProxyExceptions};{config.systemProxyItem.systemProxyExceptions}";
}
strProxy = string.Empty;
if (Utils.IsNullOrEmpty(config.systemProxyItem.systemProxyAdvancedProtocol))
{
strProxy = $"{Global.Loopback}:{port}";
}
else
{
strProxy = config.systemProxyItem.systemProxyAdvancedProtocol
.Replace("{ip}", Global.Loopback)
.Replace("{http_port}", port.ToString())
.Replace("{socks_port}", portSocks.ToString());
}
}
} }
} }

@ -163,13 +163,10 @@ namespace v2rayN.Desktop.Views
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
}); });
//if (Utils.IsWindows()) if (!Utils.IsWindows())
//{ {
//} tabSystemproxy.IsVisible = false;
//else }
//{
tabSystemproxy.IsVisible = false;
//}
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)

Loading…
Cancel
Save