From 56f1794e47c99d1124e959cb5116dd528fc861f4 Mon Sep 17 00:00:00 2001 From: DHR60 Date: Sun, 1 Mar 2026 10:38:16 +0000 Subject: [PATCH] Fix DNS rule (#8866) --- .../CoreConfig/Singbox/SingboxDnsService.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs index 03f4e80c..4b8b65aa 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs @@ -148,15 +148,20 @@ public partial class CoreConfigSingboxService _coreConfig.dns ??= new Dns4Sbox(); _coreConfig.dns.rules ??= []; - _coreConfig.dns.rules.AddRange(new[] + _coreConfig.dns.rules.Add(new() { ip_accept_any = true, server = Global.SingboxHostsDNSTag }); + + if (context.ProtectDomainList.Count > 0) { - new Rule4Sbox { ip_accept_any = true, server = Global.SingboxHostsDNSTag }, - new Rule4Sbox + _coreConfig.dns.rules.Add(new() { server = Global.SingboxDirectDNSTag, strategy = Utils.DomainStrategy4Sbox(simpleDnsItem.Strategy4Freedom), domain = context.ProtectDomainList.ToList(), - }, + }); + } + + _coreConfig.dns.rules.AddRange(new[] + { new Rule4Sbox { server = Global.SingboxRemoteDNSTag,