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.
This commit is contained in:
black-sliver
2025-10-23 22:54:27 +00:00
committed by GitHub
parent df3c6b7980
commit 4f7f092b9b

View File

@@ -146,7 +146,16 @@ def download_SNI() -> None:
signtool: str | None = None signtool: str | None = None
try: 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() html = response.read()
if b"status=OK\n" in html: if b"status=OK\n" in html:
signtool = (r'signtool sign /sha1 6df76fe776b82869a5693ddcb1b04589cffa6faf /fd sha256 /td sha256 ' signtool = (r'signtool sign /sha1 6df76fe776b82869a5693ddcb1b04589cffa6faf /fd sha256 /td sha256 '