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:
11
setup.py
11
setup.py
@@ -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 '
|
||||||
|
|||||||
Reference in New Issue
Block a user