mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-17 01:44:59 +03:00
2c90ed1a94
Rename the database and text configuration managers as handlers, move configuration data classes into Handler.Data, and relocate ProfileExManager. Update references across applications and tests.
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
namespace ServiceLib.Handler.SysProxy;
|
|
|
|
[SupportedOSPlatform("linux")]
|
|
public static class ProxySettingLinux
|
|
{
|
|
private static readonly string _proxySetFileName = $"{Global.ProxySetLinuxShellFileName.Replace(Global.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 = ConfigTextHandler.Config.SystemProxyItem?.CustomSystemProxyScriptPath;
|
|
var fileName = (customSystemProxyScriptPath.IsNotEmpty() && File.Exists(customSystemProxyScriptPath))
|
|
? customSystemProxyScriptPath
|
|
: await FileUtils.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetLinuxShellFileName), false);
|
|
|
|
// TODO: temporarily notify which script is being used
|
|
NoticeManager.Instance.SendMessage(fileName);
|
|
|
|
await Utils.GetCliWrapOutput(fileName, args);
|
|
}
|
|
}
|