Development
This commit is contained in:
parent
9f71fe31a6
commit
1b349e5d0a
1 changed files with 17 additions and 4 deletions
|
|
@ -418,15 +418,28 @@ def setup_caddy(domain, email):
|
||||||
|
|
||||||
|
|
||||||
def _lan_ip():
|
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
|
import glob
|
||||||
|
fallback = None
|
||||||
try:
|
try:
|
||||||
for path in sorted(glob.glob("/etc/systemd/network/10-routlin-*.network")):
|
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):
|
content = Path(path).read_text()
|
||||||
return m.group(1)
|
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:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return "this server"
|
return fallback or "this server"
|
||||||
|
|
||||||
|
|
||||||
# ===================================================================
|
# ===================================================================
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue