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() {