feat(CustomHosts): 支持写入Hosts注释

This commit is contained in:
InfinityPacer
2024-08-13 19:02:58 +08:00
parent 4ef08748e4
commit c49e210697

View File

@@ -235,6 +235,12 @@ class CustomHosts(_PluginBase):
for host in hosts:
if not host:
continue
host = host.strip()
if host.startswith('#'): # 检查是否为注释行
host_entry = HostsEntry(entry_type='comment', comment=host)
new_entrys.append(host_entry)
continue
host_arr = str(host).split()
try:
host_entry = HostsEntry(entry_type='ipv4' if IpUtils.is_ipv4(str(host_arr[0])) else 'ipv6',