From 0770e3003436f46999411eb2626ae5dba8df7c26 Mon Sep 17 00:00:00 2001 From: th1nker <69061641+th1nk-er@users.noreply.github.com> Date: Mon, 8 Sep 2025 18:02:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=B3=BB=E7=BB=9Fhosts=20(#7903)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复当host的记录存在行尾注释时,无法将其添加到dns.host中 示例hosts ``` 127.0.0.1 test1.com 127.0.0.1 test2.com # test ``` 在之前仅仅会添加`127.0.0.1 test1.com`这条记录,而忽略另一条 --- v2rayN/ServiceLib/Common/Utils.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index 38869ebb..49a359c0 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -582,9 +582,9 @@ public class Utils if (host.StartsWith("#")) continue; var hostItem = host.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); - if (hostItem.Length != 2) + if (hostItem.Length < 2) continue; - systemHosts.Add(hostItem.Last(), hostItem.First()); + systemHosts.Add(hostItem[1], hostItem[0]); } } }