mirror of
https://github.com/2dust/v2rayN.git
synced 2026-04-18 21:45:45 +00:00
Compare commits
2 commits
31de7ec094
...
f500d2b9f4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f500d2b9f4 | ||
|
|
79e53bf1f5 |
2 changed files with 20 additions and 11 deletions
|
|
@ -2,10 +2,6 @@
|
||||||
{
|
{
|
||||||
public class ProxySettingOSX
|
public class ProxySettingOSX
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* 仅测试了,MacOS 13.7.1 x86 版本,其他版本有待确认
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 应用接口类型
|
/// 应用接口类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -18,13 +14,15 @@
|
||||||
|
|
||||||
public static async Task SetProxy(string host, int port, string exceptions)
|
public static async Task SetProxy(string host, int port, string exceptions)
|
||||||
{
|
{
|
||||||
var lstCmd = GetSetCmds(host, port, exceptions);
|
var lstInterface = await GetListNetworkServices();
|
||||||
|
var lstCmd = GetSetCmds(lstInterface, host, port, exceptions);
|
||||||
await ExecCmd(lstCmd);
|
await ExecCmd(lstCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task UnsetProxy()
|
public static async Task UnsetProxy()
|
||||||
{
|
{
|
||||||
var lstCmd = GetUnsetCmds();
|
var lstInterface = await GetListNetworkServices();
|
||||||
|
var lstCmd = GetUnsetCmds(lstInterface);
|
||||||
await ExecCmd(lstCmd);
|
await ExecCmd(lstCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,10 +40,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<CmdItem> GetSetCmds(string host, int port, string exceptions)
|
private static List<CmdItem> GetSetCmds(List<string> lstInterface, string host, int port, string exceptions)
|
||||||
{
|
{
|
||||||
List<CmdItem> lstCmd = [];
|
List<CmdItem> lstCmd = [];
|
||||||
foreach (var interf in LstInterface)
|
foreach (var interf in lstInterface)
|
||||||
{
|
{
|
||||||
foreach (var type in LstTypes)
|
foreach (var type in LstTypes)
|
||||||
{
|
{
|
||||||
|
|
@ -70,10 +68,10 @@
|
||||||
return lstCmd;
|
return lstCmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<CmdItem> GetUnsetCmds()
|
private static List<CmdItem> GetUnsetCmds(List<string> lstInterface)
|
||||||
{
|
{
|
||||||
List<CmdItem> lstCmd = [];
|
List<CmdItem> lstCmd = [];
|
||||||
foreach (var interf in LstInterface)
|
foreach (var interf in lstInterface)
|
||||||
{
|
{
|
||||||
foreach (var type in LstTypes)
|
foreach (var type in LstTypes)
|
||||||
{
|
{
|
||||||
|
|
@ -87,5 +85,16 @@
|
||||||
|
|
||||||
return lstCmd;
|
return lstCmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<List<string>> GetListNetworkServices()
|
||||||
|
{
|
||||||
|
var services = await Utils.GetListNetworkServices();
|
||||||
|
if (services.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
return LstInterface;
|
||||||
|
}
|
||||||
|
var lst = services.Split(Environment.NewLine);
|
||||||
|
return lst.Length > 0 ? LstInterface.Intersect(lst).ToList() : LstInterface;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>7.5.0</Version>
|
<Version>7.5.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue