diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs index 00bb14d9..f31cd012 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs @@ -44,14 +44,28 @@ public partial class CoreConfigSingboxService } // Tun2SocksAddress - if (node != null && Utils.IsDomain(node.Address)) + if (node != null) { - singboxConfig.dns.rules ??= new List(); - singboxConfig.dns.rules.Insert(0, new Rule4Sbox + string? domainToAdd = null; + + if (Utils.IsDomain(node.Address)) { - server = Global.SingboxOutboundResolverTag, - domain = [node.Address], - }); + domainToAdd = node.Address; + } + else if (node.Sni != null && Utils.IsDomain(node.Sni)) + { + domainToAdd = node.Sni; + } + + if (domainToAdd != null) + { + singboxConfig.dns.rules ??= new List(); + singboxConfig.dns.rules.Insert(0, new Rule4Sbox + { + server = Global.SingboxDirectDNSTag, + domain = [domainToAdd], + }); + } } } catch (Exception ex) @@ -347,14 +361,28 @@ public partial class CoreConfigSingboxService } // Tun2SocksAddress - if (node != null && Utils.IsDomain(node.Address)) + if (node != null) { - singboxConfig.dns.rules ??= new List(); - singboxConfig.dns.rules.Insert(0, new Rule4Sbox + string? domainToAdd = null; + + if (Utils.IsDomain(node.Address)) { - server = Global.SingboxFinalResolverTag, - domain = [node.Address], - }); + domainToAdd = node.Address; + } + else if (node.Sni != null && Utils.IsDomain(node.Sni)) + { + domainToAdd = node.Sni; + } + + if (domainToAdd != null) + { + singboxConfig.dns.rules ??= new List(); + singboxConfig.dns.rules.Insert(0, new Rule4Sbox + { + server = Global.SingboxDirectDNSTag, + domain = [domainToAdd], + }); + } } } catch (Exception ex)