This commit is contained in:
DHR60 2025-08-18 21:35:24 +08:00
parent e104f9f9b2
commit 7caddc573c

View file

@ -67,6 +67,9 @@ public partial class CoreConfigSingboxService
{ {
hostsDns.predefined = Global.PredefinedHosts; hostsDns.predefined = Global.PredefinedHosts;
} }
if (!simpleDNSItem.Hosts.IsNullOrEmpty())
{
var userHostsMap = simpleDNSItem.Hosts? var userHostsMap = simpleDNSItem.Hosts?
.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries) .Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
.Where(line => !string.IsNullOrWhiteSpace(line)) .Where(line => !string.IsNullOrWhiteSpace(line))
@ -83,10 +86,8 @@ public partial class CoreConfigSingboxService
var values = parts.Skip(1).ToList(); var values = parts.Skip(1).ToList();
return values; return values;
} }
); ) ?? new Dictionary<string, List<string>>();
if (userHostsMap != null)
{
foreach (var kvp in userHostsMap) foreach (var kvp in userHostsMap)
{ {
hostsDns.predefined[kvp.Key] = kvp.Value; hostsDns.predefined[kvp.Key] = kvp.Value;
@ -100,11 +101,11 @@ public partial class CoreConfigSingboxService
{ {
foreach (var host in systemHosts) foreach (var host in systemHosts)
{ {
if (userHostsMap[host.Key] != null) if (hostsDns.predefined[host.Key] != null)
{ {
continue; continue;
} }
userHostsMap[host.Key] = new List<string> { host.Value }; hostsDns.predefined[host.Key] = new List<string> { host.Value };
} }
} }
} }