From 4f7f092b9b5d47caff9d1fdbc72b3d36d23788f4 Mon Sep 17 00:00:00 2001 From: black-sliver <59490463+black-sliver@users.noreply.github.com> Date: Thu, 23 Oct 2025 22:54:27 +0000 Subject: [PATCH] setup: check if the sign host is on a local network (#5501) Could have a really bad timeout if it goes through default route and packet is dropped. --- setup.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1a39857b..05e677f0 100644 --- a/setup.py +++ b/setup.py @@ -146,7 +146,16 @@ def download_SNI() -> None: signtool: str | None = None try: - with urllib.request.urlopen('http://192.168.206.4:12345/connector/status') as response: + import socket + + sign_host, sign_port = "192.168.206.4", 12345 + # check if the sign_host is on a local network + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + s.connect((sign_host, sign_port)) + if s.getsockname()[0].rsplit(".", 1)[0] != sign_host.rsplit(".", 1)[0]: + raise ConnectionError() # would go through default route + # configure signtool + with urllib.request.urlopen(f"http://{sign_host}:{sign_port}/connector/status") as response: html = response.read() if b"status=OK\n" in html: signtool = (r'signtool sign /sha1 6df76fe776b82869a5693ddcb1b04589cffa6faf /fd sha256 /td sha256 '