feat(config): read both owner and domain from domain

- retro-compatible change: keep using host/owner if set
- otherwise extract owner and eTLD+1 from domain field
- documentation updated to only use the `domain` field
This commit is contained in:
Quentin McGaw
2024-06-27 13:03:59 +00:00
parent 55d8c0d703
commit 07d7645d78
51 changed files with 175 additions and 169 deletions

View File

@@ -120,8 +120,7 @@ This readme and the [docs/](docs/) directory are **versioned** to match the prog
"settings": [ "settings": [
{ {
"provider": "namecheap", "provider": "namecheap",
"domain": "example.com", "domain": "sub.example.com",
"owner": "@",
"password": "e5322165c1d74692bfa6d807100c0310" "password": "e5322165c1d74692bfa6d807100c0310"
} }
] ]
@@ -165,8 +164,7 @@ This readme and the [docs/](docs/) directory are **versioned** to match the prog
"settings": [ "settings": [
{ {
"provider": "namecheap", "provider": "namecheap",
"domain": "example.com", "domain": "sub.example.com",
"owner": "@",
"password": "e5322165c1d74692bfa6d807100c0310" "password": "e5322165c1d74692bfa6d807100c0310"
} }
] ]
@@ -256,7 +254,7 @@ Check the documentation for your DNS provider:
Note that: Note that:
- you can specify multiple hosts for the same domain using a comma separated list. For example with `"owner": "@,subdomain1,subdomain2",`. - you can specify multiple owners/hosts for the same domain using a comma separated list. For example with `"domain": "example.com,sub.example.com,sub2.example.com",`.
### Environment variables ### Environment variables

View File

@@ -3,7 +3,6 @@
{ {
"provider": "namecheap", "provider": "namecheap",
"domain": "example.com", "domain": "example.com",
"owner": "@",
"password": "e5322165c1d74692bfa6d807100c0310" "password": "e5322165c1d74692bfa6d807100c0310"
}, },
{ {
@@ -13,8 +12,7 @@
}, },
{ {
"provider": "godaddy", "provider": "godaddy",
"domain": "example.org", "domain": "subdomain.example.org",
"owner": "subdomain",
"key": "aaaaaaaaaaaaaaaa", "key": "aaaaaaaaaaaaaaaa",
"secret": "aaaaaaaaaaaaaaaa" "secret": "aaaaaaaaaaaaaaaa"
}, },

View File

@@ -10,7 +10,6 @@
{ {
"provider": "aliyun", "provider": "aliyun",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"access_key_id": "your access_key_id", "access_key_id": "your access_key_id",
"access_secret": "your access_secret", "access_secret": "your access_secret",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"access_key_id"` - `"access_key_id"`
- `"access_secret"` - `"access_secret"`

View File

@@ -9,8 +9,7 @@
"settings": [ "settings": [
{ {
"provider": "allinkl", "provider": "allinkl",
"domain": "domain.com", "domain": "sub.domain.com",
"owner": "sub",
"username": "dynXXXXXXX", "username": "dynXXXXXXX",
"password": "password", "password": "password",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` username (usually starts with dyn followed by numbers) - `"username"` username (usually starts with dyn followed by numbers)
- `"password"` password in plain text - `"password"` password in plain text

View File

@@ -9,8 +9,7 @@
"settings": [ "settings": [
{ {
"provider": "changeip", "provider": "changeip",
"domain": "domain.com", "domain": "sub.domain.com",
"owner": "sub",
"username": "dynXXXXXXX", "username": "dynXXXXXXX",
"password": "password", "password": "password",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` - `"username"`
- `"password"` - `"password"`

View File

@@ -11,7 +11,6 @@
"provider": "cloudflare", "provider": "cloudflare",
"zone_identifier": "some id", "zone_identifier": "some id",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"ttl": 600, "ttl": 600,
"token": "yourtoken", "token": "yourtoken",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -24,8 +23,7 @@
### Compulsory parameters ### Compulsory parameters
- `"zone_identifier"` is the Zone ID of your site, from the domain overview page written as *Zone ID* - `"zone_identifier"` is the Zone ID of your site, from the domain overview page written as *Zone ID*
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
See [this issue comment for context](https://github.com/qdm12/ddns-updater/issues/243#issuecomment-928313949). This is left as is for compatibility. See [this issue comment for context](https://github.com/qdm12/ddns-updater/issues/243#issuecomment-928313949). This is left as is for compatibility.
- `"ttl"` integer value for record TTL in seconds (specify 1 for automatic) - `"ttl"` integer value for record TTL in seconds (specify 1 for automatic)
- One of the following ([how to find API keys](https://developers.cloudflare.com/fundamentals/api/get-started/)): - One of the following ([how to find API keys](https://developers.cloudflare.com/fundamentals/api/get-started/)):

View File

@@ -15,7 +15,6 @@ Feel free to open issues to extend its configuration options.
{ {
"provider": "custom", "provider": "custom",
"domain": "example.com", "domain": "example.com",
"owner": "@",
"url": "https://example.com/update?domain=example.com&host=@&username=username&client_key=client_key", "url": "https://example.com/update?domain=example.com&host=@&username=username&client_key=client_key",
"ipv4key": "ipv4", "ipv4key": "ipv4",
"ipv6key": "ipv6", "ipv6key": "ipv6",
@@ -29,8 +28,7 @@ Feel free to open issues to extend its configuration options.
### Compulsory parameters ### Compulsory parameters
- `"domain"` is the domain name to update - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"url"` is the URL to update your records and should contain all the information EXCEPT the IP address to update - `"url"` is the URL to update your records and should contain all the information EXCEPT the IP address to update
- `"ipv4key"` is the URL query parameter name for the IPv4 address, for example `ipv4` will be added to the URL with `&ipv4=1.2.3.4`. - `"ipv4key"` is the URL query parameter name for the IPv4 address, for example `ipv4` will be added to the URL with `&ipv4=1.2.3.4`.
- `"ipv6key"` is the URL query parameter name for the IPv6 address, for example `ipv6` will be added to the URL with `&ipv6=::aaff`. Even if you don't use IPv6, this must be set to something. - `"ipv6key"` is the URL query parameter name for the IPv6 address, for example `ipv6` will be added to the URL with `&ipv6=::aaff`. Even if you don't use IPv6, this must be set to something.

View File

@@ -10,7 +10,6 @@
{ {
"provider": "dd24", "provider": "dd24",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"password": "password", "password": "password",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "" "ipv6_suffix": ""
@@ -21,8 +20,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"password"` is your password - `"password"` is your password
### Optional parameters ### Optional parameters

View File

@@ -11,7 +11,6 @@
"provider": "ddnss", "provider": "ddnss",
"provider_ip": true, "provider_ip": true,
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "user", "username": "user",
"password": "password", "password": "password",
"dual_stack": false, "dual_stack": false,
@@ -24,8 +23,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` - `"username"`
- `"password"` - `"password"`

View File

@@ -9,8 +9,7 @@
"settings": [ "settings": [
{ {
"provider": "desec", "provider": "desec",
"domain": "dedyn.io", "domain": "sub.dedyn.io",
"owner": "sub",
"token": "token", "token": "token",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "", "ipv6_suffix": "",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"token"` is your token that you can create [here](https://desec.io/tokens) - `"token"` is your token that you can create [here](https://desec.io/tokens)
### Optional parameters ### Optional parameters

View File

@@ -10,7 +10,6 @@
{ {
"provider": "digitalocean", "provider": "digitalocean",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"token": "yourtoken", "token": "yourtoken",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "" "ipv6_suffix": ""
@@ -21,8 +20,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"token"` is your token that you can create [here](https://cloud.digitalocean.com/settings/applications) - `"token"` is your token that you can create [here](https://cloud.digitalocean.com/settings/applications)
### Optional parameters ### Optional parameters

View File

@@ -10,7 +10,6 @@
{ {
"provider": "dnsomatic", "provider": "dnsomatic",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"password": "password", "password": "password",
"provider_ip": true, "provider_ip": true,
@@ -23,8 +22,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` - `"username"`
- `"password"` - `"password"`
- `"provider_ip"` - `"provider_ip"`

View File

@@ -10,7 +10,6 @@
{ {
"provider": "dnspod", "provider": "dnspod",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"token": "yourtoken", "token": "yourtoken",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "" "ipv6_suffix": ""
@@ -21,8 +20,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"token"` - `"token"`
### Optional parameters ### Optional parameters

View File

@@ -10,7 +10,6 @@
{ {
"provider": "dondominio", "provider": "dondominio",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"name": "something", "name": "something",
"username": "username", "username": "username",
"key": "key", "key": "key",
@@ -23,8 +22,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"name"` is the name of the service/hosting - `"name"` is the name of the service/hosting
- `"username"` - `"username"`
- `"password"` - `"password"`

View File

@@ -10,7 +10,6 @@
{ {
"provider": "dreamhost", "provider": "dreamhost",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"key": "key", "key": "key",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "" "ipv6_suffix": ""
@@ -26,7 +25,7 @@
### Optional parameters ### Optional parameters
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"ip_version"` can be `ipv4` (A records), or `ipv6` (AAAA records) or `ipv4 or ipv6` (update one of the two, depending on the public ip found). It defaults to `ipv4 or ipv6`. - `"ip_version"` can be `ipv4` (A records), or `ipv6` (AAAA records) or `ipv4 or ipv6` (update one of the two, depending on the public ip found). It defaults to `ipv4 or ipv6`.
- `"ipv6_suffix"` is the IPv6 interface identifier suffix to use. It can be for example `0:0:0:0:72ad:8fbb:a54e:bedd/64`. If left empty, it defaults to no suffix and the raw public IPv6 address obtained is used in the record updating. - `"ipv6_suffix"` is the IPv6 interface identifier suffix to use. It can be for example `0:0:0:0:72ad:8fbb:a54e:bedd/64`. If left empty, it defaults to no suffix and the raw public IPv6 address obtained is used in the record updating.

View File

@@ -9,7 +9,7 @@
"settings": [ "settings": [
{ {
"provider": "duckdns", "provider": "duckdns",
"owner": "sub", "domain": "sub.duckdns.org",
"token": "token", "token": "token",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "", "ipv6_suffix": "",
@@ -21,7 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"owner"` is the resource record owner and can be for example `"sub"` for the domain `sub.duckdns.org` - `"domain"` is the domain to update. For example, for the owner/host `sub`, it would be `sub.duckdns.org`. The [eTLD+1](https://developer.mozilla.org/en-US/docs/Glossary/eTLD) must be `duckdns.org`.
- `"token"` - `"token"`
### Optional parameters ### Optional parameters

View File

@@ -10,7 +10,6 @@
{ {
"provider": "dyn", "provider": "dyn",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"client_key": "client_key", "client_key": "client_key",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` - `"username"`
- `"client_key"` - `"client_key"`

View File

@@ -10,7 +10,6 @@
{ {
"provider": "dynu", "provider": "dynu",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"group": "group", "group": "group",
"username": "username", "username": "username",
"password": "password", "password": "password",
@@ -24,8 +23,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` - `"username"`
- `"password"` could be plain text or password in MD5 or SHA256 format (There's also an option for setting a password for IP Update only) - `"password"` could be plain text or password in MD5 or SHA256 format (There's also an option for setting a password for IP Update only)

View File

@@ -10,7 +10,6 @@
{ {
"provider": "dynv6", "provider": "dynv6",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"token": "token", "token": "token",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "", "ipv6_suffix": "",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"token"` that you can obtain [here](https://dynv6.com/keys#token) - `"token"` that you can obtain [here](https://dynv6.com/keys#token)
### Optional parameters ### Optional parameters

View File

@@ -10,7 +10,6 @@
{ {
"provider": "easydns", "provider": "easydns",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"token": "token", "token": "token",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -23,8 +22,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` - `"username"`
- `"token"` - `"token"`

View File

@@ -12,7 +12,6 @@
{ {
"provider": "example", "provider": "example",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"password": "password", "password": "password",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -24,8 +23,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` - `"username"`
- `"password"` - `"password"`

View File

@@ -9,8 +9,7 @@
"settings": [ "settings": [
{ {
"provider": "freedns", "provider": "freedns",
"domain": "domain.com", "domain": "sub.domain.com",
"owner": "sub",
"token": "token", "token": "token",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "" "ipv6_suffix": ""
@@ -21,8 +20,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"token"` is the randomized update token you use to update your record - `"token"` is the randomized update token you use to update your record
### Optional parameters ### Optional parameters

View File

@@ -12,7 +12,6 @@ This provider uses Gandi v5 API
{ {
"provider": "gandi", "provider": "gandi",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"personal_access_token": "token", "personal_access_token": "token",
"ttl": 3600, "ttl": 3600,
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -24,8 +23,7 @@ This provider uses Gandi v5 API
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"personal_access_token"` - `"personal_access_token"`
### Optional parameters ### Optional parameters

View File

@@ -17,7 +17,6 @@
// ... // ...
}, },
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "" "ipv6_suffix": ""
} }
@@ -30,8 +29,7 @@
- `"project"` is the id of your Google Cloud project - `"project"` is the id of your Google Cloud project
- `"zone"` is the zone, that your DNS record is located in - `"zone"` is the zone, that your DNS record is located in
- `"credentials"` is the JSON credentials for your Google Cloud project. This is usually downloaded as a JSON file, which you can copy paste the content as the value of the `"credentials"` key. More information on how to get it is available [here](https://cloud.google.com/docs/authentication/getting-started). Please ensure your service account has all necessary permissions to create/update/list/get DNS records within your project. - `"credentials"` is the JSON credentials for your Google Cloud project. This is usually downloaded as a JSON file, which you can copy paste the content as the value of the `"credentials"` key. More information on how to get it is available [here](https://cloud.google.com/docs/authentication/getting-started). Please ensure your service account has all necessary permissions to create/update/list/get DNS records within your project.
- `"domain"` is the TLD of you DNS record (without a trailing dot) - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
### Optional parameters ### Optional parameters

View File

@@ -10,7 +10,6 @@
{ {
"provider": "godaddy", "provider": "godaddy",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"key": "key", "key": "key",
"secret": "secret", "secret": "secret",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"key"` - `"key"`
- `"secret"` - `"secret"`

View File

@@ -9,8 +9,7 @@
"settings": [ "settings": [
{ {
"provider": "goip", "provider": "goip",
"domain": "goip.de", "domain": "mysubdomain.goip.de",
"owner": "mysubdomain",
"username": "username", "username": "username",
"password": "password", "password": "password",
"provider_ip": true, "provider_ip": true,
@@ -24,7 +23,7 @@
### Compulsory parameters ### Compulsory parameters
- `"owner"` is the resource record owner and can be for example `"example"` for `example.goip.de`. - `"domain"` is the domain to update. For example, for the owner/host `sub`, it would be `sub.goip.de`. The [eTLD+1](https://developer.mozilla.org/en-US/docs/Glossary/eTLD) must be `goip.de` or `goip.it`.
- `"username"` is your goip.de username listed under "Routers" - `"username"` is your goip.de username listed under "Routers"
- `"password"` is your router account password - `"password"` is your router account password

View File

@@ -10,7 +10,6 @@
{ {
"provider": "he", "provider": "he",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"password": "password", "password": "password",
"provider_ip": true, "provider_ip": true,
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard. (untested)
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com` (untested)
- `"password"` - `"password"`
### Optional parameters ### Optional parameters

View File

@@ -11,7 +11,6 @@
"provider": "hetzner", "provider": "hetzner",
"zone_identifier": "some id", "zone_identifier": "some id",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"ttl": 600, "ttl": 600,
"token": "yourtoken", "token": "yourtoken",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -24,8 +23,7 @@
### Compulsory parameters ### Compulsory parameters
- `"zone_identifier"` is the Zone ID of your site, from the domain overview page written as *Zone ID* - `"zone_identifier"` is the Zone ID of your site, from the domain overview page written as *Zone ID*
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"ttl"` optional integer value corresponding to a number of seconds - `"ttl"` optional integer value corresponding to a number of seconds
- One of the following ([how to find API keys](https://docs.hetzner.com/cloud/api/getting-started/generating-api-token)): - One of the following ([how to find API keys](https://docs.hetzner.com/cloud/api/getting-started/generating-api-token)):
- API Token `"token"`, configured with DNS edit permissions for your DNS name's zone - API Token `"token"`, configured with DNS edit permissions for your DNS name's zone

View File

@@ -10,7 +10,6 @@
{ {
"provider": "infomaniak", "provider": "infomaniak",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"password": "password", "password": "password",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -23,8 +22,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` for dyndns (**not** your infomaniak admin username!) - `"username"` for dyndns (**not** your infomaniak admin username!)
- `"password"` for dyndns (**not** your infomaniak admin password!) - `"password"` for dyndns (**not** your infomaniak admin password!)

View File

@@ -10,7 +10,6 @@
{ {
"provider": "inwx", "provider": "inwx",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"password": "password", "password": "password",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` - `"username"`
- `"password"` - `"password"`

View File

@@ -10,7 +10,6 @@
{ {
"provider": "ionos", "provider": "ionos",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"api_key": "api_key", "api_key": "api_key",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "" "ipv6_suffix": ""
@@ -21,8 +20,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"api_key"` is your API key, obtained from [creating an API key](https://www.ionos.com/help/domains/configuring-your-ip-address/set-up-dynamic-dns-with-company-name/#c181598) - `"api_key"` is your API key, obtained from [creating an API key](https://www.ionos.com/help/domains/configuring-your-ip-address/set-up-dynamic-dns-with-company-name/#c181598)
### Optional parameters ### Optional parameters

View File

@@ -10,7 +10,6 @@
{ {
"provider": "linode", "provider": "linode",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"token": "token", "token": "token",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "" "ipv6_suffix": ""
@@ -21,8 +20,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"token"` - `"token"`
### Optional parameters ### Optional parameters

View File

@@ -10,7 +10,6 @@
{ {
"provider": "luadns", "provider": "luadns",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"email": "email", "email": "email",
"token": "token", "token": "token",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"email"` - `"email"`
- `"token"` - `"token"`

View File

@@ -12,7 +12,6 @@
{ {
"provider": "name.com", "provider": "name.com",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"token": "token", "token": "token",
"ttl": 300, "ttl": 300,
@@ -25,8 +24,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` is your account username - `"username"` is your account username
- `"token"` which you can obtain from [www.name.com/account/settings/api](https://www.name.com/account/settings/api) - `"token"` which you can obtain from [www.name.com/account/settings/api](https://www.name.com/account/settings/api)

View File

@@ -10,7 +10,6 @@
{ {
"provider": "namecheap", "provider": "namecheap",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"password": "password", "password": "password",
"provider_ip": true "provider_ip": true
} }
@@ -20,8 +19,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"password"` - `"password"`
### Optional parameters ### Optional parameters

View File

@@ -14,7 +14,6 @@ Also keep in mind, that TTL, Expire, Retry and Refresh values of the given Domai
{ {
"provider": "netcup", "provider": "netcup",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"api_key": "xxxxx", "api_key": "xxxxx",
"password": "yyyyy", "password": "yyyyy",
"customer_number": "111111", "customer_number": "111111",
@@ -27,8 +26,7 @@ Also keep in mind, that TTL, Expire, Retry and Refresh values of the given Domai
### Compulsory parameters ### Compulsory parameters
- `"domain"` is your domain - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com` or `"@"` for the root of the domain. It cannot be the wildcard.
- `"api_key"` is your api key (generated in the [customercontrolpanel](https://www.customercontrolpanel.de)) - `"api_key"` is your api key (generated in the [customercontrolpanel](https://www.customercontrolpanel.de))
- `"password"` is your api password (generated in the [customercontrolpanel](https://www.customercontrolpanel.de)). Netcup only allows one ApiPassword. This is not the account password. This password is used for all api keys. - `"password"` is your api password (generated in the [customercontrolpanel](https://www.customercontrolpanel.de)). Netcup only allows one ApiPassword. This is not the account password. This password is used for all api keys.
- `"customer_number"` is your customer number (viewable in the [customercontrolpanel](https://www.customercontrolpanel.de) next to your name). As seen in the example above, provide the number as string value. - `"customer_number"` is your customer number (viewable in the [customercontrolpanel](https://www.customercontrolpanel.de) next to your name). As seen in the example above, provide the number as string value.

View File

@@ -10,7 +10,6 @@
{ {
"provider": "njalla", "provider": "njalla",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"key": "key", "key": "key",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "", "ipv6_suffix": "",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"key"` is the key for your record - `"key"` is the key for your record
### Optional parameters ### Optional parameters

View File

@@ -10,7 +10,6 @@
{ {
"provider": "noip", "provider": "noip",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"password": "password", "password": "password",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -23,8 +22,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` - `"username"`
- `"password"` - `"password"`

View File

@@ -10,7 +10,6 @@
{ {
"provider": "opendns", "provider": "opendns",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"password": "password", "password": "password",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -23,8 +22,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` - `"username"`
- `"password"` - `"password"`

View File

@@ -10,7 +10,6 @@
{ {
"provider": "ovh", "provider": "ovh",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"password": "password", "password": "password",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -23,8 +22,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
#### Using DynHost #### Using DynHost

View File

@@ -10,7 +10,6 @@
{ {
"provider": "porkbun", "provider": "porkbun",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"api_key": "sk1_7d119e3f656b00ae042980302e1425a04163c476efec1833q3cb0w54fc6f5022", "api_key": "sk1_7d119e3f656b00ae042980302e1425a04163c476efec1833q3cb0w54fc6f5022",
"secret_api_key": "pk1_5299b57125c8f3cdf347d2fe0e713311ee3a1e11f11a14942b26472593e35368", "secret_api_key": "pk1_5299b57125c8f3cdf347d2fe0e713311ee3a1e11f11a14942b26472593e35368",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -22,8 +21,7 @@
### Compulsory Parameters ### Compulsory Parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"apikey"` - `"apikey"`
- `"secretapikey"` - `"secretapikey"`
- `"ttl"` optional integer value corresponding to a number of seconds - `"ttl"` optional integer value corresponding to a number of seconds

View File

@@ -10,7 +10,6 @@
{ {
"provider": "route53", "provider": "route53",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "", "ipv6_suffix": "",
"access_key": "ffffffffffffffffffff", "access_key": "ffffffffffffffffffff",
@@ -24,8 +23,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"access_key"` is the `AWS_ACCESS_KEY` - `"access_key"` is the `AWS_ACCESS_KEY`
- `"secret_key"` is the `AWS_SECRET_ACCESS_KEY` - `"secret_key"` is the `AWS_SECRET_ACCESS_KEY`
- `"zone_id"` is identification of your hosted zone - `"zone_id"` is identification of your hosted zone

View File

@@ -10,7 +10,6 @@
{ {
"provider": "selfhost.de", "provider": "selfhost.de",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"password": "password", "password": "password",
"provider_ip": true, "provider_ip": true,
@@ -23,8 +22,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` is your DynDNS username - `"username"` is your DynDNS username
- `"password"` is your DynDNS password - `"password"` is your DynDNS password

View File

@@ -10,7 +10,6 @@
{ {
"provider": "servercow", "provider": "servercow",
"domain": "domain.com", "domain": "domain.com",
"owner": "",
"username": "servercow_username", "username": "servercow_username",
"password": "servercow_password", "password": "servercow_password",
"ttl": 600, "ttl": 600,
@@ -24,8 +23,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` is the username for your DNS API User - `"username"` is the username for your DNS API User
- `"password"` is the password for your DNS API User - `"password"` is the password for your DNS API User

View File

@@ -10,7 +10,6 @@
{ {
"provider": "spdyn", "provider": "spdyn",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"user": "user", "user": "user",
"password": "password", "password": "password",
"token": "token", "token": "token",
@@ -24,8 +23,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
#### Using user and password #### Using user and password

View File

@@ -10,7 +10,6 @@
{ {
"provider": "strato", "provider": "strato",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"password": "password", "password": "password",
"ip_version": "ipv4", "ip_version": "ipv4",
"ipv6_suffix": "", "ipv6_suffix": "",
@@ -22,8 +21,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"password"` is your dyndns password - `"password"` is your dyndns password
### Optional parameters ### Optional parameters

View File

@@ -10,7 +10,6 @@
{ {
"provider": "variomedia", "provider": "variomedia",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"email": "email@domain.com", "email": "email@domain.com",
"password": "password", "password": "password",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -23,8 +22,7 @@
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain) or `sub.example.com` (subdomain of `example.com`).
- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com`
- `"email"` - `"email"`
- `"password"` is your DNS settings password, not your account password ⚠️ - `"password"` is your DNS settings password, not your account password ⚠️

View File

@@ -16,7 +16,6 @@ set the environment variable as `PERIOD=11m` to check your public IP address and
{ {
"provider": "zoneedit", "provider": "zoneedit",
"domain": "domain.com", "domain": "domain.com",
"owner": "@",
"username": "username", "username": "username",
"token": "token", "token": "token",
"ip_version": "ipv4", "ip_version": "ipv4",
@@ -29,8 +28,7 @@ set the environment variable as `PERIOD=11m` to check your public IP address and
### Compulsory parameters ### Compulsory parameters
- `"domain"` - `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"owner"` is the resource record owner and can be `"@"` for the root domain, `"*"` for the wildcard, or for example `"sub"` for the subdomain `sub.domain.com`
- `"username"` - `"username"`
- `"token"` - `"token"`

2
go.mod
View File

@@ -15,6 +15,7 @@ require (
github.com/qdm12/log v0.1.0 github.com/qdm12/log v0.1.0
github.com/stretchr/testify v1.9.0 github.com/stretchr/testify v1.9.0
golang.org/x/mod v0.18.0 golang.org/x/mod v0.18.0
golang.org/x/net v0.26.0
golang.org/x/oauth2 v0.21.0 golang.org/x/oauth2 v0.21.0
) )
@@ -28,7 +29,6 @@ require (
github.com/mattn/go-isatty v0.0.17 // indirect github.com/mattn/go-isatty v0.0.17 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.7.0 // indirect golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect golang.org/x/sys v0.21.0 // indirect
golang.org/x/tools v0.22.0 // indirect golang.org/x/tools v0.22.0 // indirect

View File

@@ -12,16 +12,19 @@ import (
"github.com/qdm12/ddns-updater/internal/models" "github.com/qdm12/ddns-updater/internal/models"
"github.com/qdm12/ddns-updater/internal/provider" "github.com/qdm12/ddns-updater/internal/provider"
"github.com/qdm12/ddns-updater/internal/provider/constants" "github.com/qdm12/ddns-updater/internal/provider/utils"
"github.com/qdm12/ddns-updater/pkg/publicip/ipversion" "github.com/qdm12/ddns-updater/pkg/publicip/ipversion"
"golang.org/x/net/publicsuffix"
) )
type commonSettings struct { type commonSettings struct {
Provider string `json:"provider"` Provider string `json:"provider"`
Domain string `json:"domain"` Domain string `json:"domain"`
// Host is kept for retro-compatibility and is replaced by Owner. // Host is kept for retro-compatibility and is replaced by Owner.
Host string `json:"host,omitempty"` Host string `json:"host,omitempty"`
Owner string `json:"owner"` // Owner is kept for retro-compatibility and is determined from the
// Domain field.
Owner string `json:"owner,omitempty"`
IPVersion string `json:"ip_version"` IPVersion string `json:"ip_version"`
IPv6Suffix netip.Prefix `json:"ipv6_suffix,omitempty"` IPv6Suffix netip.Prefix `json:"ipv6_suffix,omitempty"`
// Retro values for warnings // Retro values for warnings
@@ -155,25 +158,25 @@ func makeSettingsFromObject(common commonSettings, rawSettings json.RawMessage,
common.Owner = common.Host common.Owner = common.Host
} }
providerName := models.Provider(common.Provider) var domain string
if providerName == constants.DuckDNS { // only owner(s), no domain var owners []string
if common.Domain != "" { // retro compatibility if common.Owner != "" { // retro compatibility
if common.Owner == "" { owners = strings.Split(common.Owner, ",")
common.Owner = strings.TrimSuffix(common.Domain, ".duckdns.org") domain = common.Domain // single domain only
warnings = append(warnings, domains := make([]string, len(owners))
fmt.Sprintf("DuckDNS record should have %q specified as owner instead of %q as domain", for i, owner := range owners {
common.Owner, common.Domain)) domains[i] = utils.BuildURLQueryHostname(owner, common.Domain)
} else { }
warnings = append(warnings, warnings = append(warnings,
fmt.Sprintf("ignoring domain %q because owner %q is specified for DuckDNS record", fmt.Sprintf("you can specify the owner %q directly in the domain field as %q",
common.Domain, common.Owner)) common.Owner, strings.Join(domains, ",")))
} } else { // extract owner(s) from domain(s)
common.Domain = "" // duckdns enforces empty domains domain, owners, err = extractFromDomainField(common.Domain)
if err != nil {
return nil, nil, fmt.Errorf("extracting owners from domains: %w", err)
} }
} }
owners := strings.Split(common.Owner, ",")
if common.IPVersion == "" { if common.IPVersion == "" {
common.IPVersion = ipversion.IP4or6.String() common.IPVersion = ipversion.IP4or6.String()
} }
@@ -193,10 +196,11 @@ func makeSettingsFromObject(common commonSettings, rawSettings json.RawMessage,
ipv6Suffix, ipVersion)) ipv6Suffix, ipVersion))
} }
providerName := models.Provider(common.Provider)
providers = make([]provider.Provider, len(owners)) providers = make([]provider.Provider, len(owners))
for i, owner := range owners { for i, owner := range owners {
owner = strings.TrimSpace(owner) owner = strings.TrimSpace(owner)
providers[i], err = provider.New(providerName, rawSettings, common.Domain, providers[i], err = provider.New(providerName, rawSettings, domain,
owner, ipVersion, ipv6Suffix) owner, ipVersion, ipv6Suffix)
if err != nil { if err != nil {
return nil, warnings, err return nil, warnings, err
@@ -204,3 +208,31 @@ func makeSettingsFromObject(common commonSettings, rawSettings json.RawMessage,
} }
return providers, warnings, nil return providers, warnings, nil
} }
var (
ErrMultipleDomainsSpecified = errors.New("multiple domains specified")
)
func extractFromDomainField(domainField string) (domainRegistered string,
owners []string, err error) {
domains := strings.Split(domainField, ",")
owners = make([]string, len(domains))
for i, domain := range domains {
newDomainRegistered, err := publicsuffix.EffectiveTLDPlusOne(domain)
switch {
case err != nil:
return "", nil, fmt.Errorf("extracting effective TLD+1: %w", err)
case domainRegistered == "":
domainRegistered = newDomainRegistered
case domainRegistered != newDomainRegistered:
return "", nil, fmt.Errorf("%w: %q and %q",
ErrMultipleDomainsSpecified, domainRegistered, newDomainRegistered)
}
if domain == domainRegistered {
owners[i] = "@"
continue
}
owners[i] = strings.TrimSuffix(domain, "."+domainRegistered)
}
return domainRegistered, owners, nil
}

View File

@@ -0,0 +1,66 @@
package params
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_extractFromDomainField(t *testing.T) {
t.Parallel()
testCases := map[string]struct {
domainField string
domainRegistered string
owners []string
errWrapped error
errMessage string
}{
"root_domain": {
domainField: "example.com",
domainRegistered: "example.com",
owners: []string{"@"},
},
"subdomain": {
domainField: "abc.example.com",
domainRegistered: "example.com",
owners: []string{"abc"},
},
"two_dots_tld": {
domainField: "abc.example.co.uk",
domainRegistered: "example.co.uk",
owners: []string{"abc"},
},
"wildcard": {
domainField: "*.example.com",
domainRegistered: "example.com",
owners: []string{"*"},
},
"multiple": {
domainField: "*.example.com,example.com",
domainRegistered: "example.com",
owners: []string{"*", "@"},
},
"different_domains": {
domainField: "*.example.com,abc.something.com",
errWrapped: ErrMultipleDomainsSpecified,
errMessage: "multiple domains specified: \"example.com\" and \"something.com\"",
},
}
for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()
domainRegistered, owners, err := extractFromDomainField(testCase.domainField)
assert.ErrorIs(t, err, testCase.errWrapped)
if testCase.errWrapped != nil {
assert.EqualError(t, err, testCase.errMessage)
}
assert.Equal(t, testCase.domainRegistered, domainRegistered)
assert.Equal(t, testCase.owners, owners)
})
}
}