From ffe401a26d2bdc9b906d48b7856011c315b1b4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E8=90=BD?= <53731501+qyl27@users.noreply.github.com> Date: Fri, 30 Jan 2026 15:32:06 +0800 Subject: [PATCH] Accept hosts.ics as a host file on windows. (#8714) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 秋雨落 --- v2rayN/ServiceLib/Common/Utils.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index fe2b1549..0f4feda5 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -719,10 +719,9 @@ public class Utils return Guid.TryParse(strSrc, out _); } - public static Dictionary GetSystemHosts() + private static Dictionary GetSystemHosts(string hostFile) { var systemHosts = new Dictionary(); - var hostFile = @"C:\Windows\System32\drivers\etc\hosts"; try { if (File.Exists(hostFile)) @@ -755,6 +754,19 @@ public class Utils return systemHosts; } + public static Dictionary 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 GetCliWrapOutput(string filePath, string? arg) { return await GetCliWrapOutput(filePath, arg != null ? new List() { arg } : null);