mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-01 12:48:49 +00:00
parent
691b19b5fd
commit
324f46cdad
2 changed files with 25 additions and 13 deletions
|
@ -825,7 +825,7 @@ namespace v2rayN.Handler.CoreConfig
|
|||
}
|
||||
singboxConfig.dns = dns4Sbox;
|
||||
|
||||
GenDnsDomains(singboxConfig);
|
||||
GenDnsDomains(node, singboxConfig);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -834,33 +834,44 @@ namespace v2rayN.Handler.CoreConfig
|
|||
return 0;
|
||||
}
|
||||
|
||||
private int GenDnsDomains(SingboxConfig singboxConfig)
|
||||
private int GenDnsDomains(ProfileItem? node, SingboxConfig singboxConfig)
|
||||
{
|
||||
var dns4Sbox = singboxConfig.dns ?? new();
|
||||
dns4Sbox.servers ??= [];
|
||||
dns4Sbox.rules ??= [];
|
||||
|
||||
var tag = "local_local";
|
||||
dns4Sbox.servers.Add(new()
|
||||
{
|
||||
tag = tag,
|
||||
address = "223.5.5.5",
|
||||
detour = Global.DirectTag,
|
||||
//strategy = strategy
|
||||
});
|
||||
|
||||
var lstDomain = singboxConfig.outbounds
|
||||
.Where(t => !Utils.IsNullOrEmpty(t.server) && Utils.IsDomain(t.server))
|
||||
.Select(t => t.server)
|
||||
.ToList();
|
||||
if (lstDomain != null && lstDomain.Count > 0)
|
||||
{
|
||||
//var strategy = dns4Sbox.servers.Where(t => !Utils.IsNullOrEmpty(t.strategy)).Select(t => t.strategy).FirstOrDefault();
|
||||
var tag = "local_local";
|
||||
dns4Sbox.servers.Add(new()
|
||||
{
|
||||
tag = tag,
|
||||
address = "223.5.5.5",
|
||||
detour = Global.DirectTag,
|
||||
//strategy = strategy
|
||||
});
|
||||
dns4Sbox.rules.Add(new()
|
||||
dns4Sbox.rules.Insert(0, new()
|
||||
{
|
||||
server = tag,
|
||||
domain = lstDomain
|
||||
});
|
||||
}
|
||||
|
||||
//Tun2SocksAddress
|
||||
if (_config.tunModeItem.enableTun && node?.configType == EConfigType.Socks && Utils.IsDomain(node?.sni))
|
||||
{
|
||||
dns4Sbox.rules.Insert(0, new()
|
||||
{
|
||||
server = tag,
|
||||
domain = [node?.sni]
|
||||
});
|
||||
}
|
||||
|
||||
singboxConfig.dns = dns4Sbox;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1120,7 +1131,7 @@ namespace v2rayN.Handler.CoreConfig
|
|||
singboxConfig.route.rules.Add(rule);
|
||||
}
|
||||
|
||||
GenDnsDomains(singboxConfig);
|
||||
GenDnsDomains(null, singboxConfig);
|
||||
//var dnsServer = singboxConfig.dns?.servers.FirstOrDefault();
|
||||
//if (dnsServer != null)
|
||||
//{
|
||||
|
|
|
@ -218,6 +218,7 @@ namespace v2rayN.Handler
|
|||
coreType = preCoreType,
|
||||
configType = EConfigType.Socks,
|
||||
address = Global.Loopback,
|
||||
sni = node.address, //Tun2SocksAddress
|
||||
port = LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks)
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue