feat: DNS-free WAN IP detection + add calibre to records

Use Cloudflare 1.1.1.1/cdn-cgi/trace as primary IP source (fixed IP, no resolver dependency — survives AdGuard/upstream DNS outages). Add calibre to DNS_RECORDS: its A record points at the dynamic WAN IP but was not guarded, so it would go stale on the next WAN change.
This commit is contained in:
Eddy de Vink 2026-09-25 10:44:53 +02:00
commit 4f9b2c064e
3 changed files with 15 additions and 8 deletions

View file

@ -66,7 +66,7 @@ sudo systemctl enable --now wan-ip-guard.timer
| `MATRIX_API_ENDPOINT` | Matrix homeserver API | `https://whatsed.eddydevink.nl` |
| `MATRIX_TOKEN_FILE` | Bestand met Sherpa compat-token | `/home/aiaiaiaiagent/whatsed-new/secrets/sherpa-token` |
| `MATRIX_ROOM_FILE` | Bestand met DM-room voor Eddy | `/home/aiaiaiaiagent/whatsed-new/secrets/eddy-report-room` |
| `DNS_RECORDS` | Komma-gescheiden records | `example.com,git,www` |
| `DNS_RECORDS` | Komma-gescheiden records | `example.com,git,www,whatsed,auth.whatsed,calibre` |
| `EURODYNDNS_USER` | EuroDNS site-login (dyndns2) | `your_login` |
| `EURODYNDNS_PASS` | EuroDNS site-password (dyndns2) | `your_password` |
| `EURODYNDNS_HOSTS` | EuroDynDNS-hostnames (domeinen in EuroDNS-zone) | `eddydev.ink,www.eddydev.ink` |
@ -116,7 +116,7 @@ wan-ip-guard.service: Failed to spawn 'start' task: Permission denied
## Hoe het werkt
1. **IP detectie:** Haalt het WAN IP op via `ifconfig.me` met fallback naar `api.ipify.org` en `icanhazip.com`
1. **IP detectie:** Haalt het WAN IP op via `https://1.1.1.1/cdn-cgi/trace` (Cloudflare, DNS-vrij — werkt als de lokale resolver uitvalt) met fallback naar `ifconfig.me`, `api.ipify.org` en `icanhazip.com`
2. **State vergelijking:** Vergelijkt met het laatst opgeslagen IP in de state file
3. **DNS update:** Voor elke record worden eerst alle bestaande A-records met de exacte oude waarde verwijderd en daarna één nieuw A-record toegevoegd via DirectAdmin API. De delete-aanroep gebruikt `action=select` en een URL-gecodeerde waarde `name=<recordnaam>&value=<oude-ip>` in parameter `arecs0`. De waarde moet dus niet `recordnaam=ip` zijn.
4. **EuroDynDNS:** Hostnames in `EURODYNDNS_HOSTS` (domeinen die in de EuroDNS-zone staan, bv. `eddydev.ink`) worden bij een IP-wijziging via de EuroDynDNS-update-URL bijgewerkt: `https://update.eurodyndns.org/update/?hostname=<fqdn>&myip=<ip>` met HTTP Basic auth (`EURODYNDNS_USER`/`EURODYNDNS_PASS`, de EuroDNS site-login/password). Een antwoord `good`/`nochg` telt als succes; een foutcode (`badauth`, `!yours`, `notfqdn`, …) als mislukking.