Add last ip override

This commit is contained in:
2026-01-03 10:32:02 +01:00
parent c428678663
commit 8ab85c002e
3 changed files with 12 additions and 3 deletions
+6 -2
View File
@@ -14,7 +14,7 @@ Config (config.ini by default):
poll_seconds = 3600 ; optional
Environment overrides (take precedence over config file):
CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID, IPINFO_URL, POLL_SECONDS, CONFIG_PATH
CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID, IPINFO_URL, POLL_SECONDS, CONFIG_PATH, LAST_IP_OVERRIDE
Install dependency:
pip install requests
@@ -52,6 +52,7 @@ def load_config(path: str) -> dict:
"zone_id": get_opt("cloudflare", "zone_id"),
"ipinfo_url": get_opt("service", "ipinfo_url"),
"poll_seconds": None,
"last_ip_override": get_opt("service", "last_ip_override"),
}
poll_raw = get_opt("service", "poll_seconds")
@@ -135,12 +136,15 @@ def main() -> None:
ipinfo_url = os.getenv("IPINFO_URL") or config.get("ipinfo_url") or IPINFO_DEFAULT
poll_seconds = os.getenv("POLL_SECONDS")
poll_seconds = int(poll_seconds) if poll_seconds else config.get("poll_seconds", DEFAULT_POLL_SECONDS)
last_ip_override = os.getenv("LAST_IP_OVERRIDE") or config.get("last_ip_override")
session = requests.Session()
last_ip: Optional[str] = None
last_ip: Optional[str] = last_ip_override
print(f"Starting Cloudflare DDNS watcher (interval={poll_seconds}s)")
print(f"Using IP endpoint: {ipinfo_url}")
if last_ip_override:
print(f"Starting with overridden last_ip: {last_ip_override}")
try:
while True: