Development

This commit is contained in:
Matthew Grotke 2026-05-22 02:29:02 -04:00
parent 9f71fe31a6
commit 1b349e5d0a

View file

@ -418,15 +418,28 @@ def setup_caddy(domain, email):
def _lan_ip():
"""Read the LAN IP from routlin's networkd config files."""
"""Read the LAN IP from routlin's networkd config files.
Prefers the physical (untagged) interface its Name has no dot.
Falls back to the first address found across all routlin network files.
"""
import glob
fallback = None
try:
for path in sorted(glob.glob("/etc/systemd/network/10-routlin-*.network")):
for m in re.finditer(r'^Address=(\d+\.\d+\.\d+\.\d+)/', Path(path).read_text(), re.MULTILINE):
return m.group(1)
content = Path(path).read_text()
name_m = re.search(r'^Name=(.+)$', content, re.MULTILINE)
addr_m = re.search(r'^Address=(\d+\.\d+\.\d+\.\d+)/', content, re.MULTILINE)
if not name_m or not addr_m:
continue
ip = addr_m.group(1)
if '.' not in name_m.group(1).strip(): # physical interface, no dot
return ip
if fallback is None:
fallback = ip
except Exception:
pass
return "this server"
return fallback or "this server"
# ===================================================================