Add system proxy exception function for macos

pull/6316/head
2dust 2024-12-19 11:40:16 +08:00
parent abb58379b3
commit 2cd2e8894d
2 changed files with 14 additions and 4 deletions

View File

@ -16,9 +16,9 @@
/// </summary>
private static readonly List<string> LstTypes = ["setwebproxy", "setsecurewebproxy", "setsocksfirewallproxy"];
public static async Task SetProxy(string host, int port)
public static async Task SetProxy(string host, int port, string exceptions)
{
var lstCmd = GetSetCmds(host, port);
var lstCmd = GetSetCmds(host, port, exceptions);
await ExecCmd(lstCmd);
}
@ -42,7 +42,7 @@
}
}
private static List<CmdItem> GetSetCmds(string host, int port)
private static List<CmdItem> GetSetCmds(string host, int port, string exceptions)
{
List<CmdItem> lstCmd = [];
foreach (var interf in LstInterface)
@ -55,6 +55,16 @@
Arguments = [$"-{type}", interf, host, (type.Contains("socks") ? (port - 1) : port).ToString()]
});
}
if (exceptions.IsNotEmpty())
{
List<string> args = [$"-setproxybypassdomains", interf];
args.AddRange(exceptions.Split(','));
lstCmd.Add(new CmdItem()
{
Cmd = "networksetup",
Arguments = args
});
}
}
return lstCmd;

View File

@ -32,7 +32,7 @@
break;
case ESysProxyType.ForcedChange when Utils.IsOSX():
await ProxySettingOSX.SetProxy(Global.Loopback, port);
await ProxySettingOSX.SetProxy(Global.Loopback, port, exceptions);
break;
case ESysProxyType.ForcedClear when Utils.IsWindows():