Add GET parameter to allow useres to change expiry TTL

This commit is contained in:
2026-02-07 22:34:50 +01:00
parent 5b51a8a153
commit eafe106bf1
4 changed files with 119 additions and 18 deletions

View File

@@ -110,6 +110,9 @@ path = "/var/lib/ddns-service/ddns.db" # required for sqlite
[defaults]
# dns_ttl = 60 # default: 60
# expiry_ttl = 3600 # default: 3600
# expiry_ttl_min = # optional, min value via HTTP
# expiry_ttl_max = # optional, max value via HTTP
# expiry_ttl_allow_zero = true # default: true, allow 0 via HTTP
[email]
# enabled = false # default: false
@@ -182,6 +185,7 @@ ipv6 = ["myip6", "ipv6", "ip6"]
username = ["username", "user"]
password = ["password", "pass", "token"]
notify_change = ["notify_change"]
expiry_ttl = ["expiry_ttl"]
[[endpoints]]
path = "/nic/update"
@@ -192,6 +196,7 @@ ipv6 = ["myip6"]
username = ["username"]
password = ["password"]
notify_change = []
expiry_ttl = []
```
**Default accepted parameter names** (first match wins):
@@ -203,6 +208,7 @@ notify_change = []
| username | username, user |
| password | password, pass, token |
| notify_change | notify_change |
| expiry_ttl | expiry_ttl |
## CLI Usage
@@ -295,7 +301,7 @@ kill -HUP $(pidof ddns-service)
### Request
```
GET /update?hostname=mypc.dyn.example.com[&myip=1.2.3.4][&myip6=2001:db8::1][&notify_change=1]
GET /update?hostname=mypc.dyn.example.com[&myip=1.2.3.4][&myip6=2001:db8::1][&notify_change=1][&expiry_ttl=7200]
Authorization: Basic base64(username:password)
```
@@ -306,6 +312,8 @@ GET /update?hostname=mypc.dyn.example.com&username=myuser&password=secret
Set `notify_change=1` to receive an email notification when the IP address changes. Requires email to be enabled and a change notification template configured.
Set `expiry_ttl=N` to change the hostname's expiry TTL (in seconds). Can be sent alone without IP parameters.
### IP Detection
- If `myip` and/or `myip6` provided: use those values
@@ -325,7 +333,7 @@ Set `notify_change=1` to receive an email notification when the IP address chang
**JSON (with `Accept: application/json`):**
```json
{"status": "good", "ipv4": "1.2.3.4", "ipv6": "2001:db8::1"}
{"status": "good", "ipv4": "1.2.3.4", "ipv6": "2001:db8::1", "expiry_ttl": 3600}
```
## Client Examples
@@ -346,6 +354,11 @@ With change notification:
curl -u "username:password" "https://ddns.example.com/update?hostname=mypc.dyn.example.com&notify_change=1"
```
Change expiry TTL:
```bash
curl -u "username:password" "https://ddns.example.com/update?hostname=mypc.dyn.example.com&expiry_ttl=7200"
```
### wget
```bash