Fix IP validation in DDNS and document journalctl sudo rule

Co-authored-by: naturallaw777 <99053422+naturallaw777@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-08-11 10:45:50 +00:00
committed by GitHub
co-authored by naturallaw777
parent f2ad9c1f17
commit 9b77b04741
2 changed files with 14 additions and 2 deletions
+6 -2
View File
@@ -4535,18 +4535,22 @@ def _run_njalla_ddns() -> None:
if not urls:
return
# Resolve current public IP (best-effort; skip if unavailable)
public_ip = ""
try:
ip_result = subprocess.run(
["dig", "@resolver4.opendns.com", "myip.opendns.com", "+short", "-4"],
capture_output=True, text=True, timeout=10, check=False,
)
public_ip = ip_result.stdout.strip()
raw_ip = ip_result.stdout.strip().splitlines()[0] if ip_result.stdout.strip() else ""
# Validate strictly as a proper IPv4/IPv6 address before substitution
ipaddress.ip_address(raw_ip)
public_ip = raw_ip
except Exception:
public_ip = ""
for raw_url in urls:
try:
# Replace the placeholder with the resolved IP (safe string replacement)
# Replace the placeholder with the validated IP (safe string replacement)
url = raw_url.replace("${IP}", public_ip) if public_ip else raw_url
subprocess.run(
["curl", "--silent", "--max-time", "15", "--fail", url],