mirror of
https://github.com/2dust/v2rayN.git
synced 2025-11-20 06:32:52 +00:00
Introduces options to specify custom PAC file and system proxy script paths for system proxy settings. Updates configuration models, view models, UI bindings, and logic for Linux/OSX proxy handling and PAC management to use these custom paths if provided. Also adds UI elements and localization for the new settings.
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
namespace ServiceLib.Handler.SysProxy;
|
|
|
|
public static class ProxySettingOSX
|
|
{
|
|
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())
|
|
{
|
|
args.AddRange(exceptions.Split(','));
|
|
}
|
|
|
|
await ExecCmd(args);
|
|
}
|
|
|
|
public static async Task UnsetProxy()
|
|
{
|
|
List<string> args = ["clear"];
|
|
await ExecCmd(args);
|
|
}
|
|
|
|
private static async Task ExecCmd(List<string> args)
|
|
{
|
|
var customSystemProxyScriptPath = AppManager.Instance.Config.SystemProxyItem?.CustomSystemProxyScriptPath;
|
|
var fileName = (customSystemProxyScriptPath.IsNotEmpty() && File.Exists(customSystemProxyScriptPath))
|
|
? customSystemProxyScriptPath
|
|
: await FileUtils.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetOSXShellFileName), false);
|
|
|
|
// TODO: temporarily notify which script is being used
|
|
NoticeManager.Instance.SendMessage(fileName);
|
|
|
|
await Utils.GetCliWrapOutput(fileName, args);
|
|
}
|
|
}
|