Skip to content

Commit

Permalink
opt: 优化界面输出
Browse files Browse the repository at this point in the history
  • Loading branch information
sinspired committed Nov 16, 2024
1 parent fa91672 commit bdf779c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions SetDNS.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,12 @@ def main():
if confirm.lower() == "y":
set_dns_servers(recommended_dns["ipv4"], recommended_dns["ipv6"])
logger.info("DNS服务器已更新")
input("\n任务执行完毕,按任意键退出!")
else:
logger.info("操作已取消")
else:
logger.warning("未找到合适的DNS服务器")
input("\n任务执行失败,按任意键退出!")


def is_admin() -> bool:
Expand Down
6 changes: 4 additions & 2 deletions SetHosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ async def get_best_hosts(

valid_results = [result for result in results if result[1] < latency_limit]
if not valid_results:
logging.warning(f"未找到延迟小于 {latency_limit}ms 的IP。")
logging.warning(f"[bold red]未找到延迟小于 {latency_limit}ms 的IP。[/bold red]")
return []

ipv4_results = [r for r in valid_results if not self.is_ipv6(r[0])]
Expand Down Expand Up @@ -349,10 +349,11 @@ async def update_hosts(self):
rprint(f"\n为组内所有域名应用发现的最快IP:")
for domain in group.domains:
new_entries = [f"{ip}\t{domain}" for ip, latency in fastest_ips]
rprint(f" {domain}:")
rprint(f" {domain}")
# for entry in new_entries:
# rprint(f" {entry}")
all_entries.extend(new_entries)
rprint("\n[green]---------------------------------------------------------[/green]")

if all_entries:
self.write_to_hosts_file(all_entries)
Expand Down Expand Up @@ -520,6 +521,7 @@ async def main():
rprint(
f"[bold]代码运行时间:[/bold] [cyan]{elapsed_time.total_seconds():.2f} 秒[/cyan]"
)
input("\n任务执行完毕,按任意键退出!")


def is_admin() -> bool:
Expand Down

0 comments on commit bdf779c

Please sign in to comment.