pull/7805/head
DHR60 2025-08-19 09:09:35 +08:00 committed by GitHub
parent e104f9f9b2
commit 4853e2348d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 20 deletions

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 };
} }
} }
} }