mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-23 03:16:53 +00:00
Adds DNS routing
This commit is contained in:
parent
7b082cf870
commit
aee02245fc
2 changed files with 28 additions and 1 deletions
|
@ -48,6 +48,7 @@ public class Global
|
||||||
public const string ProxyTag = "proxy";
|
public const string ProxyTag = "proxy";
|
||||||
public const string DirectTag = "direct";
|
public const string DirectTag = "direct";
|
||||||
public const string BlockTag = "block";
|
public const string BlockTag = "block";
|
||||||
|
public const string DnsTag = "dns-module";
|
||||||
public const string StreamSecurity = "tls";
|
public const string StreamSecurity = "tls";
|
||||||
public const string StreamSecurityReality = "reality";
|
public const string StreamSecurityReality = "reality";
|
||||||
public const string Loopback = "127.0.0.1";
|
public const string Loopback = "127.0.0.1";
|
||||||
|
|
|
@ -1143,7 +1143,21 @@ public class CoreConfigV2rayService
|
||||||
var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
|
var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
|
||||||
if (item != null && item.Enabled == true)
|
if (item != null && item.Enabled == true)
|
||||||
{
|
{
|
||||||
return await GenDnsCompatible(node, v2rayConfig);
|
var result = await GenDnsCompatible(node, v2rayConfig);
|
||||||
|
|
||||||
|
if (v2rayConfig.routing.domainStrategy == "IPIfNonMatch")
|
||||||
|
{
|
||||||
|
// DNS routing
|
||||||
|
v2rayConfig.dns.tag = Global.DnsTag;
|
||||||
|
v2rayConfig.routing.rules.Add(new RulesItem4Ray
|
||||||
|
{
|
||||||
|
type = "field",
|
||||||
|
inboundTag = new List<string> { Global.DnsTag },
|
||||||
|
outboundTag = Global.ProxyTag,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
var simpleDNSItem = _config.SimpleDNSItem;
|
var simpleDNSItem = _config.SimpleDNSItem;
|
||||||
var domainStrategy4Freedom = simpleDNSItem?.RayStrategy4Freedom;
|
var domainStrategy4Freedom = simpleDNSItem?.RayStrategy4Freedom;
|
||||||
|
@ -1164,6 +1178,18 @@ public class CoreConfigV2rayService
|
||||||
|
|
||||||
await GenDnsServers(node, v2rayConfig, simpleDNSItem);
|
await GenDnsServers(node, v2rayConfig, simpleDNSItem);
|
||||||
await GenDnsHosts(v2rayConfig, simpleDNSItem);
|
await GenDnsHosts(v2rayConfig, simpleDNSItem);
|
||||||
|
|
||||||
|
if (v2rayConfig.routing.domainStrategy == "IPIfNonMatch")
|
||||||
|
{
|
||||||
|
// DNS routing
|
||||||
|
v2rayConfig.dns.tag = Global.DnsTag;
|
||||||
|
v2rayConfig.routing.rules.Add(new RulesItem4Ray
|
||||||
|
{
|
||||||
|
type = "field",
|
||||||
|
inboundTag = new List<string> { Global.DnsTag },
|
||||||
|
outboundTag = Global.ProxyTag,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue