mirror of https://github.com/2dust/v2rayN
parent
a73906505c
commit
dcc9c9fa14
|
@ -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";
|
||||||
|
|
|
@ -203,8 +203,15 @@ public class Response4Ray
|
||||||
|
|
||||||
public class Dns4Ray
|
public class Dns4Ray
|
||||||
{
|
{
|
||||||
public Dictionary<string, List<string>>? hosts { get; set; }
|
public Dictionary<string, object>? hosts { get; set; }
|
||||||
public List<object> servers { get; set; }
|
public List<object> servers { get; set; }
|
||||||
|
public string? clientIp { get; set; }
|
||||||
|
public string? queryStrategy { get; set; }
|
||||||
|
public bool? disableCache { get; set; }
|
||||||
|
public bool? disableFallback { get; set; }
|
||||||
|
public bool? disableFallbackIfMatch { get; set; }
|
||||||
|
public bool? useSystemHosts { get; set; }
|
||||||
|
public string? tag { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DnsServer4Ray
|
public class DnsServer4Ray
|
||||||
|
@ -214,6 +221,12 @@ public class DnsServer4Ray
|
||||||
public bool? skipFallback { get; set; }
|
public bool? skipFallback { get; set; }
|
||||||
public List<string>? expectedIPs { get; set; }
|
public List<string>? expectedIPs { get; set; }
|
||||||
public List<string>? unexpectedIPs { get; set; }
|
public List<string>? unexpectedIPs { get; set; }
|
||||||
|
public string? clientIp { get; set; }
|
||||||
|
public string? queryStrategy { get; set; }
|
||||||
|
public int? timeoutMs { get; set; }
|
||||||
|
public bool? disableCache { get; set; }
|
||||||
|
public bool? finalQuery { get; set; }
|
||||||
|
public string? tag { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Routing4Ray
|
public class Routing4Ray
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -1340,10 +1366,13 @@ public class CoreConfigV2rayService
|
||||||
return await Task.FromResult(0);
|
return await Task.FromResult(0);
|
||||||
}
|
}
|
||||||
v2rayConfig.dns ??= new Dns4Ray();
|
v2rayConfig.dns ??= new Dns4Ray();
|
||||||
v2rayConfig.dns.hosts ??= new Dictionary<string, List<string>>();
|
v2rayConfig.dns.hosts ??= new Dictionary<string, object>();
|
||||||
if (simpleDNSItem.AddCommonHosts == true)
|
if (simpleDNSItem.AddCommonHosts == true)
|
||||||
{
|
{
|
||||||
v2rayConfig.dns.hosts = Global.PredefinedHosts;
|
v2rayConfig.dns.hosts = Global.PredefinedHosts.ToDictionary(
|
||||||
|
kvp => kvp.Key,
|
||||||
|
kvp => (object)kvp.Value
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simpleDNSItem.UseSystemHosts == true)
|
if (simpleDNSItem.UseSystemHosts == true)
|
||||||
|
|
Loading…
Reference in New Issue