mirror of https://github.com/2dust/v2rayN
rename DNSItem to SimpleDNSItem
parent
8405f7db6d
commit
4303997977
|
@ -63,7 +63,6 @@ public sealed class AppHandler
|
|||
SQLiteHelper.Instance.CreateTable<ServerStatItem>();
|
||||
SQLiteHelper.Instance.CreateTable<RoutingItem>();
|
||||
SQLiteHelper.Instance.CreateTable<ProfileExItem>();
|
||||
SQLiteHelper.Instance.CreateTable<DNSItem>();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ public class ConfigHandler
|
|||
|
||||
config.ConstItem ??= new ConstItem();
|
||||
|
||||
config.DNSItem ??= new DNSItem()
|
||||
config.SimpleDNSItem ??= new SimpleDNSItem()
|
||||
{
|
||||
UseSystemHosts = false,
|
||||
AddCommonHosts = true,
|
||||
|
@ -2118,7 +2118,7 @@ public class ConfigHandler
|
|||
config.ConstItem.SrsSourceUrl = "";
|
||||
config.ConstItem.RouteRulesTemplateSourceUrl = "";
|
||||
|
||||
await SQLiteHelper.Instance.DeleteAllAsync<DNSItem>();
|
||||
//await SQLiteHelper.Instance.DeleteAllAsync<SimpleDNSItem>();
|
||||
|
||||
return true;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class Config
|
|||
public List<InItem> Inbound { get; set; }
|
||||
public List<KeyEventItem> GlobalHotkeys { get; set; }
|
||||
public List<CoreTypeItem> CoreTypeItem { get; set; }
|
||||
public DNSItem DNSItem { get; set; }
|
||||
public SimpleDNSItem SimpleDNSItem { get; set; }
|
||||
|
||||
#endregion other entities
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ public class WindowSizeItem
|
|||
}
|
||||
|
||||
[Serializable]
|
||||
public class DNSItem
|
||||
public class SimpleDNSItem
|
||||
{
|
||||
public bool? UseSystemHosts { get; set; }
|
||||
public bool? AddCommonHosts { get; set; }
|
||||
|
|
|
@ -245,7 +245,7 @@ public class CoreConfigSingboxService
|
|||
singboxConfig.route.rules.Add(rule);
|
||||
}
|
||||
|
||||
await GenDnsDomains(singboxConfig, _config.DNSItem);
|
||||
await GenDnsDomains(singboxConfig, _config.SimpleDNSItem);
|
||||
//var dnsServer = singboxConfig.dns?.servers.FirstOrDefault();
|
||||
//if (dnsServer != null)
|
||||
//{
|
||||
|
@ -317,7 +317,7 @@ public class CoreConfigSingboxService
|
|||
await GenOutbound(node, singboxConfig.outbounds.First());
|
||||
}
|
||||
await GenMoreOutbounds(node, singboxConfig);
|
||||
await GenDnsDomains(singboxConfig, _config.DNSItem);
|
||||
await GenDnsDomains(singboxConfig, _config.SimpleDNSItem);
|
||||
|
||||
singboxConfig.route.rules.Clear();
|
||||
singboxConfig.inbounds.Clear();
|
||||
|
@ -1225,7 +1225,7 @@ public class CoreConfigSingboxService
|
|||
try
|
||||
{
|
||||
singboxConfig.route.final = Global.ProxyTag;
|
||||
var item = _config.DNSItem;
|
||||
var item = _config.SimpleDNSItem;
|
||||
singboxConfig.route.default_domain_resolver = new()
|
||||
{
|
||||
server = "outbound_resolver",
|
||||
|
@ -1575,9 +1575,9 @@ public class CoreConfigSingboxService
|
|||
{
|
||||
try
|
||||
{
|
||||
var dNSItem = _config.DNSItem;
|
||||
await GenDnsServers(singboxConfig, dNSItem);
|
||||
await GenDnsRules(singboxConfig, dNSItem);
|
||||
var simpleDNSItem = _config.SimpleDNSItem;
|
||||
await GenDnsServers(singboxConfig, simpleDNSItem);
|
||||
await GenDnsRules(singboxConfig, simpleDNSItem);
|
||||
|
||||
singboxConfig.dns ??= new Dns4Sbox();
|
||||
singboxConfig.dns.independent_cache = true;
|
||||
|
@ -1590,20 +1590,20 @@ public class CoreConfigSingboxService
|
|||
return 0;
|
||||
}
|
||||
|
||||
private async Task<int> GenDnsServers(SingboxConfig singboxConfig, DNSItem dNSItem)
|
||||
private async Task<int> GenDnsServers(SingboxConfig singboxConfig, SimpleDNSItem simpleDNSItem)
|
||||
{
|
||||
var finalDns = await GenDnsDomains(singboxConfig, dNSItem);
|
||||
var finalDns = await GenDnsDomains(singboxConfig, simpleDNSItem);
|
||||
|
||||
var directDns = ParseDnsAddress(dNSItem.DirectDNS);
|
||||
var directDns = ParseDnsAddress(simpleDNSItem.DirectDNS);
|
||||
directDns.tag = "dns_direct";
|
||||
directDns.domain_resolver = "final_resolver";
|
||||
|
||||
var remoteDns = ParseDnsAddress(dNSItem.RemoteDNS);
|
||||
var remoteDns = ParseDnsAddress(simpleDNSItem.RemoteDNS);
|
||||
remoteDns.tag = "dns_remote";
|
||||
remoteDns.detour = Global.ProxyTag;
|
||||
remoteDns.domain_resolver = "final_resolver";
|
||||
|
||||
var resolverDns = ParseDnsAddress(dNSItem.SingboxOutboundsResolveDNS);
|
||||
var resolverDns = ParseDnsAddress(simpleDNSItem.SingboxOutboundsResolveDNS);
|
||||
resolverDns.tag = "outbound_resolver";
|
||||
resolverDns.domain_resolver = "final_resolver";
|
||||
|
||||
|
@ -1612,11 +1612,11 @@ public class CoreConfigSingboxService
|
|||
tag = "dns_hosts",
|
||||
type = "hosts",
|
||||
};
|
||||
if (dNSItem.AddCommonHosts == true)
|
||||
if (simpleDNSItem.AddCommonHosts == true)
|
||||
{
|
||||
hostsDns.predefined = Global.PredefinedHosts;
|
||||
}
|
||||
var userHostsMap = dNSItem.Hosts?
|
||||
var userHostsMap = simpleDNSItem.Hosts?
|
||||
.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Where(line => !string.IsNullOrWhiteSpace(line))
|
||||
.Where(line => line.Contains(' '))
|
||||
|
@ -1670,7 +1670,7 @@ public class CoreConfigSingboxService
|
|||
singboxConfig.dns.servers.Add(hostsDns);
|
||||
|
||||
// fake ip
|
||||
if (dNSItem.FakeIP == true)
|
||||
if (simpleDNSItem.FakeIP == true)
|
||||
{
|
||||
var fakeip = new Server4Sbox
|
||||
{
|
||||
|
@ -1685,9 +1685,9 @@ public class CoreConfigSingboxService
|
|||
return await Task.FromResult(0);
|
||||
}
|
||||
|
||||
private async Task<Server4Sbox> GenDnsDomains(SingboxConfig singboxConfig, DNSItem? dNSItem)
|
||||
private async Task<Server4Sbox> GenDnsDomains(SingboxConfig singboxConfig, SimpleDNSItem? simpleDNSItem)
|
||||
{
|
||||
var finalDns = ParseDnsAddress(dNSItem.SingboxFinalResolveDNS);
|
||||
var finalDns = ParseDnsAddress(simpleDNSItem.SingboxFinalResolveDNS);
|
||||
finalDns.tag = "final_resolver";
|
||||
singboxConfig.dns ??= new Dns4Sbox();
|
||||
singboxConfig.dns.servers ??= new List<Server4Sbox>();
|
||||
|
@ -1695,7 +1695,7 @@ public class CoreConfigSingboxService
|
|||
return await Task.FromResult(finalDns);
|
||||
}
|
||||
|
||||
private async Task<int> GenDnsRules(SingboxConfig singboxConfig, DNSItem dNSItem)
|
||||
private async Task<int> GenDnsRules(SingboxConfig singboxConfig, SimpleDNSItem simpleDNSItem)
|
||||
{
|
||||
singboxConfig.dns ??= new Dns4Sbox();
|
||||
singboxConfig.dns.rules ??= new List<Rule4Sbox>();
|
||||
|
@ -1706,13 +1706,13 @@ public class CoreConfigSingboxService
|
|||
new Rule4Sbox
|
||||
{
|
||||
server = "dns_remote",
|
||||
strategy = string.IsNullOrEmpty(dNSItem.SingboxStrategy4Proxy) ? null : dNSItem.SingboxStrategy4Proxy,
|
||||
strategy = simpleDNSItem.SingboxStrategy4Proxy.IsNullOrEmpty() ? null : simpleDNSItem.SingboxStrategy4Proxy,
|
||||
clash_mode = ERuleMode.Global.ToString()
|
||||
},
|
||||
new Rule4Sbox
|
||||
{
|
||||
server = "dns_direct",
|
||||
strategy = string.IsNullOrEmpty(dNSItem.SingboxStrategy4Direct) ? null : dNSItem.SingboxStrategy4Direct,
|
||||
strategy = simpleDNSItem.SingboxStrategy4Direct.IsNullOrEmpty() ? null : simpleDNSItem.SingboxStrategy4Direct,
|
||||
clash_mode = ERuleMode.Direct.ToString()
|
||||
},
|
||||
new Rule4Sbox
|
||||
|
@ -1732,9 +1732,9 @@ public class CoreConfigSingboxService
|
|||
var expectedIPsRegions = new List<string>();
|
||||
var regionNames = new HashSet<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(dNSItem?.DirectExpectedIPs))
|
||||
if (!string.IsNullOrEmpty(simpleDNSItem?.DirectExpectedIPs))
|
||||
{
|
||||
var ipItems = dNSItem.DirectExpectedIPs
|
||||
var ipItems = simpleDNSItem.DirectExpectedIPs
|
||||
.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(s => s.Trim())
|
||||
.Where(s => !string.IsNullOrEmpty(s))
|
||||
|
@ -1777,7 +1777,7 @@ public class CoreConfigSingboxService
|
|||
if (item.OutboundTag == Global.DirectTag)
|
||||
{
|
||||
rule.server = "dns_direct";
|
||||
rule.strategy = string.IsNullOrEmpty(dNSItem.SingboxStrategy4Direct) ? null : dNSItem.SingboxStrategy4Direct;
|
||||
rule.strategy = string.IsNullOrEmpty(simpleDNSItem.SingboxStrategy4Direct) ? null : simpleDNSItem.SingboxStrategy4Direct;
|
||||
|
||||
if (expectedIPsRegions.Count > 0 && rule.geosite?.Count > 0)
|
||||
{
|
||||
|
@ -1797,14 +1797,14 @@ public class CoreConfigSingboxService
|
|||
}
|
||||
else if (item.OutboundTag == Global.ProxyTag)
|
||||
{
|
||||
if (dNSItem.FakeIP == true)
|
||||
if (simpleDNSItem.FakeIP == true)
|
||||
{
|
||||
var rule4Fake = JsonUtils.DeepCopy(rule);
|
||||
rule4Fake.server = "dns-fake";
|
||||
singboxConfig.dns.rules.Add(rule4Fake);
|
||||
}
|
||||
rule.server = "dns_remote";
|
||||
rule.strategy = string.IsNullOrEmpty(dNSItem.SingboxStrategy4Proxy) ? null : dNSItem.SingboxStrategy4Proxy;
|
||||
rule.strategy = string.IsNullOrEmpty(simpleDNSItem.SingboxStrategy4Proxy) ? null : simpleDNSItem.SingboxStrategy4Proxy;
|
||||
}
|
||||
else if (item.OutboundTag == Global.BlockTag)
|
||||
{
|
||||
|
@ -1929,7 +1929,7 @@ public class CoreConfigSingboxService
|
|||
{
|
||||
enabled = true,
|
||||
path = Utils.GetBinPath("cache.db"),
|
||||
store_fakeip = _config.DNSItem.FakeIP == true
|
||||
store_fakeip = _config.SimpleDNSItem.FakeIP == true
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1137,7 +1137,7 @@ public class CoreConfigV2rayService
|
|||
{
|
||||
try
|
||||
{
|
||||
var dNSItem = _config.DNSItem;
|
||||
var dNSItem = _config.SimpleDNSItem;
|
||||
var domainStrategy4Freedom = dNSItem?.RayStrategy4Freedom;
|
||||
|
||||
//Outbound Freedom domainStrategy
|
||||
|
@ -1164,7 +1164,7 @@ public class CoreConfigV2rayService
|
|||
return 0;
|
||||
}
|
||||
|
||||
private async Task<int> GenDnsServers(ProfileItem? node, V2rayConfig v2rayConfig, DNSItem dNSItem)
|
||||
private async Task<int> GenDnsServers(ProfileItem? node, V2rayConfig v2rayConfig, SimpleDNSItem simpleDNSItem)
|
||||
{
|
||||
static List<string> ParseDnsAddresses(string? dnsInput, string defaultAddress)
|
||||
{
|
||||
|
@ -1192,8 +1192,8 @@ public class CoreConfigV2rayService
|
|||
});
|
||||
}
|
||||
|
||||
var directDNSAddress = ParseDnsAddresses(dNSItem?.DirectDNS, Global.DomainDirectDNSAddress.FirstOrDefault());
|
||||
var remoteDNSAddress = ParseDnsAddresses(dNSItem?.RemoteDNS, Global.DomainRemoteDNSAddress.FirstOrDefault());
|
||||
var directDNSAddress = ParseDnsAddresses(simpleDNSItem?.DirectDNS, Global.DomainDirectDNSAddress.FirstOrDefault());
|
||||
var remoteDNSAddress = ParseDnsAddresses(simpleDNSItem?.RemoteDNS, Global.DomainRemoteDNSAddress.FirstOrDefault());
|
||||
|
||||
var directDomainList = new List<string>();
|
||||
var directGeositeList = new List<string>();
|
||||
|
@ -1203,9 +1203,9 @@ public class CoreConfigV2rayService
|
|||
var expectedIPs = new List<string>();
|
||||
var regionNames = new HashSet<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(dNSItem?.DirectExpectedIPs))
|
||||
if (!string.IsNullOrEmpty(simpleDNSItem?.DirectExpectedIPs))
|
||||
{
|
||||
expectedIPs = dNSItem.DirectExpectedIPs
|
||||
expectedIPs = simpleDNSItem.DirectExpectedIPs
|
||||
.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(s => s.Trim())
|
||||
.Where(s => !string.IsNullOrEmpty(s))
|
||||
|
@ -1317,20 +1317,20 @@ public class CoreConfigV2rayService
|
|||
return 0;
|
||||
}
|
||||
|
||||
private async Task<int> GenDnsHosts(V2rayConfig v2rayConfig, DNSItem dNSItem)
|
||||
private async Task<int> GenDnsHosts(V2rayConfig v2rayConfig, SimpleDNSItem simpleDNSItem)
|
||||
{
|
||||
if (dNSItem.AddCommonHosts == false && dNSItem.UseSystemHosts == false && dNSItem.Hosts.IsNullOrEmpty())
|
||||
if (simpleDNSItem.AddCommonHosts == false && simpleDNSItem.UseSystemHosts == false && simpleDNSItem.Hosts.IsNullOrEmpty())
|
||||
{
|
||||
return await Task.FromResult(0);
|
||||
}
|
||||
v2rayConfig.dns ??= new Dns4Ray();
|
||||
v2rayConfig.dns.hosts ??= new Dictionary<string, List<string>>();
|
||||
if (dNSItem.AddCommonHosts == true)
|
||||
if (simpleDNSItem.AddCommonHosts == true)
|
||||
{
|
||||
v2rayConfig.dns.hosts = Global.PredefinedHosts;
|
||||
}
|
||||
|
||||
if (dNSItem.UseSystemHosts == true)
|
||||
if (simpleDNSItem.UseSystemHosts == true)
|
||||
{
|
||||
var systemHosts = Utils.GetSystemHosts();
|
||||
if (systemHosts.Count > 0)
|
||||
|
@ -1350,7 +1350,7 @@ public class CoreConfigV2rayService
|
|||
}
|
||||
}
|
||||
|
||||
var userHostsMap = dNSItem.Hosts?
|
||||
var userHostsMap = simpleDNSItem.Hosts?
|
||||
.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Where(line => !string.IsNullOrWhiteSpace(line))
|
||||
.Where(line => line.Contains(' '))
|
||||
|
|
|
@ -49,7 +49,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
|||
private async Task Init()
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
var item = _config.DNSItem;
|
||||
var item = _config.SimpleDNSItem;
|
||||
UseSystemHosts = item.UseSystemHosts;
|
||||
AddCommonHosts = item.AddCommonHosts;
|
||||
FakeIP = item.FakeIP;
|
||||
|
@ -67,19 +67,19 @@ public class DNSSettingViewModel : MyReactiveObject
|
|||
|
||||
private async Task SaveSettingAsync()
|
||||
{
|
||||
_config.DNSItem.UseSystemHosts = UseSystemHosts;
|
||||
_config.DNSItem.AddCommonHosts = AddCommonHosts;
|
||||
_config.DNSItem.FakeIP = FakeIP;
|
||||
_config.DNSItem.BlockBindingQuery = BlockBindingQuery;
|
||||
_config.DNSItem.DirectDNS = DirectDNS;
|
||||
_config.DNSItem.RemoteDNS = RemoteDNS;
|
||||
_config.DNSItem.RayStrategy4Freedom = RayStrategy4Freedom;
|
||||
_config.DNSItem.SingboxOutboundsResolveDNS = SingboxOutboundsResolveDNS;
|
||||
_config.DNSItem.SingboxFinalResolveDNS = SingboxFinalResolveDNS;
|
||||
_config.DNSItem.SingboxStrategy4Direct = SingboxStrategy4Direct;
|
||||
_config.DNSItem.SingboxStrategy4Proxy = SingboxStrategy4Proxy;
|
||||
_config.DNSItem.Hosts = Hosts;
|
||||
_config.DNSItem.DirectExpectedIPs = DirectExpectedIPs;
|
||||
_config.SimpleDNSItem.UseSystemHosts = UseSystemHosts;
|
||||
_config.SimpleDNSItem.AddCommonHosts = AddCommonHosts;
|
||||
_config.SimpleDNSItem.FakeIP = FakeIP;
|
||||
_config.SimpleDNSItem.BlockBindingQuery = BlockBindingQuery;
|
||||
_config.SimpleDNSItem.DirectDNS = DirectDNS;
|
||||
_config.SimpleDNSItem.RemoteDNS = RemoteDNS;
|
||||
_config.SimpleDNSItem.RayStrategy4Freedom = RayStrategy4Freedom;
|
||||
_config.SimpleDNSItem.SingboxOutboundsResolveDNS = SingboxOutboundsResolveDNS;
|
||||
_config.SimpleDNSItem.SingboxFinalResolveDNS = SingboxFinalResolveDNS;
|
||||
_config.SimpleDNSItem.SingboxStrategy4Direct = SingboxStrategy4Direct;
|
||||
_config.SimpleDNSItem.SingboxStrategy4Proxy = SingboxStrategy4Proxy;
|
||||
_config.SimpleDNSItem.Hosts = Hosts;
|
||||
_config.SimpleDNSItem.DirectExpectedIPs = DirectExpectedIPs;
|
||||
await ConfigHandler.SaveConfig(_config);
|
||||
if (_updateView != null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue