mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 05:03:02 +00:00
Support sing-box 1.11 DNS
This commit is contained in:
parent
b53101ce58
commit
a89471da92
2 changed files with 41 additions and 2 deletions
|
|
@ -254,6 +254,13 @@ public class Server4Sbox : BaseServer4Sbox
|
|||
|
||||
// public List<string>? path { get; set; } // hosts
|
||||
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
|
||||
|
|
|
|||
|
|
@ -378,8 +378,15 @@ public partial class CoreConfigSingboxService
|
|||
return;
|
||||
}
|
||||
_coreConfig.dns = dns4Sbox;
|
||||
|
||||
GenDnsProtectCustom();
|
||||
if (dns4Sbox.servers?.Count > 0 &&
|
||||
dns4Sbox.servers.First().address.IsNullOrEmpty())
|
||||
{
|
||||
GenDnsProtectCustom();
|
||||
}
|
||||
else
|
||||
{
|
||||
GenDnsProtectCustomLegacy();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -395,6 +402,16 @@ public partial class CoreConfigSingboxService
|
|||
dns4Sbox.rules ??= [];
|
||||
|
||||
var tag = Global.SingboxLocalDNSTag;
|
||||
dns4Sbox.rules.Insert(0, new()
|
||||
{
|
||||
server = tag,
|
||||
clash_mode = ERuleMode.Direct.ToString()
|
||||
});
|
||||
dns4Sbox.rules.Insert(0, new()
|
||||
{
|
||||
server = dns4Sbox.servers.Where(t => t.detour == Global.ProxyTag).Select(t => t.tag).FirstOrDefault() ?? "remote",
|
||||
clash_mode = ERuleMode.Global.ToString()
|
||||
});
|
||||
|
||||
var finalDnsAddress = string.IsNullOrEmpty(dnsItem?.DomainDNSAddress) ? Global.DomainPureIPDNSAddress.FirstOrDefault() : dnsItem?.DomainDNSAddress;
|
||||
|
||||
|
|
@ -407,6 +424,21 @@ public partial class CoreConfigSingboxService
|
|||
_coreConfig.dns = dns4Sbox;
|
||||
}
|
||||
|
||||
private void GenDnsProtectCustomLegacy()
|
||||
{
|
||||
GenDnsProtectCustom();
|
||||
|
||||
var localDnsServer = _coreConfig.dns?.servers?.FirstOrDefault(s => s.tag == Global.SingboxLocalDNSTag);
|
||||
if (localDnsServer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
localDnsServer.type = null;
|
||||
localDnsServer.server = null;
|
||||
var dnsItem = context.RawDnsItem;
|
||||
localDnsServer.address = string.IsNullOrEmpty(dnsItem?.DomainDNSAddress) ? Global.DomainPureIPDNSAddress.FirstOrDefault() : dnsItem?.DomainDNSAddress;
|
||||
}
|
||||
|
||||
private Rule4Sbox BuildProtectDomainRule()
|
||||
{
|
||||
return new()
|
||||
|
|
|
|||
Loading…
Reference in a new issue