v2rayN/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs

31 lines
897 B
C#
Raw Normal View History

namespace ServiceLib.Handler.SysProxy;
2025-08-17 08:52:51 +00:00
public static class ProxySettingOSX
2024-09-28 02:41:30 +00:00
{
private static readonly string _proxySetFileName = $"{Global.ProxySetOSXShellFileName.Replace(Global.NamespaceSample, "")}.sh";
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
{
args.AddRange(exceptions.Split(','));
}
await ExecCmd(args);
}
2025-01-01 06:24:23 +00:00
public static async Task UnsetProxy()
{
List<string> args = ["clear"];
await ExecCmd(args);
}
2025-01-05 04:24:14 +00:00
private static async Task ExecCmd(List<string> args)
{
var fileName = await FileManager.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetOSXShellFileName), false);
await Utils.GetCliWrapOutput(fileName, args);
2024-09-28 02:41:30 +00:00
}
}