Accept hosts.ics as a host file on windows. (#8714)

Signed-off-by: 秋雨落 <i@rain.cx>
This commit is contained in:
雨落
2026-01-30 15:32:06 +08:00
committed by GitHub
parent 8774e302b2
commit ffe401a26d

View File

@@ -719,10 +719,9 @@ public class Utils
return Guid.TryParse(strSrc, out _); return Guid.TryParse(strSrc, out _);
} }
public static Dictionary<string, string> GetSystemHosts() private static Dictionary<string, string> GetSystemHosts(string hostFile)
{ {
var systemHosts = new Dictionary<string, string>(); var systemHosts = new Dictionary<string, string>();
var hostFile = @"C:\Windows\System32\drivers\etc\hosts";
try try
{ {
if (File.Exists(hostFile)) if (File.Exists(hostFile))
@@ -755,6 +754,19 @@ public class Utils
return systemHosts; return systemHosts;
} }
public static Dictionary<string, string> GetSystemHosts()
{
var hosts = GetSystemHosts(@"C:\Windows\System32\drivers\etc\hosts");
var hostsIcs = GetSystemHosts(@"C:\Windows\System32\drivers\etc\hosts.ics");
foreach (var (key, value) in hostsIcs)
{
hosts[key] = value;
}
return hosts;
}
public static async Task<string?> GetCliWrapOutput(string filePath, string? arg) public static async Task<string?> GetCliWrapOutput(string filePath, string? arg)
{ {
return await GetCliWrapOutput(filePath, arg != null ? new List<string>() { arg } : null); return await GetCliWrapOutput(filePath, arg != null ? new List<string>() { arg } : null);