mirror of https://github.com/2dust/v2rayN
add sing-box tun bypassMode
parent
4d92caabf8
commit
e461fce2cb
|
@ -1,5 +1,4 @@
|
|||
using System.ComponentModel;
|
||||
using v2rayN.Base;
|
||||
using v2rayN.Base;
|
||||
using v2rayN.Mode;
|
||||
using v2rayN.Resx;
|
||||
|
||||
|
@ -382,7 +381,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
outbound = "direct",
|
||||
process_name = lstDirectExe
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (_config.routingBasicItem.enableRoutingAdvanced)
|
||||
|
@ -412,6 +411,38 @@ namespace v2rayN.Handler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_config.tunModeItem.enableTun)
|
||||
{
|
||||
if (_config.tunModeItem.bypassMode)
|
||||
{
|
||||
//direct ips
|
||||
if (_config.tunModeItem.directIP != null && _config.tunModeItem.directIP.Count > 0)
|
||||
{
|
||||
singboxConfig.route.rules.Add(new() { outbound = "direct", ip_cidr = _config.tunModeItem.directIP });
|
||||
}
|
||||
//direct process
|
||||
if (_config.tunModeItem.directProcess != null && _config.tunModeItem.directProcess.Count > 0)
|
||||
{
|
||||
singboxConfig.route.rules.Add(new() { outbound = "direct", process_name = _config.tunModeItem.directProcess });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//proxy ips
|
||||
if (_config.tunModeItem.proxyIP != null && _config.tunModeItem.proxyIP.Count > 0)
|
||||
{
|
||||
singboxConfig.route.rules.Add(new() { outbound = "proxy", ip_cidr = _config.tunModeItem.proxyIP });
|
||||
}
|
||||
//proxy process
|
||||
if (_config.tunModeItem.proxyProcess != null && _config.tunModeItem.proxyProcess.Count > 0)
|
||||
{
|
||||
singboxConfig.route.rules.Add(new() { outbound = "proxy", process_name = _config.tunModeItem.proxyProcess });
|
||||
}
|
||||
|
||||
singboxConfig.route.rules.Add(new() { outbound = "direct", inbound = new() { "tun-in" } });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -135,30 +135,7 @@ namespace v2rayN.Base
|
|||
configStr = configStr.Replace("$dns_object$", dnsObject);
|
||||
|
||||
//exe
|
||||
List<string> lstDnsExe = new();
|
||||
List<string> lstDirectExe = new();
|
||||
var coreInfos = LazyConfig.Instance.GetCoreInfos();
|
||||
foreach (var it in coreInfos)
|
||||
{
|
||||
if (it.coreType == ECoreType.v2rayN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (var it2 in it.coreExes)
|
||||
{
|
||||
if (!lstDnsExe.Contains(it2) && it.coreType != ECoreType.sing_box)
|
||||
{
|
||||
//lstDnsExe.Add(it2);
|
||||
lstDnsExe.Add($"{it2}.exe");
|
||||
}
|
||||
|
||||
if (!lstDirectExe.Contains(it2))
|
||||
{
|
||||
//lstDirectExe.Add(it2);
|
||||
lstDirectExe.Add($"{it2}.exe");
|
||||
}
|
||||
}
|
||||
}
|
||||
routingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe);
|
||||
string strDns = string.Join("\",\"", lstDnsExe.ToArray());
|
||||
configStr = configStr.Replace("$dnsProcessName$", $"\"{strDns}\"");
|
||||
|
||||
|
@ -209,6 +186,33 @@ namespace v2rayN.Base
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void routingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe)
|
||||
{
|
||||
lstDnsExe = new();
|
||||
lstDirectExe = new();
|
||||
var coreInfos = LazyConfig.Instance.GetCoreInfos();
|
||||
foreach (var it in coreInfos)
|
||||
{
|
||||
if (it.coreType == ECoreType.v2rayN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (var it2 in it.coreExes)
|
||||
{
|
||||
if (!lstDnsExe.Contains(it2) && it.coreType != ECoreType.sing_box)
|
||||
{
|
||||
lstDnsExe.Add($"{it2}.exe");
|
||||
}
|
||||
|
||||
if (!lstDirectExe.Contains(it2))
|
||||
{
|
||||
lstDirectExe.Add($"{it2}.exe");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CoreStop()
|
||||
{
|
||||
try
|
||||
|
|
Loading…
Reference in New Issue