From 3def7c53d923745065a11570c776e9623cbf7a77 Mon Sep 17 00:00:00 2001 From: sinspired Date: Wed, 4 Dec 2024 18:34:30 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E4=BC=98=E5=8C=96=E5=BB=B6=E8=BF=9F?= =?UTF-8?q?=E6=B5=8B=E9=80=9F=EF=BC=8C=E5=A4=A7=E5=B9=85=E6=8F=90=E5=8D=87?= =?UTF-8?q?=E6=80=A7=E8=83=BD=EF=BC=9Bconfig:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9B=B4=E5=A4=9ADNS=E6=9C=8D=E5=8A=A1=E5=99=A8=EF=BC=8C?= =?UTF-8?q?=E5=89=94=E9=99=A4=E8=A7=A3=E6=9E=90=E7=BB=93=E6=9E=9C=E8=BE=83?= =?UTF-8?q?=E5=B7=AE=E7=9A=84=E6=9C=8D=E5=8A=A1=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setHosts_Classic.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/setHosts_Classic.py b/setHosts_Classic.py index 453c4a6..cd58f7c 100644 --- a/setHosts_Classic.py +++ b/setHosts_Classic.py @@ -926,7 +926,7 @@ def _sync_is_cert_valid(self, domain: str, ip: str, port: int = 443) -> bool: except ConnectionError as e: logging.debug(f"{domain} ({ip}): 连接被强迫关闭,ip有效 - {e}") - return False + return True except Exception as e: logging.debug(f"{domain} ({ip}): 证书验证失败 - {e}") return False @@ -957,10 +957,7 @@ def _sync_is_cert_valid_dict(self, domain: str, ip: str, latency: float, port: i except ConnectionError as e: logging.debug(f"{domain} ({ip}) { latency:.0f}ms: 连接被强迫关闭,ip有效 - {e}") - rprint(f"{domain} ({ip}) { - latency:.0f}ms: 连接被强迫关闭,ip有效 - {e}") - input("按任意键继续...") - return (ip, latency, False) + return (ip, latency, True) except Exception as e: logging.debug(f"{domain} ({ip}) {latency:.0f}ms: 证书验证失败 - {e}") return (ip, latency, False) @@ -991,12 +988,9 @@ def _sync_is_cert_valid_dict_average(self, domains: List[str], ip: str, latency: return (ip, latency, True) # 任意一个验证通过即返回成功 except ConnectionError as e: - # logging.debug(f"{domain} ({ip}) { - # latency:.0f}ms: 连接被强迫关闭,ip有效 - {e}") - rprint(f"[red]{domain} ({ip}) { - latency:.0f}ms: 连接被强迫关闭,ip有效[/red]") - # input("按任意键继续...\n") - continue # 检查下一个 domain + logging.debug(f"{domain} ({ip}) { + latency:.0f}ms: 连接被强迫关闭,ip有效 - {e}") + return (ip, latency, True) except Exception as e: logging.debug(f"{domain} ({ip}) {latency:.0f}ms: 证书验证失败 - {e}") continue # 检查下一个 domain @@ -1043,7 +1037,7 @@ def _print_results(self, best_hosts: List[Tuple[str, float]], latency_limit: int end_time = datetime.now() total_time = end_time - start_time rprint( - f"[bold]运行时间:[/bold] [cyan]{total_time.total_seconds():.2f} 秒[/cyan]") + f"[bright_black]- 运行时间:[/bright_black] [cyan]{total_time.total_seconds():.2f} 秒[/cyan]") # -------------------- Hosts文件管理 -------------------- #