mirror of
https://github.com/2dust/v2rayN.git
synced 2026-04-14 19:45:45 +00:00
Fix sing-box tun
This commit is contained in:
parent
43dcb90632
commit
f1b3a8a28c
2 changed files with 11 additions and 36 deletions
|
|
@ -11,7 +11,7 @@ public partial class CoreConfigSingboxService
|
|||
_coreConfig.inbounds = [];
|
||||
|
||||
if (!context.IsTunEnabled
|
||||
|| (context.IsTunEnabled && _node.Port != listenPort))
|
||||
|| (context.IsTunEnabled && _node.Address != Global.Loopback && _node.Port != listenPort))
|
||||
{
|
||||
var inbound = new Inbound4Sbox()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ public partial class CoreConfigSingboxService
|
|||
_coreConfig.route.rules.AddRange(tunRules);
|
||||
}
|
||||
|
||||
var (lstDnsExe, lstDirectExe) = BuildRoutingDirectExe();
|
||||
_coreConfig.route.rules.Add(new()
|
||||
{
|
||||
port = [53],
|
||||
action = "hijack-dns",
|
||||
process_name = lstDnsExe
|
||||
network = ["udp"],
|
||||
action = "hijack-dns"
|
||||
});
|
||||
|
||||
var lstDirectExe = BuildRoutingDirectExe();
|
||||
_coreConfig.route.rules.Add(new()
|
||||
{
|
||||
outbound = Global.DirectTag,
|
||||
|
|
@ -79,28 +79,6 @@ public partial class CoreConfigSingboxService
|
|||
}
|
||||
}
|
||||
|
||||
if (_config.Inbound.First().SniffingEnabled)
|
||||
{
|
||||
_coreConfig.route.rules.Add(new()
|
||||
{
|
||||
action = "sniff"
|
||||
});
|
||||
_coreConfig.route.rules.Add(new()
|
||||
{
|
||||
protocol = ["dns"],
|
||||
action = "hijack-dns"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_coreConfig.route.rules.Add(new()
|
||||
{
|
||||
port = [53],
|
||||
network = ["udp"],
|
||||
action = "hijack-dns"
|
||||
});
|
||||
}
|
||||
|
||||
var hostsDomains = new List<string>();
|
||||
if (rawDNSItem is not { Enabled: true })
|
||||
{
|
||||
|
|
@ -234,9 +212,8 @@ public partial class CoreConfigSingboxService
|
|||
}
|
||||
}
|
||||
|
||||
private static (List<string> lstDnsExe, List<string> lstDirectExe) BuildRoutingDirectExe()
|
||||
private static List<string> BuildRoutingDirectExe()
|
||||
{
|
||||
var dnsExeSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
var directExeSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var coreInfoResult = CoreInfoManager.Instance.GetCoreInfo();
|
||||
|
|
@ -248,20 +225,18 @@ public partial class CoreConfigSingboxService
|
|||
continue;
|
||||
}
|
||||
|
||||
if (coreConfig.CoreExes == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var baseExeName in coreConfig.CoreExes)
|
||||
{
|
||||
if (coreConfig.CoreType != ECoreType.sing_box)
|
||||
{
|
||||
dnsExeSet.Add(Utils.GetExeName(baseExeName));
|
||||
}
|
||||
directExeSet.Add(Utils.GetExeName(baseExeName));
|
||||
}
|
||||
}
|
||||
|
||||
var lstDnsExe = new List<string>(dnsExeSet);
|
||||
var lstDirectExe = new List<string>(directExeSet);
|
||||
|
||||
return (lstDnsExe, lstDirectExe);
|
||||
return new List<string>(directExeSet);
|
||||
}
|
||||
|
||||
private void GenRoutingUserRule(RulesItem? item)
|
||||
|
|
|
|||
Loading…
Reference in a new issue