diff --git a/packages/node/meshnet_node/startup.py b/packages/node/meshnet_node/startup.py index a712590..6c36a7c 100644 --- a/packages/node/meshnet_node/startup.py +++ b/packages/node/meshnet_node/startup.py @@ -128,6 +128,19 @@ def run_startup( tracker_url = tracker_url.rstrip("/") # 1. Hardware detection + if advertise_host is None and host == "0.0.0.0": + # socket.getfqdn() returns an mDNS name (.local / .localdomain) that remote + # machines on a different OS or subnet often can't resolve. Instead, probe the + # outbound IP by opening a UDP socket toward the tracker — no data is sent. + try: + _tracker_host = urllib.parse.urlparse(tracker_url).hostname or "8.8.8.8" + _s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + _s.connect((_tracker_host, 80)) + advertise_host = _s.getsockname()[0] + _s.close() + except Exception: + advertise_host = socket.getfqdn() + print("Detecting hardware...", flush=True) hw = detect_hardware() device: str = hw["device"]