Skip to content

Commit

Permalink
更新 setHosts_Classic.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sinspired authored Dec 7, 2024
1 parent 8fa5e0a commit e60e75a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions setHosts_Classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def write_readme_file(
output_fb.write(readme_content)

rprint(
f"[blue]已更新 README.md 文件,位于: [underline]README.md[/underline][/blue]\n"
"[blue]已更新 README.md 文件,位于: [underline]README.md[/underline][/blue]\n"
)

except FileNotFoundError as e:
Expand Down Expand Up @@ -351,7 +351,8 @@ async def resolve_domain(self, domain: str) -> Set[str]:

ips.update(ipv4_ips + ipv6_ips)
logging.debug(
f"成功通过缓存文件解析 {domain}, 发现 {len(ipv4_ips)+len(ipv6_ips)} 个 DNS 主机:\n{ipv4_ips}\n{ipv6_ips if ipv6_ips else ''}\n"
f"成功通过缓存文件解析 {domain}, 发现 {len(ipv4_ips)
+ len(ipv6_ips)} 个 DNS 主机:\n{ipv4_ips}\n{ipv6_ips if ipv6_ips else ''}\n"
)
else:
ipaddress_ips = await self._resolve_via_ipaddress(domain)
Expand Down Expand Up @@ -604,7 +605,7 @@ async def get_lowest_latency_hosts(
f"[bright_black]- 获取到 [bold bright_green]{len(all_ips)}[/bold bright_green] 个唯一IP地址[/bright_black]"
)
if all_ips:
rprint(f"[bright_black]- 检测主机延迟...[/bright_black]")
rprint("[bright_black]- 检测主机延迟...[/bright_black]")

# 使用线程池来并发处理SSL证书验证
with concurrent.futures.ThreadPoolExecutor(
Expand Down Expand Up @@ -658,7 +659,7 @@ async def get_lowest_latency_hosts(
if len(valid_latency_ips) > 1 and any(
keyword in group_name.lower() for keyword in ["google"]
):
rprint(f"[bright_black]- 验证SSL证书...[/bright_black]")
rprint("[bright_black]- 验证SSL证书...[/bright_black]")
ipv4_count = 0
ipv6_count = 0
batch_size = args.batch_size
Expand All @@ -669,7 +670,7 @@ async def get_lowest_latency_hosts(

for i in range(0, total_results, batch_size):
min_len = min(total_results, batch_size)
batch = valid_latency_ips[i : i + min_len]
batch = valid_latency_ips[i: i + min_len]
ssl_verification_tasks = [
loop.run_in_executor(
executor,
Expand Down Expand Up @@ -899,8 +900,7 @@ def _print_results(self, best_hosts: List[Tuple[str, float]], latency_limit: int
)
for ip, time in best_hosts:
rprint(
f" [green]{
ip}[/green] [bright_black]{time:.2f} ms[/bright_black]"
f" [green]{ip}[/green] [bright_black]{time:.2f} ms[/bright_black]"
)

# end_time = datetime.now()
Expand Down Expand Up @@ -1843,9 +1843,9 @@ def get_dns_cache_file() -> Path:

# 获取用户目录下的 .setHosts,以防止没有写入权限
dns_cache_dir = (
Path(os.getenv("USERPROFILE", os.getenv("HOME")))
/ ".setHosts"
/ "dns_cache"
Path(os.getenv("USERPROFILE", os.getenv("HOME")))/
".setHosts"/
"dns_cache"
)
else:
# 脚本运行时路径
Expand Down

0 comments on commit e60e75a

Please sign in to comment.