mirror of
https://github.com/2dust/v2rayN.git
synced 2026-04-16 12:35:46 +00:00
- Resolve static analysis warnings (CAxxxx) and optimize performance. - Refactor UI bindings to eliminate async void and race conditions. - Migrate Win32 API to LibraryImport for AOT compatibility.
31 lines
1.2 KiB
C#
31 lines
1.2 KiB
C#
namespace ServiceLib.Handler.SysProxy;
|
|
|
|
public static class ProxySettingLinux
|
|
{
|
|
private static readonly string _proxySetFileName = $"{AppConfig.ProxySetLinuxShellFileName.Replace(AppConfig.NamespaceSample, "")}.sh";
|
|
|
|
public static async Task SetProxy(string host, int port, string exceptions)
|
|
{
|
|
List<string> args = ["manual", host, port.ToString(), exceptions];
|
|
await ExecCmd(args);
|
|
}
|
|
|
|
public static async Task UnsetProxy()
|
|
{
|
|
List<string> args = ["none"];
|
|
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(AppConfig.ProxySetLinuxShellFileName), false);
|
|
|
|
// TODO: temporarily notify which script is being used
|
|
NoticeManager.Instance.SendMessage(fileName);
|
|
|
|
await Utils.GetCliWrapOutput(fileName, args);
|
|
}
|
|
}
|