2025-04-02 03:44:23 +00:00
|
|
|
namespace ServiceLib.Handler.SysProxy;
|
|
|
|
|
2025-08-17 08:52:51 +00:00
|
|
|
public static class ProxySettingOSX
|
2024-09-28 02:41:30 +00:00
|
|
|
{
|
2025-04-02 03:44:23 +00:00
|
|
|
private static readonly string _proxySetFileName = $"{Global.ProxySetOSXShellFileName.Replace(Global.NamespaceSample, "")}.sh";
|
2024-11-08 01:21:43 +00:00
|
|
|
|
2025-04-02 03:44:23 +00:00
|
|
|
public static async Task SetProxy(string host, int port, string exceptions)
|
|
|
|
{
|
|
|
|
List<string> args = ["set", host, port.ToString()];
|
|
|
|
if (exceptions.IsNotEmpty())
|
2024-09-28 02:41:30 +00:00
|
|
|
{
|
2025-04-02 03:44:23 +00:00
|
|
|
args.AddRange(exceptions.Split(','));
|
2024-11-08 01:21:43 +00:00
|
|
|
}
|
|
|
|
|
2025-04-02 03:44:23 +00:00
|
|
|
await ExecCmd(args);
|
|
|
|
}
|
2025-01-01 06:24:23 +00:00
|
|
|
|
2025-04-02 03:44:23 +00:00
|
|
|
public static async Task UnsetProxy()
|
|
|
|
{
|
|
|
|
List<string> args = ["clear"];
|
|
|
|
await ExecCmd(args);
|
|
|
|
}
|
2025-01-05 04:24:14 +00:00
|
|
|
|
2025-04-02 03:44:23 +00:00
|
|
|
private static async Task ExecCmd(List<string> args)
|
|
|
|
{
|
2025-07-30 11:52:45 +00:00
|
|
|
var fileName = await FileManager.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetOSXShellFileName), false);
|
2025-04-02 03:44:23 +00:00
|
|
|
|
|
|
|
await Utils.GetCliWrapOutput(fileName, args);
|
2024-09-28 02:41:30 +00:00
|
|
|
}
|
2025-02-23 11:52:13 +00:00
|
|
|
}
|