mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-02 13:18:50 +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;
|
singboxConfig.dns = dns4Sbox;
|
||||||
|
|
||||||
GenDnsDomains(singboxConfig);
|
GenDnsDomains(node, singboxConfig);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -834,19 +834,12 @@ namespace v2rayN.Handler.CoreConfig
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GenDnsDomains(SingboxConfig singboxConfig)
|
private int GenDnsDomains(ProfileItem? node, SingboxConfig singboxConfig)
|
||||||
{
|
{
|
||||||
var dns4Sbox = singboxConfig.dns ?? new();
|
var dns4Sbox = singboxConfig.dns ?? new();
|
||||||
dns4Sbox.servers ??= [];
|
dns4Sbox.servers ??= [];
|
||||||
dns4Sbox.rules ??= [];
|
dns4Sbox.rules ??= [];
|
||||||
|
|
||||||
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";
|
var tag = "local_local";
|
||||||
dns4Sbox.servers.Add(new()
|
dns4Sbox.servers.Add(new()
|
||||||
{
|
{
|
||||||
|
@ -855,12 +848,30 @@ namespace v2rayN.Handler.CoreConfig
|
||||||
detour = Global.DirectTag,
|
detour = Global.DirectTag,
|
||||||
//strategy = strategy
|
//strategy = strategy
|
||||||
});
|
});
|
||||||
dns4Sbox.rules.Add(new()
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
dns4Sbox.rules.Insert(0, new()
|
||||||
{
|
{
|
||||||
server = tag,
|
server = tag,
|
||||||
domain = lstDomain
|
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;
|
singboxConfig.dns = dns4Sbox;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1120,7 +1131,7 @@ namespace v2rayN.Handler.CoreConfig
|
||||||
singboxConfig.route.rules.Add(rule);
|
singboxConfig.route.rules.Add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
GenDnsDomains(singboxConfig);
|
GenDnsDomains(null, singboxConfig);
|
||||||
//var dnsServer = singboxConfig.dns?.servers.FirstOrDefault();
|
//var dnsServer = singboxConfig.dns?.servers.FirstOrDefault();
|
||||||
//if (dnsServer != null)
|
//if (dnsServer != null)
|
||||||
//{
|
//{
|
||||||
|
|
|
@ -218,6 +218,7 @@ namespace v2rayN.Handler
|
||||||
coreType = preCoreType,
|
coreType = preCoreType,
|
||||||
configType = EConfigType.Socks,
|
configType = EConfigType.Socks,
|
||||||
address = Global.Loopback,
|
address = Global.Loopback,
|
||||||
|
sni = node.address, //Tun2SocksAddress
|
||||||
port = LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks)
|
port = LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue