From bbe57d5f07b37c6dfb91223c79f8357a7c907fee Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Tue, 30 Jun 2026 02:27:10 +0300 Subject: [PATCH] fix: advertise LAN IP instead of mDNS hostname when --host 0.0.0.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit socket.getfqdn() returns *.localdomain names that other machines on the same LAN (especially cross-OS) cannot resolve via DNS. When the node is bound to 0.0.0.0 and --advertise-host is not given, probe the outbound IP by connecting a UDP socket toward the tracker — this picks the correct interface IP without sending any data. Co-Authored-By: Claude Sonnet 4.6 --- packages/node/meshnet_node/startup.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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"]