From cb182125f6d2a7e431de3867a8de1be7dde2cffb Mon Sep 17 00:00:00 2001 From: DHR60 Date: Sat, 13 Sep 2025 11:13:09 +0800 Subject: [PATCH] Fix (#7946) https://github.com/2dust/v2rayN/pull/7937 --- .../Singbox/SingboxRoutingService.cs | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs index 9fec047c..21dfb101 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxRoutingService.cs @@ -72,11 +72,6 @@ public partial class CoreConfigSingboxService } var hostsDomains = new List(); - var systemHostsMap = Utils.GetSystemHosts(); - foreach (var kvp in systemHostsMap) - { - hostsDomains.Add(kvp.Key); - } var dnsItem = await AppManager.Instance.GetDNSItem(ECoreType.sing_box); if (dnsItem == null || dnsItem.Enabled == false) { @@ -89,12 +84,23 @@ public partial class CoreConfigSingboxService hostsDomains.Add(kvp.Key); } } + if (simpleDNSItem.UseSystemHosts == true) + { + var systemHostsMap = Utils.GetSystemHosts(); + foreach (var kvp in systemHostsMap) + { + hostsDomains.Add(kvp.Key); + } + } } - singboxConfig.route.rules.Add(new() + if (hostsDomains.Count > 0) { - action = "resolve", - domain = hostsDomains, - }); + singboxConfig.route.rules.Add(new() + { + action = "resolve", + domain = hostsDomains, + }); + } singboxConfig.route.rules.Add(new() {