mirror of
https://github.com/2dust/v2rayN.git
synced 2026-04-20 22:45:50 +00:00
Remove legacy sing-box dns compatibility (#9163)
This commit is contained in:
parent
d67321eed0
commit
90b055e364
3 changed files with 9 additions and 38 deletions
|
|
@ -261,14 +261,6 @@ public class Server4Sbox : BaseServer4Sbox
|
||||||
|
|
||||||
// public List<string>? path { get; set; } // hosts
|
// public List<string>? path { get; set; } // hosts
|
||||||
public Dictionary<string, List<string>>? predefined { get; set; }
|
public Dictionary<string, List<string>>? predefined { get; set; }
|
||||||
|
|
||||||
// Deprecated in sing-box 1.12.0 , kept for backward compatibility
|
|
||||||
public string? address { get; set; }
|
|
||||||
|
|
||||||
public string? address_resolver { get; set; }
|
|
||||||
public string? address_strategy { get; set; }
|
|
||||||
public string? strategy { get; set; }
|
|
||||||
// Deprecated End
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Experimental4Sbox
|
public class Experimental4Sbox
|
||||||
|
|
|
||||||
|
|
@ -429,15 +429,7 @@ public partial class CoreConfigSingboxService
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_coreConfig.dns = dns4Sbox;
|
_coreConfig.dns = dns4Sbox;
|
||||||
if (dns4Sbox.servers?.Count > 0 &&
|
GenDnsProtectCustom();
|
||||||
dns4Sbox.servers.First().address.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
GenDnsProtectCustom();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GenDnsProtectCustomLegacy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -479,23 +471,6 @@ public partial class CoreConfigSingboxService
|
||||||
_coreConfig.dns = dns4Sbox;
|
_coreConfig.dns = dns4Sbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenDnsProtectCustomLegacy()
|
|
||||||
{
|
|
||||||
GenDnsProtectCustom();
|
|
||||||
|
|
||||||
_coreConfig.dns?.servers?.RemoveAll(s => s.tag == Global.SingboxLocalDNSTag);
|
|
||||||
var dnsItem = context.RawDnsItem;
|
|
||||||
var localDnsServer = new Server4Sbox()
|
|
||||||
{
|
|
||||||
address = string.IsNullOrEmpty(dnsItem?.DomainDNSAddress)
|
|
||||||
? Global.DomainPureIPDNSAddress.FirstOrDefault()
|
|
||||||
: dnsItem?.DomainDNSAddress,
|
|
||||||
tag = Global.SingboxLocalDNSTag,
|
|
||||||
detour = Global.DirectTag,
|
|
||||||
};
|
|
||||||
_coreConfig.dns?.servers?.Add(localDnsServer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rule4Sbox? BuildProtectDomainRule()
|
private Rule4Sbox? BuildProtectDomainRule()
|
||||||
{
|
{
|
||||||
if (context.ProtectDomainList.Count == 0)
|
if (context.ProtectDomainList.Count == 0)
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,9 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
if (NormalDNS2Compatible.IsNotEmpty())
|
if (NormalDNS2Compatible.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(NormalDNS2Compatible);
|
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(NormalDNS2Compatible);
|
||||||
if (obj2 == null)
|
if (obj2 == null
|
||||||
|
|| obj2.servers.Count == 0
|
||||||
|
|| obj2.servers.Any(s => s.type.IsNullOrEmpty()))
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||||
return;
|
return;
|
||||||
|
|
@ -154,7 +156,9 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
if (TunDNS2Compatible.IsNotEmpty())
|
if (TunDNS2Compatible.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible);
|
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible);
|
||||||
if (obj2 == null)
|
if (obj2 == null
|
||||||
|
|| obj2.servers.Count == 0
|
||||||
|
|| obj2.servers.Any(s => s.type.IsNullOrEmpty()))
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||||
return;
|
return;
|
||||||
|
|
@ -174,8 +178,8 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
item2.Enabled = SBCustomDNSEnableCompatible;
|
item2.Enabled = SBCustomDNSEnableCompatible;
|
||||||
item2.DomainStrategy4Freedom = DomainStrategy4Freedom2Compatible;
|
item2.DomainStrategy4Freedom = DomainStrategy4Freedom2Compatible;
|
||||||
item2.DomainDNSAddress = DomainDNSAddress2Compatible;
|
item2.DomainDNSAddress = DomainDNSAddress2Compatible;
|
||||||
item2.NormalDNS = JsonUtils.Serialize(JsonUtils.ParseJson(NormalDNS2Compatible));
|
item2.NormalDNS = JsonUtils.Serialize(JsonUtils.Deserialize<Dns4Sbox>(NormalDNS2Compatible));
|
||||||
item2.TunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(TunDNS2Compatible));
|
item2.TunDNS = JsonUtils.Serialize(JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible));
|
||||||
await ConfigHandler.SaveDNSItems(_config, item2);
|
await ConfigHandler.SaveDNSItems(_config, item2);
|
||||||
|
|
||||||
await ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue