From 32fafeca95473b608931522cce643158bc4ad6b8 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Thu, 27 Jun 2024 06:51:08 +0000 Subject: [PATCH] chore(all): rename `host` to `owner` - Retro-compatible change, `host` field still works - Documentation updated to use `owner` field - Code updated to use owner variable name --- .github/CONTRIBUTING.md | 2 +- README.md | 6 +- cmd/updater/main.go | 4 +- config.json | 4 +- docs/aliyun.md | 4 +- docs/allinkl.md | 4 +- docs/changeip.md | 4 +- docs/cloudflare.md | 4 +- docs/custom.md | 4 +- docs/dd24.md | 4 +- docs/ddnss.de.md | 4 +- docs/desec.md | 4 +- docs/digitalocean.md | 4 +- docs/dnsomatic.md | 4 +- docs/dnspod.md | 4 +- docs/dondominio.md | 4 +- docs/dreamhost.md | 4 +- docs/duckdns.md | 4 +- docs/dyndns.md | 4 +- docs/dynu.md | 4 +- docs/dynv6.md | 4 +- docs/easydns.md | 4 +- docs/example.md | 4 +- docs/freedns.md | 4 +- docs/gandi.md | 4 +- docs/gcp.md | 4 +- docs/godaddy.md | 4 +- docs/goip.md | 4 +- docs/he.net.md | 4 +- docs/hetzner.md | 4 +- docs/infomaniak.md | 4 +- docs/inwx.md | 4 +- docs/ionos.md | 4 +- docs/linode.md | 4 +- docs/luadns.md | 4 +- docs/name.com.md | 4 +- docs/namecheap.md | 4 +- docs/netcup.md | 4 +- docs/njalla.md | 4 +- docs/noip.md | 4 +- docs/opendns.md | 4 +- docs/ovh.md | 4 +- docs/porkbun.md | 4 +- docs/route53.md | 4 +- docs/selfhost.de.md | 4 +- docs/servercow.md | 4 +- docs/spdyn.md | 4 +- docs/strato.md | 4 +- docs/variomedia.md | 4 +- docs/zoneedit.md | 4 +- internal/data/interfaces.go | 2 +- internal/data/persistence.go | 2 +- internal/models/html.go | 2 +- internal/params/json.go | 37 ++++--- internal/persistence/json/database.go | 18 +++- internal/persistence/json/models.go | 6 +- internal/persistence/json/queries.go | 14 +-- internal/provider/errors/validation.go | 6 +- internal/provider/provider.go | 96 +++++++++---------- internal/provider/providers/aliyun/create.go | 2 +- .../provider/providers/aliyun/getrecord.go | 2 +- .../provider/providers/aliyun/provider.go | 16 ++-- internal/provider/providers/aliyun/update.go | 2 +- .../provider/providers/allinkl/provider.go | 22 ++--- .../provider/providers/changeip/provider.go | 26 ++--- .../provider/providers/cloudflare/provider.go | 22 ++--- .../provider/providers/custom/provider.go | 16 ++-- internal/provider/providers/dd24/provider.go | 16 ++-- internal/provider/providers/ddnss/provider.go | 22 ++--- internal/provider/providers/desec/provider.go | 22 ++--- .../providers/digitalocean/provider.go | 20 ++-- .../provider/providers/dnsomatic/provider.go | 24 ++--- .../provider/providers/dnspod/provider.go | 22 ++--- .../provider/providers/dondominio/provider.go | 20 ++-- .../provider/providers/dreamhost/provider.go | 26 ++--- .../provider/providers/duckdns/provider.go | 22 ++--- internal/provider/providers/dyn/provider.go | 18 ++-- internal/provider/providers/dynu/provider.go | 26 ++--- internal/provider/providers/dynv6/provider.go | 22 ++--- .../provider/providers/easydns/provider.go | 20 ++-- .../provider/providers/example/provider.go | 32 +++---- .../provider/providers/freedns/provider.go | 16 ++-- internal/provider/providers/gandi/provider.go | 18 ++-- internal/provider/providers/gcp/provider.go | 16 ++-- internal/provider/providers/gcp/update.go | 2 +- .../provider/providers/godaddy/provider.go | 18 ++-- internal/provider/providers/goip/provider.go | 20 ++-- internal/provider/providers/he/provider.go | 16 ++-- internal/provider/providers/hetzner/create.go | 2 +- .../provider/providers/hetzner/getrecord.go | 2 +- .../provider/providers/hetzner/provider.go | 16 ++-- internal/provider/providers/hetzner/update.go | 2 +- .../provider/providers/infomaniak/provider.go | 22 ++--- internal/provider/providers/inwx/provider.go | 18 ++-- internal/provider/providers/ionos/create.go | 2 +- internal/provider/providers/ionos/provider.go | 18 ++-- .../provider/providers/linode/provider.go | 18 ++-- .../provider/providers/luadns/provider.go | 18 ++-- .../provider/providers/namecheap/provider.go | 18 ++-- .../providers/namecom/createrecord.go | 2 +- .../provider/providers/namecom/getrecord.go | 2 +- .../provider/providers/namecom/provider.go | 16 ++-- .../providers/namecom/updaterecord.go | 4 +- .../provider/providers/netcup/provider.go | 22 ++--- internal/provider/providers/netcup/update.go | 4 +- .../provider/providers/njalla/provider.go | 18 ++-- internal/provider/providers/noip/provider.go | 22 ++--- .../provider/providers/nowdns/provider.go | 4 +- .../provider/providers/opendns/provider.go | 22 ++--- internal/provider/providers/ovh/provider.go | 24 ++--- internal/provider/providers/porkbun/api.go | 12 +-- .../provider/providers/porkbun/provider.go | 16 ++-- .../provider/providers/route53/provider.go | 24 ++--- .../provider/providers/selfhostde/provider.go | 22 ++--- .../provider/providers/servercow/provider.go | 34 ++++--- internal/provider/providers/spdyn/provider.go | 22 ++--- .../provider/providers/strato/provider.go | 22 ++--- .../provider/providers/variomedia/provider.go | 22 ++--- .../provider/providers/zoneedit/provider.go | 20 ++-- internal/provider/utils/domain.go | 14 +-- internal/provider/utils/provider.go | 4 +- internal/server/ui/index.html | 4 +- k8s/base/secret-config.yaml | 2 +- 123 files changed, 713 insertions(+), 690 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 7c3f4d82d..bf28b504d 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -77,7 +77,7 @@ In more detailed steps: ```go case constants.Example: - return example.New(data, domain, host, ipVersion, ipv6Suffix) + return example.New(data, domain, owner, ipVersion, ipv6Suffix) ``` 1. Copy the file [`docs/example.md`](../docs/example.md) to `docs/yourprovider.md` and modify it to fit the configuration and domain setup of your DNS provider. There are a few `` comments indicating what to change, please **remove them** when done. diff --git a/README.md b/README.md index 43cb3e6e5..2237fc559 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ Program to keep DNS A and/or AAAA records updated for multiple DNS providers { "provider": "namecheap", "domain": "example.com", - "host": "@", + "owner": "@", "password": "e5322165c1d74692bfa6d807100c0310" } ] @@ -155,7 +155,7 @@ Program to keep DNS A and/or AAAA records updated for multiple DNS providers { "provider": "namecheap", "domain": "example.com", - "host": "@", + "owner": "@", "password": "e5322165c1d74692bfa6d807100c0310" } ] @@ -245,7 +245,7 @@ Check the documentation for your DNS provider: Note that: -- you can specify multiple hosts for the same domain using a comma separated list. For example with `"host": "@,subdomain1,subdomain2",`. +- you can specify multiple hosts for the same domain using a comma separated list. For example with `"owner": "@,subdomain1,subdomain2",`. ### Environment variables diff --git a/cmd/updater/main.go b/cmd/updater/main.go index c6c48f8f0..c1deec3ec 100644 --- a/cmd/updater/main.go +++ b/cmd/updater/main.go @@ -319,10 +319,10 @@ func readRecords(providers []provider.Provider, persistentDB *persistence.Databa records = make([]recordslib.Record, len(providers)) for i, provider := range providers { logger.Info("Reading history from database: domain " + - provider.Domain() + " host " + provider.Host() + + provider.Domain() + " owner " + provider.Owner() + " " + provider.IPVersion().String()) events, err := persistentDB.GetEvents(provider.Domain(), - provider.Host(), provider.IPVersion()) + provider.Owner(), provider.IPVersion()) if err != nil { shoutrrrClient.Notify(err.Error()) return nil, err diff --git a/config.json b/config.json index b07412e5b..b4de97d65 100644 --- a/config.json +++ b/config.json @@ -3,7 +3,7 @@ { "provider": "namecheap", "domain": "example.com", - "host": "@", + "owner": "@", "password": "e5322165c1d74692bfa6d807100c0310" }, { @@ -14,7 +14,7 @@ { "provider": "godaddy", "domain": "example.org", - "host": "subdomain", + "owner": "subdomain", "key": "aaaaaaaaaaaaaaaa", "secret": "aaaaaaaaaaaaaaaa" }, diff --git a/docs/aliyun.md b/docs/aliyun.md index 292060773..10a05a85e 100644 --- a/docs/aliyun.md +++ b/docs/aliyun.md @@ -10,7 +10,7 @@ { "provider": "aliyun", "domain": "domain.com", - "host": "@", + "owner": "@", "access_key_id": "your access_key_id", "access_secret": "your access_secret", "ip_version": "ipv4", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"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_secret"` diff --git a/docs/allinkl.md b/docs/allinkl.md index de90bb2ca..1ae896716 100644 --- a/docs/allinkl.md +++ b/docs/allinkl.md @@ -10,7 +10,7 @@ { "provider": "allinkl", "domain": "domain.com", - "host": "host", + "owner": "sub", "username": "dynXXXXXXX", "password": "password", "ip_version": "ipv4", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host (subdomain) +- `"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) - `"password"` password in plain text diff --git a/docs/changeip.md b/docs/changeip.md index f8584ae33..cee17b2ca 100644 --- a/docs/changeip.md +++ b/docs/changeip.md @@ -10,7 +10,7 @@ { "provider": "changeip", "domain": "domain.com", - "host": "host", + "owner": "sub", "username": "dynXXXXXXX", "password": "password", "ip_version": "ipv4", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host (subdomain) +- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com` - `"username"` - `"password"` diff --git a/docs/cloudflare.md b/docs/cloudflare.md index f9e61be05..fc5429cb8 100644 --- a/docs/cloudflare.md +++ b/docs/cloudflare.md @@ -11,7 +11,7 @@ "provider": "cloudflare", "zone_identifier": "some id", "domain": "domain.com", - "host": "@", + "owner": "@", "ttl": 600, "token": "yourtoken", "ip_version": "ipv4", @@ -25,7 +25,7 @@ - `"zone_identifier"` is the Zone ID of your site, from the domain overview page written as *Zone ID* - `"domain"` -- `"host"` is your host and can be `"@"`, a subdomain or 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. - `"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/)): diff --git a/docs/custom.md b/docs/custom.md index 2a66924ff..2ed1b65fb 100644 --- a/docs/custom.md +++ b/docs/custom.md @@ -15,7 +15,7 @@ Feel free to open issues to extend its configuration options. { "provider": "custom", "domain": "example.com", - "host": "@", + "owner": "@", "url": "https://example.com/update?domain=example.com&host=@&username=username&client_key=client_key", "ipv4key": "ipv4", "ipv6key": "ipv6", @@ -30,7 +30,7 @@ Feel free to open issues to extend its configuration options. ### Compulsory parameters - `"domain"` is the domain name to update -- `"host"` is the host to update, which can be `"@"` (root), `"*"` or a subdomain +- `"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 - `"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. diff --git a/docs/dd24.md b/docs/dd24.md index 18a9b1057..b4489bfa7 100644 --- a/docs/dd24.md +++ b/docs/dd24.md @@ -10,7 +10,7 @@ { "provider": "dd24", "domain": "domain.com", - "host": "@", + "owner": "@", "password": "password", "ip_version": "ipv4", "ipv6_suffix": "" @@ -22,7 +22,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"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 ### Optional parameters diff --git a/docs/ddnss.de.md b/docs/ddnss.de.md index 1467a30af..f535b500b 100644 --- a/docs/ddnss.de.md +++ b/docs/ddnss.de.md @@ -11,7 +11,7 @@ "provider": "ddnss", "provider_ip": true, "domain": "domain.com", - "host": "@", + "owner": "@", "username": "user", "password": "password", "dual_stack": false, @@ -25,7 +25,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com` - `"username"` - `"password"` diff --git a/docs/desec.md b/docs/desec.md index 4915c9407..6a01e75ba 100644 --- a/docs/desec.md +++ b/docs/desec.md @@ -10,7 +10,7 @@ { "provider": "desec", "domain": "dedyn.io", - "host": "host", + "owner": "sub", "token": "token", "ip_version": "ipv4", "ipv6_suffix": "", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` can be `@` for the root domain or a subdomain or a wildcard subdomain (`*`), defaults to `@` +- `"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) ### Optional parameters diff --git a/docs/digitalocean.md b/docs/digitalocean.md index 7f9c109cc..a995c492a 100644 --- a/docs/digitalocean.md +++ b/docs/digitalocean.md @@ -10,7 +10,7 @@ { "provider": "digitalocean", "domain": "domain.com", - "host": "@", + "owner": "@", "token": "yourtoken", "ip_version": "ipv4", "ipv6_suffix": "" @@ -22,7 +22,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or `"*"` +- `"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) ### Optional parameters diff --git a/docs/dnsomatic.md b/docs/dnsomatic.md index c65cce3c3..671f9a249 100644 --- a/docs/dnsomatic.md +++ b/docs/dnsomatic.md @@ -10,7 +10,7 @@ { "provider": "dnsomatic", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "password": "password", "provider_ip": true, @@ -24,7 +24,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or `"*"` +- `"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"` - `"password"` - `"provider_ip"` diff --git a/docs/dnspod.md b/docs/dnspod.md index 8647e0bbc..2a53ec653 100644 --- a/docs/dnspod.md +++ b/docs/dnspod.md @@ -10,7 +10,7 @@ { "provider": "dnspod", "domain": "domain.com", - "host": "@", + "owner": "@", "token": "yourtoken", "ip_version": "ipv4", "ipv6_suffix": "" @@ -22,7 +22,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com` - `"token"` ### Optional parameters diff --git a/docs/dondominio.md b/docs/dondominio.md index 4f14bcad4..2fa58c933 100644 --- a/docs/dondominio.md +++ b/docs/dondominio.md @@ -10,7 +10,7 @@ { "provider": "dondominio", "domain": "domain.com", - "host": "@", + "owner": "@", "name": "something", "username": "username", "key": "key", @@ -24,7 +24,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is the subdomain to update which can be `@`, `*` or a subdomain +- `"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 - `"username"` - `"password"` diff --git a/docs/dreamhost.md b/docs/dreamhost.md index 9910462f5..2fdd0a985 100644 --- a/docs/dreamhost.md +++ b/docs/dreamhost.md @@ -10,7 +10,7 @@ { "provider": "dreamhost", "domain": "domain.com", - "host": "@", + "owner": "@", "key": "key", "ip_version": "ipv4", "ipv6_suffix": "" @@ -26,7 +26,7 @@ ### Optional parameters -- `"host"` is your host and can be a subdomain or `"@"`. It defaults to `"@"`. +- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.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`. - `"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. diff --git a/docs/duckdns.md b/docs/duckdns.md index 6d47c4977..4a73ae5ff 100644 --- a/docs/duckdns.md +++ b/docs/duckdns.md @@ -9,7 +9,7 @@ "settings": [ { "provider": "duckdns", - "host": "host", + "owner": "sub", "token": "token", "ip_version": "ipv4", "ipv6_suffix": "", @@ -21,7 +21,7 @@ ### Compulsory parameters -- `"host"` is your host, for example `subdomain` for `subdomain.duckdns.org` +- `"owner"` is the resource record owner and can be for example `"sub"` for the domain `sub.duckdns.org` - `"token"` ### Optional parameters diff --git a/docs/dyndns.md b/docs/dyndns.md index ba7ed20b0..ce86c9782 100644 --- a/docs/dyndns.md +++ b/docs/dyndns.md @@ -10,7 +10,7 @@ { "provider": "dyn", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "client_key": "client_key", "ip_version": "ipv4", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or `"*"` +- `"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"` - `"client_key"` diff --git a/docs/dynu.md b/docs/dynu.md index 59cee24c5..49b0e17e2 100644 --- a/docs/dynu.md +++ b/docs/dynu.md @@ -10,7 +10,7 @@ { "provider": "dynu", "domain": "domain.com", - "host": "@", + "owner": "@", "group": "group", "username": "username", "password": "password", @@ -25,7 +25,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com` - `"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) diff --git a/docs/dynv6.md b/docs/dynv6.md index e485d38e4..4cc2fd983 100644 --- a/docs/dynv6.md +++ b/docs/dynv6.md @@ -10,7 +10,7 @@ { "provider": "dynv6", "domain": "domain.com", - "host": "@", + "owner": "@", "token": "token", "ip_version": "ipv4", "ipv6_suffix": "", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"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) ### Optional parameters diff --git a/docs/easydns.md b/docs/easydns.md index c75de51da..30409f356 100644 --- a/docs/easydns.md +++ b/docs/easydns.md @@ -10,7 +10,7 @@ { "provider": "easydns", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "token": "token", "ip_version": "ipv4", @@ -24,7 +24,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or `"*"` +- `"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"` - `"token"` diff --git a/docs/example.md b/docs/example.md index 827cfb37e..de14e21a9 100644 --- a/docs/example.md +++ b/docs/example.md @@ -12,7 +12,7 @@ { "provider": "example", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "password": "password", "ip_version": "ipv4", @@ -25,7 +25,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or 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"` - `"password"` diff --git a/docs/freedns.md b/docs/freedns.md index 4058ff36b..a301b9c35 100644 --- a/docs/freedns.md +++ b/docs/freedns.md @@ -10,7 +10,7 @@ { "provider": "freedns", "domain": "domain.com", - "host": "host", + "owner": "sub", "token": "token", "ip_version": "ipv4", "ipv6_suffix": "" @@ -22,7 +22,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host (subdomain) +- `"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 ### Optional parameters diff --git a/docs/gandi.md b/docs/gandi.md index 4687ce17c..8b8f599b2 100644 --- a/docs/gandi.md +++ b/docs/gandi.md @@ -12,7 +12,7 @@ This provider uses Gandi v5 API { "provider": "gandi", "domain": "domain.com", - "host": "@", + "owner": "@", "personal_access_token": "token", "ttl": 3600, "ip_version": "ipv4", @@ -25,7 +25,7 @@ This provider uses Gandi v5 API ### Compulsory parameters - `"domain"` -- `"host"` which can be a subdomain, `@` or a 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"` ### Optional parameters diff --git a/docs/gcp.md b/docs/gcp.md index 87f74c5cc..b5d9aa03d 100644 --- a/docs/gcp.md +++ b/docs/gcp.md @@ -17,7 +17,7 @@ // ... }, "domain": "domain.com", - "host": "@", + "owner": "@", "ip_version": "ipv4", "ipv6_suffix": "" } @@ -31,7 +31,7 @@ - `"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. - `"domain"` is the TLD of you DNS record (without a trailing dot) -- `"host"` is your host and can be a subdomain or `"@"` or `"*"` +- `"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 diff --git a/docs/godaddy.md b/docs/godaddy.md index 71803ecb9..f3bf934fd 100644 --- a/docs/godaddy.md +++ b/docs/godaddy.md @@ -10,7 +10,7 @@ { "provider": "godaddy", "domain": "domain.com", - "host": "@", + "owner": "@", "key": "key", "secret": "secret", "ip_version": "ipv4", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain, `"@"` or `"*"` generally +- `"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"` - `"secret"` diff --git a/docs/goip.md b/docs/goip.md index d1ec61508..996c4a303 100644 --- a/docs/goip.md +++ b/docs/goip.md @@ -10,7 +10,7 @@ { "provider": "goip", "domain": "goip.de", - "host": "mysubdomain", + "owner": "mysubdomain", "username": "username", "password": "password", "provider_ip": true, @@ -24,7 +24,7 @@ ### Compulsory parameters -- `"host"` is the host of your domain, for example `"example"` for `example.goip.de`. +- `"owner"` is the resource record owner and can be for example `"example"` for `example.goip.de`. - `"username"` is your goip.de username listed under "Routers" - `"password"` is your router account password diff --git a/docs/he.net.md b/docs/he.net.md index 438e8908d..f0eee5f9a 100644 --- a/docs/he.net.md +++ b/docs/he.net.md @@ -10,7 +10,7 @@ { "provider": "he", "domain": "domain.com", - "host": "@", + "owner": "@", "password": "password", "provider_ip": true, "ip_version": "ipv4", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or `"*"` (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"` ### Optional parameters diff --git a/docs/hetzner.md b/docs/hetzner.md index b13b6555a..f5368eb8d 100644 --- a/docs/hetzner.md +++ b/docs/hetzner.md @@ -11,7 +11,7 @@ "provider": "hetzner", "zone_identifier": "some id", "domain": "domain.com", - "host": "@", + "owner": "@", "ttl": 600, "token": "yourtoken", "ip_version": "ipv4", @@ -25,7 +25,7 @@ - `"zone_identifier"` is the Zone ID of your site, from the domain overview page written as *Zone ID* - `"domain"` -- `"host"` is your host and can be `"@"`, a subdomain or 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 - 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 diff --git a/docs/infomaniak.md b/docs/infomaniak.md index 6905fbae3..d62af2728 100644 --- a/docs/infomaniak.md +++ b/docs/infomaniak.md @@ -10,7 +10,7 @@ { "provider": "infomaniak", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "password": "password", "ip_version": "ipv4", @@ -24,7 +24,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"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!) - `"password"` for dyndns (**not** your infomaniak admin password!) diff --git a/docs/inwx.md b/docs/inwx.md index 5c4c96fc9..84a0ef4e7 100644 --- a/docs/inwx.md +++ b/docs/inwx.md @@ -10,7 +10,7 @@ { "provider": "inwx", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "password": "password", "ip_version": "ipv4", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com` - `"username"` - `"password"` diff --git a/docs/ionos.md b/docs/ionos.md index 38cf31e3f..c4d9d286f 100644 --- a/docs/ionos.md +++ b/docs/ionos.md @@ -10,7 +10,7 @@ { "provider": "ionos", "domain": "domain.com", - "host": "@", + "owner": "@", "api_key": "api_key", "ip_version": "ipv4", "ipv6_suffix": "" @@ -22,7 +22,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or `"*"` +- `"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) ### Optional parameters diff --git a/docs/linode.md b/docs/linode.md index fbfa9d83a..5a791b15a 100644 --- a/docs/linode.md +++ b/docs/linode.md @@ -10,7 +10,7 @@ { "provider": "linode", "domain": "domain.com", - "host": "@", + "owner": "@", "token": "token", "ip_version": "ipv4", "ipv6_suffix": "" @@ -22,7 +22,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or `"*"` +- `"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"` ### Optional parameters diff --git a/docs/luadns.md b/docs/luadns.md index 4e523adc8..ee1a62133 100644 --- a/docs/luadns.md +++ b/docs/luadns.md @@ -10,7 +10,7 @@ { "provider": "luadns", "domain": "domain.com", - "host": "@", + "owner": "@", "email": "email", "token": "token", "ip_version": "ipv4", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or `"*"` +- `"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"` - `"token"` diff --git a/docs/name.com.md b/docs/name.com.md index efd465832..5e14d8202 100644 --- a/docs/name.com.md +++ b/docs/name.com.md @@ -12,7 +12,7 @@ { "provider": "name.com", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "token": "token", "ttl": 300, @@ -26,7 +26,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain, `"@"` or `"*"` generally +- `"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 - `"token"` which you can obtain from [www.name.com/account/settings/api](https://www.name.com/account/settings/api) diff --git a/docs/namecheap.md b/docs/namecheap.md index 47273d88b..52f3a734f 100644 --- a/docs/namecheap.md +++ b/docs/namecheap.md @@ -10,7 +10,7 @@ { "provider": "namecheap", "domain": "domain.com", - "host": "@", + "owner": "@", "password": "password", "provider_ip": true } @@ -21,7 +21,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain, `"@"` or `"*"` generally +- `"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"` ### Optional parameters diff --git a/docs/netcup.md b/docs/netcup.md index 60b49e45b..2a7b0bf4e 100644 --- a/docs/netcup.md +++ b/docs/netcup.md @@ -14,7 +14,7 @@ Also keep in mind, that TTL, Expire, Retry and Refresh values of the given Domai { "provider": "netcup", "domain": "domain.com", - "host": "host", + "owner": "@", "api_key": "xxxxx", "password": "yyyyy", "customer_number": "111111", @@ -28,7 +28,7 @@ Also keep in mind, that TTL, Expire, Retry and Refresh values of the given Domai ### Compulsory parameters - `"domain"` is your domain -- `"host"` is your host (subdomain) or `"@"` for the root of the domain. It cannot be the wildcard. +- `"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)) - `"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. diff --git a/docs/njalla.md b/docs/njalla.md index a83c1379b..19e0f53ac 100644 --- a/docs/njalla.md +++ b/docs/njalla.md @@ -10,7 +10,7 @@ { "provider": "njalla", "domain": "domain.com", - "host": "@", + "owner": "@", "key": "key", "ip_version": "ipv4", "ipv6_suffix": "", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or `"*"` +- `"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 ### Optional parameters diff --git a/docs/noip.md b/docs/noip.md index a6fe34c80..7cfdd79a0 100644 --- a/docs/noip.md +++ b/docs/noip.md @@ -10,7 +10,7 @@ { "provider": "noip", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "password": "password", "ip_version": "ipv4", @@ -24,7 +24,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com` - `"username"` - `"password"` diff --git a/docs/opendns.md b/docs/opendns.md index 950997f5d..0d4dfe06b 100644 --- a/docs/opendns.md +++ b/docs/opendns.md @@ -10,7 +10,7 @@ { "provider": "opendns", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "password": "password", "ip_version": "ipv4", @@ -24,7 +24,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com` - `"username"` - `"password"` diff --git a/docs/ovh.md b/docs/ovh.md index db9b0d080..5cb282b9e 100644 --- a/docs/ovh.md +++ b/docs/ovh.md @@ -10,7 +10,7 @@ { "provider": "ovh", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "password": "password", "ip_version": "ipv4", @@ -24,7 +24,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"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 diff --git a/docs/porkbun.md b/docs/porkbun.md index 691ac758f..8f9e5ddd9 100644 --- a/docs/porkbun.md +++ b/docs/porkbun.md @@ -10,7 +10,7 @@ { "provider": "porkbun", "domain": "domain.com", - "host": "@", + "owner": "@", "api_key": "sk1_7d119e3f656b00ae042980302e1425a04163c476efec1833q3cb0w54fc6f5022", "secret_api_key": "pk1_5299b57125c8f3cdf347d2fe0e713311ee3a1e11f11a14942b26472593e35368", "ip_version": "ipv4", @@ -23,7 +23,7 @@ ### Compulsory Parameters - `"domain"` -- `"host"` is your host and can be a subdomain, `"*"` or `"@"` +- `"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"` - `"secretapikey"` - `"ttl"` optional integer value corresponding to a number of seconds diff --git a/docs/route53.md b/docs/route53.md index 5407c1f97..76e36d49d 100644 --- a/docs/route53.md +++ b/docs/route53.md @@ -10,7 +10,7 @@ { "provider": "route53", "domain": "domain.com", - "host": "@", + "owner": "@", "ip_version": "ipv4", "ipv6_suffix": "", "access_key": "ffffffffffffffffffff", @@ -25,7 +25,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or 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` - `"secret_key"` is the `AWS_SECRET_ACCESS_KEY` - `"zone_id"` is identification of your hosted zone diff --git a/docs/selfhost.de.md b/docs/selfhost.de.md index e507f2fa8..71c2241b8 100644 --- a/docs/selfhost.de.md +++ b/docs/selfhost.de.md @@ -10,7 +10,7 @@ { "provider": "selfhost.de", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "password": "password", "provider_ip": true, @@ -24,7 +24,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"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 - `"password"` is your DynDNS password diff --git a/docs/servercow.md b/docs/servercow.md index e7b049c19..32c9ae995 100644 --- a/docs/servercow.md +++ b/docs/servercow.md @@ -10,7 +10,7 @@ { "provider": "servercow", "domain": "domain.com", - "host": "", + "owner": "", "username": "servercow_username", "password": "servercow_password", "ttl": 600, @@ -25,7 +25,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be `""`, a subdomain or `"*"` generally +- `"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 - `"password"` is the password for your DNS API User diff --git a/docs/spdyn.md b/docs/spdyn.md index ff8b1522d..5563c4c18 100644 --- a/docs/spdyn.md +++ b/docs/spdyn.md @@ -10,7 +10,7 @@ { "provider": "spdyn", "domain": "domain.com", - "host": "@", + "owner": "@", "user": "user", "password": "password", "token": "token", @@ -25,7 +25,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"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 diff --git a/docs/strato.md b/docs/strato.md index 0bcad5644..89b8ccb78 100644 --- a/docs/strato.md +++ b/docs/strato.md @@ -10,7 +10,7 @@ { "provider": "strato", "domain": "domain.com", - "host": "@", + "owner": "@", "password": "password", "ip_version": "ipv4", "ipv6_suffix": "", @@ -23,7 +23,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"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 ### Optional parameters diff --git a/docs/variomedia.md b/docs/variomedia.md index 9ddcee489..17930596a 100644 --- a/docs/variomedia.md +++ b/docs/variomedia.md @@ -10,7 +10,7 @@ { "provider": "variomedia", "domain": "domain.com", - "host": "@", + "owner": "@", "email": "email@domain.com", "password": "password", "ip_version": "ipv4", @@ -24,7 +24,7 @@ ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` +- `"owner"` is the resource record owner and can be `"@"` for the root domain or for example `"sub"` for the subdomain `sub.domain.com` - `"email"` - `"password"` is your DNS settings password, not your account password ⚠️ diff --git a/docs/zoneedit.md b/docs/zoneedit.md index 8b2aa9827..24d4823bd 100644 --- a/docs/zoneedit.md +++ b/docs/zoneedit.md @@ -16,7 +16,7 @@ set the environment variable as `PERIOD=11m` to check your public IP address and { "provider": "zoneedit", "domain": "domain.com", - "host": "@", + "owner": "@", "username": "username", "token": "token", "ip_version": "ipv4", @@ -30,7 +30,7 @@ set the environment variable as `PERIOD=11m` to check your public IP address and ### Compulsory parameters - `"domain"` -- `"host"` is your host and can be a subdomain or `"@"` or `"*"` +- `"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"` - `"token"` diff --git a/internal/data/interfaces.go b/internal/data/interfaces.go index aae22f9d6..e92bd39ea 100644 --- a/internal/data/interfaces.go +++ b/internal/data/interfaces.go @@ -7,5 +7,5 @@ import ( type PersistentDatabase interface { Close() error - StoreNewIP(domain, host string, ip netip.Addr, t time.Time) (err error) + StoreNewIP(domain, owner string, ip netip.Addr, t time.Time) (err error) } diff --git a/internal/data/persistence.go b/internal/data/persistence.go index 018bdcffa..6b0aaa528 100644 --- a/internal/data/persistence.go +++ b/internal/data/persistence.go @@ -19,7 +19,7 @@ func (db *Database) Update(id uint, record records.Record) (err error) { if newCount > currentCount { if err := db.persistentDB.StoreNewIP( record.Provider.Domain(), - record.Provider.Host(), + record.Provider.Owner(), record.History.GetCurrentIP(), record.History.GetSuccessTime(), ); err != nil { diff --git a/internal/models/html.go b/internal/models/html.go index fc844bc51..fc8d8681f 100644 --- a/internal/models/html.go +++ b/internal/models/html.go @@ -10,7 +10,7 @@ type HTMLData struct { // It is exported so that the HTML template engine can render it. type HTMLRow struct { Domain string - Host string + Owner string Provider string IPVersion string Status string diff --git a/internal/params/json.go b/internal/params/json.go index 1fa8b4f9d..981968002 100644 --- a/internal/params/json.go +++ b/internal/params/json.go @@ -18,9 +18,11 @@ import ( ) type commonSettings struct { - Provider string `json:"provider"` - Domain string `json:"domain"` - Host string `json:"host"` + Provider string `json:"provider"` + Domain string `json:"domain"` + // Host is kept for retro-compatibility and is replaced by Owner. + Host string `json:"host,omitempty"` + Owner string `json:"owner"` IPVersion string `json:"ip_version"` IPv6Suffix netip.Prefix `json:"ipv6_suffix,omitempty"` // Retro values for warnings @@ -162,22 +164,27 @@ func makeSettingsFromObject(common commonSettings, rawSettings json.RawMessage, } } + if common.Owner == "" { // retro compatibility + common.Owner = common.Host + } + providerName := models.Provider(common.Provider) - if providerName == constants.DuckDNS { // only hosts, no domain + if providerName == constants.DuckDNS { // only owner(s), no domain if common.Domain != "" { // retro compatibility - if common.Host == "" { - common.Host = strings.TrimSuffix(common.Domain, ".duckdns.org") + if common.Owner == "" { + common.Owner = strings.TrimSuffix(common.Domain, ".duckdns.org") warnings = append(warnings, - fmt.Sprintf("DuckDNS record should have %q specified as host instead of %q as domain", - common.Host, common.Domain)) + fmt.Sprintf("DuckDNS record should have %q specified as owner instead of %q as domain", + common.Owner, common.Domain)) } else { warnings = append(warnings, - fmt.Sprintf("ignoring domain %q because host %q is specified for DuckDNS record", - common.Domain, common.Host)) + fmt.Sprintf("ignoring domain %q because owner %q is specified for DuckDNS record", + common.Domain, common.Owner)) } } } - hosts := strings.Split(common.Host, ",") + + owners := strings.Split(common.Owner, ",") if common.IPVersion == "" { common.IPVersion = ipversion.IP4or6.String() @@ -198,11 +205,11 @@ func makeSettingsFromObject(common commonSettings, rawSettings json.RawMessage, ipv6Suffix, ipVersion)) } - providers = make([]provider.Provider, len(hosts)) - for i, host := range hosts { - host = strings.TrimSpace(host) + providers = make([]provider.Provider, len(owners)) + for i, owner := range owners { + owner = strings.TrimSpace(owner) providers[i], err = provider.New(providerName, rawSettings, common.Domain, - host, ipVersion, ipv6Suffix) + owner, ipVersion, ipv6Suffix) if err != nil { return nil, warnings, err } diff --git a/internal/persistence/json/database.go b/internal/persistence/json/database.go index 4226527da..902e6d8c0 100644 --- a/internal/persistence/json/database.go +++ b/internal/persistence/json/database.go @@ -64,6 +64,14 @@ func NewDatabase(dataDir string) (*Database, error) { return nil, fmt.Errorf("closing database file: %w", err) } + // Migration from older database using "host" instead of "owner". + for i := range data.Records { + if data.Records[i].Owner == "" { + data.Records[i].Owner = data.Records[i].Host + data.Records[i].Host = "" + } + } + err = checkData(data) if err != nil { return nil, fmt.Errorf("%s validation error: %w", filePath, err) @@ -77,7 +85,7 @@ func NewDatabase(dataDir string) (*Database, error) { var ( ErrDomainEmpty = errors.New("domain is empty") - ErrHostIsEmpty = errors.New("host is empty") + ErrOwnerNotSet = errors.New("owner is not set") ErrIPRecordsMisordered = errors.New("IP records are not ordered correctly by time") ErrIPEmpty = errors.New("IP is empty") ErrIPTimeEmpty = errors.New("time of IP is empty") @@ -89,16 +97,16 @@ func checkData(data dataModel) (err error) { case record.Domain == "": return fmt.Errorf("%w: for record %d of %d", ErrDomainEmpty, i+1, len(data.Records)) - case record.Host == "": + case record.Owner == "": return fmt.Errorf("%w: for record %d of %d with domain %s", - ErrHostIsEmpty, i+1, len(data.Records), record.Domain) + ErrOwnerNotSet, i+1, len(data.Records), record.Domain) } err = checkHistoryEvents(record.Events) if err != nil { - return fmt.Errorf("for record %d of %d with domain %s and host %s: "+ + return fmt.Errorf("for record %d of %d with domain %s and owner %s: "+ "history events: %w", i+1, len(data.Records), - record.Domain, record.Host, err) + record.Domain, record.Owner, err) } } return nil diff --git a/internal/persistence/json/models.go b/internal/persistence/json/models.go index f1342d37d..c431f814a 100644 --- a/internal/persistence/json/models.go +++ b/internal/persistence/json/models.go @@ -11,8 +11,10 @@ type dataModel struct { } type record struct { - Domain string `json:"domain"` - Host string `json:"host"` + Domain string `json:"domain"` + // Host is kept for retro-compatibility and is replaced by Owner. + Host string `json:"host,omitempty"` + Owner string `json:"owner"` Events []models.HistoryEvent `json:"ips"` } diff --git a/internal/persistence/json/queries.go b/internal/persistence/json/queries.go index e9633c356..5fb9c69f9 100644 --- a/internal/persistence/json/queries.go +++ b/internal/persistence/json/queries.go @@ -9,14 +9,14 @@ import ( "github.com/qdm12/ddns-updater/pkg/publicip/ipversion" ) -// StoreNewIP stores a new IP address for a certain domain and host. -func (db *Database) StoreNewIP(domain, host string, ip netip.Addr, t time.Time) (err error) { +// StoreNewIP stores a new IP address for a certain domain and owner. +func (db *Database) StoreNewIP(domain, owner string, ip netip.Addr, t time.Time) (err error) { db.Lock() defer db.Unlock() targetIndex := -1 for i, record := range db.data.Records { - if record.Domain == domain && record.Host == host { + if record.Domain == domain && record.Owner == owner { targetIndex = i break } @@ -26,7 +26,7 @@ func (db *Database) StoreNewIP(domain, host string, ip netip.Addr, t time.Time) if recordNotFound { db.data.Records = append(db.data.Records, record{ Domain: domain, - Host: host, + Owner: owner, }) targetIndex = len(db.data.Records) - 1 } @@ -39,14 +39,14 @@ func (db *Database) StoreNewIP(domain, host string, ip netip.Addr, t time.Time) return db.write() } -// GetEvents gets all the IP addresses history for a certain domain, host and +// GetEvents gets all the IP addresses history for a certain domain, owner and // IP version, in the order from oldest to newest. -func (db *Database) GetEvents(domain, host string, +func (db *Database) GetEvents(domain, owner string, ipVersion ipversion.IPVersion) (events []models.HistoryEvent, err error) { db.RLock() defer db.RUnlock() for _, record := range db.data.Records { - if record.Domain == domain && record.Host == host { + if record.Domain == domain && record.Owner == owner { return filterEvents(record.Events, ipVersion), nil } } diff --git a/internal/provider/errors/validation.go b/internal/provider/errors/validation.go index 1f1cedd0a..a2fdd527b 100644 --- a/internal/provider/errors/validation.go +++ b/internal/provider/errors/validation.go @@ -18,9 +18,9 @@ var ( ErrEmailNotValid = errors.New("email address is not valid") ErrGCPProjectNotSet = errors.New("GCP project is not set") ErrDomainNotValid = errors.New("domain is not valid") - ErrHostNotSet = errors.New("host is not set") - ErrHostOnlySubdomain = errors.New("host can only be a subdomain") - ErrHostWildcard = errors.New(`host cannot be a "*"`) + ErrOwnerNotSet = errors.New("owner is not set") + ErrOwnerRootOrWildcard = errors.New(`owner cannot be "@" or "*"`) + ErrOwnerWildcard = errors.New(`owner cannot be "*"`) ErrIPv4KeyNotSet = errors.New("IPv4 key is not set") ErrIPv6KeyNotSet = errors.New("IPv6 key is not set") ErrKeyNotSet = errors.New("key is not set") diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 0895f9dbe..db750bb6a 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -63,7 +63,7 @@ import ( type Provider interface { String() string Domain() string - Host() string + Owner() string BuildDomainName() string HTML() models.HTMLRow Proxied() bool @@ -75,103 +75,103 @@ type Provider interface { var ErrProviderUnknown = errors.New("unknown provider") //nolint:gocyclo -func New(providerName models.Provider, data json.RawMessage, domain, host string, //nolint:ireturn +func New(providerName models.Provider, data json.RawMessage, domain, owner string, //nolint:ireturn ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (provider Provider, err error) { switch providerName { case constants.Aliyun: - return aliyun.New(data, domain, host, ipVersion, ipv6Suffix) + return aliyun.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.AllInkl: - return allinkl.New(data, domain, host, ipVersion, ipv6Suffix) + return allinkl.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Changeip: - return changeip.New(data, domain, host, ipVersion, ipv6Suffix) + return changeip.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Cloudflare: - return cloudflare.New(data, domain, host, ipVersion, ipv6Suffix) + return cloudflare.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Custom: - return custom.New(data, domain, host, ipVersion, ipv6Suffix) + return custom.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Dd24: - return dd24.New(data, domain, host, ipVersion, ipv6Suffix) + return dd24.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.DdnssDe: - return ddnss.New(data, domain, host, ipVersion, ipv6Suffix) + return ddnss.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.DeSEC: - return desec.New(data, domain, host, ipVersion, ipv6Suffix) + return desec.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.DigitalOcean: - return digitalocean.New(data, domain, host, ipVersion, ipv6Suffix) + return digitalocean.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.DNSOMatic: - return dnsomatic.New(data, domain, host, ipVersion, ipv6Suffix) + return dnsomatic.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.DNSPod: - return dnspod.New(data, domain, host, ipVersion, ipv6Suffix) + return dnspod.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.DonDominio: - return dondominio.New(data, domain, host, ipVersion, ipv6Suffix) + return dondominio.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Dreamhost: - return dreamhost.New(data, domain, host, ipVersion, ipv6Suffix) + return dreamhost.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.DuckDNS: - return duckdns.New(data, domain, host, ipVersion, ipv6Suffix) + return duckdns.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Dyn: - return dyn.New(data, domain, host, ipVersion, ipv6Suffix) + return dyn.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Dynu: - return dynu.New(data, domain, host, ipVersion, ipv6Suffix) + return dynu.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.DynV6: - return dynv6.New(data, domain, host, ipVersion, ipv6Suffix) + return dynv6.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.EasyDNS: - return easydns.New(data, domain, host, ipVersion, ipv6Suffix) + return easydns.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Example: - return example.New(data, domain, host, ipVersion, ipv6Suffix) + return example.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.FreeDNS: - return freedns.New(data, domain, host, ipVersion, ipv6Suffix) + return freedns.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Gandi: - return gandi.New(data, domain, host, ipVersion, ipv6Suffix) + return gandi.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.GCP: - return gcp.New(data, domain, host, ipVersion, ipv6Suffix) + return gcp.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.GoDaddy: - return godaddy.New(data, domain, host, ipVersion, ipv6Suffix) + return godaddy.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.GoIP: - return goip.New(data, domain, host, ipVersion, ipv6Suffix) + return goip.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.HE: - return he.New(data, domain, host, ipVersion, ipv6Suffix) + return he.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Hetzner: - return hetzner.New(data, domain, host, ipVersion, ipv6Suffix) + return hetzner.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Infomaniak: - return infomaniak.New(data, domain, host, ipVersion, ipv6Suffix) + return infomaniak.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.INWX: - return inwx.New(data, domain, host, ipVersion, ipv6Suffix) + return inwx.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Ionos: - return ionos.New(data, domain, host, ipVersion, ipv6Suffix) + return ionos.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Linode: - return linode.New(data, domain, host, ipVersion, ipv6Suffix) + return linode.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.LuaDNS: - return luadns.New(data, domain, host, ipVersion, ipv6Suffix) + return luadns.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Namecheap: - return namecheap.New(data, domain, host) + return namecheap.New(data, domain, owner) case constants.NameCom: - return namecom.New(data, domain, host, ipVersion, ipv6Suffix) + return namecom.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Netcup: - return netcup.New(data, domain, host, ipVersion, ipv6Suffix) + return netcup.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Njalla: - return njalla.New(data, domain, host, ipVersion, ipv6Suffix) + return njalla.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.NoIP: - return noip.New(data, domain, host, ipVersion, ipv6Suffix) + return noip.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.NowDNS: return nowdns.New(data, domain, ipVersion, ipv6Suffix) case constants.OpenDNS: - return opendns.New(data, domain, host, ipVersion, ipv6Suffix) + return opendns.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.OVH: - return ovh.New(data, domain, host, ipVersion, ipv6Suffix) + return ovh.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Porkbun: - return porkbun.New(data, domain, host, ipVersion, ipv6Suffix) + return porkbun.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Route53: - return route53.New(data, domain, host, ipVersion, ipv6Suffix) + return route53.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.SelfhostDe: - return selfhostde.New(data, domain, host, ipVersion, ipv6Suffix) + return selfhostde.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Servercow: - return servercow.New(data, domain, host, ipVersion, ipv6Suffix) + return servercow.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Spdyn: - return spdyn.New(data, domain, host, ipVersion, ipv6Suffix) + return spdyn.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Strato: - return strato.New(data, domain, host, ipVersion, ipv6Suffix) + return strato.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Variomedia: - return variomedia.New(data, domain, host, ipVersion, ipv6Suffix) + return variomedia.New(data, domain, owner, ipVersion, ipv6Suffix) case constants.Zoneedit: - return zoneedit.New(data, domain, host, ipVersion, ipv6Suffix) + return zoneedit.New(data, domain, owner, ipVersion, ipv6Suffix) default: return nil, fmt.Errorf("%w: %s", ErrProviderUnknown, providerName) } diff --git a/internal/provider/providers/aliyun/create.go b/internal/provider/providers/aliyun/create.go index 0393f011d..f676d91b5 100644 --- a/internal/provider/providers/aliyun/create.go +++ b/internal/provider/providers/aliyun/create.go @@ -27,7 +27,7 @@ func (p *Provider) createRecord(ctx context.Context, values := newURLValues(p.accessKeyID) values.Set("Action", "AddDomainRecord") values.Set("DomainName", p.domain) - values.Set("RR", p.host) + values.Set("RR", p.owner) values.Set("Type", recordType) values.Set("Value", ip.String()) diff --git a/internal/provider/providers/aliyun/getrecord.go b/internal/provider/providers/aliyun/getrecord.go index d5a771090..5ccae721d 100644 --- a/internal/provider/providers/aliyun/getrecord.go +++ b/internal/provider/providers/aliyun/getrecord.go @@ -21,7 +21,7 @@ func (p *Provider) getRecordID(ctx context.Context, client *http.Client, values := newURLValues(p.accessKeyID) values.Set("Action", "DescribeDomainRecords") values.Set("DomainName", p.domain) - values.Set("RRKeyWord", p.host) + values.Set("RRKeyWord", p.owner) values.Set("Type", recordType) sign(http.MethodGet, values, p.accessSecret) diff --git a/internal/provider/providers/aliyun/provider.go b/internal/provider/providers/aliyun/provider.go index 0f777dfb6..988840b8a 100644 --- a/internal/provider/providers/aliyun/provider.go +++ b/internal/provider/providers/aliyun/provider.go @@ -17,7 +17,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix accessKeyID string @@ -25,7 +25,7 @@ type Provider struct { region string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -39,7 +39,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, accessKeyID: extraSettings.AccessKeyID, @@ -67,15 +67,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Aliyun, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Aliyun, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -91,13 +91,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Aliyun", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/aliyun/update.go b/internal/provider/providers/aliyun/update.go index 02ca3da61..a4db3eb5c 100644 --- a/internal/provider/providers/aliyun/update.go +++ b/internal/provider/providers/aliyun/update.go @@ -26,7 +26,7 @@ func (p *Provider) updateRecord(ctx context.Context, client *http.Client, values := newURLValues(p.accessKeyID) values.Set("Action", "UpdateDomainRecord") values.Set("RecordId", recordID) - values.Set("RR", p.host) + values.Set("RR", p.owner) values.Set("Type", recordType) values.Set("Value", ip.String()) diff --git a/internal/provider/providers/allinkl/provider.go b/internal/provider/providers/allinkl/provider.go index f01678bf8..6d0c76a13 100644 --- a/internal/provider/providers/allinkl/provider.go +++ b/internal/provider/providers/allinkl/provider.go @@ -21,7 +21,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -29,7 +29,7 @@ type Provider struct { useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -43,7 +43,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -63,22 +63,22 @@ func (p *Provider) isValid() error { return fmt.Errorf("%w", errors.ErrUsernameNotSet) case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.AllInkl, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.AllInkl, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -94,13 +94,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "ALL-INKL.com", IPVersion: p.ipVersion.String(), } @@ -114,7 +114,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add User: url.UserPassword(p.username, p.password), } values := url.Values{} - values.Set("host", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("host", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { if ip.Is6() { diff --git a/internal/provider/providers/changeip/provider.go b/internal/provider/providers/changeip/provider.go index 458b0b0be..71397cc9e 100644 --- a/internal/provider/providers/changeip/provider.go +++ b/internal/provider/providers/changeip/provider.go @@ -18,7 +18,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -32,7 +32,7 @@ type settings struct { UseProviderIP bool `json:"provider_ip"` } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { var providerSpecificSettings settings @@ -40,13 +40,13 @@ func New(data json.RawMessage, domain, host string, if err != nil { return nil, fmt.Errorf("json decoding provider specific settings: %w", err) } - err = validateSettings(domain, host, providerSpecificSettings) + err = validateSettings(domain, owner, providerSpecificSettings) if err != nil { return nil, fmt.Errorf("validating settings: %w", err) } return &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: providerSpecificSettings.Username, @@ -55,12 +55,12 @@ func New(data json.RawMessage, domain, host string, }, nil } -func validateSettings(domain, host string, settings settings) error { +func validateSettings(domain, owner string, settings settings) error { switch { case domain == "": return fmt.Errorf("%w", errors.ErrDomainNotSet) - case host == "": - return fmt.Errorf("%w", errors.ErrHostNotSet) + case owner == "": + return fmt.Errorf("%w", errors.ErrOwnerNotSet) case settings.Username == "": return fmt.Errorf("%w", errors.ErrUsernameNotSet) case settings.Password == "": @@ -70,15 +70,15 @@ func validateSettings(domain, host string, settings settings) error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Changeip, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Changeip, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -94,13 +94,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "changeip.com", IPVersion: p.ipVersion.String(), } @@ -113,7 +113,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/nic/update", } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { values.Set("ip", ip.String()) diff --git a/internal/provider/providers/cloudflare/provider.go b/internal/provider/providers/cloudflare/provider.go index 16436ad5a..9f5e7bd0a 100644 --- a/internal/provider/providers/cloudflare/provider.go +++ b/internal/provider/providers/cloudflare/provider.go @@ -22,7 +22,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix key string @@ -34,7 +34,7 @@ type Provider struct { ttl uint32 } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -52,7 +52,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, key: extraSettings.Key, @@ -104,15 +104,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Cloudflare, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Cloudflare, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -128,13 +128,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Cloudflare", IPVersion: p.ipVersion.String(), } @@ -172,7 +172,7 @@ func (p *Provider) getRecordID(ctx context.Context, client *http.Client, newIP n values := url.Values{} values.Set("type", recordType) - values.Set("name", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("name", utils.BuildURLQueryHostname(p.owner, p.domain)) values.Set("page", "1") values.Set("per_page", "1") u.RawQuery = values.Encode() @@ -246,7 +246,7 @@ func (p *Provider) createRecord(ctx context.Context, client *http.Client, ip net TTL uint32 `json:"ttl"` }{ Type: recordType, - Name: utils.BuildURLQueryHostname(p.host, p.domain), + Name: utils.BuildURLQueryHostname(p.owner, p.domain), Content: ip.String(), Proxied: p.proxied, TTL: p.ttl, @@ -338,7 +338,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add TTL uint32 `json:"ttl"` }{ Type: recordType, - Name: utils.BuildURLQueryHostname(p.host, p.domain), + Name: utils.BuildURLQueryHostname(p.owner, p.domain), Content: ip.String(), Proxied: p.proxied, TTL: p.ttl, diff --git a/internal/provider/providers/custom/provider.go b/internal/provider/providers/custom/provider.go index e356fef25..2a17b9d57 100644 --- a/internal/provider/providers/custom/provider.go +++ b/internal/provider/providers/custom/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix url *url.URL @@ -29,7 +29,7 @@ type Provider struct { successRegex regexp.Regexp } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -50,7 +50,7 @@ func New(data json.RawMessage, domain, host string, p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, url: parsedURL, @@ -83,15 +83,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Custom, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Custom, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -107,14 +107,14 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { updateHostname := p.url.Hostname() return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: fmt.Sprintf("%s: %s", updateHostname, constants.Custom, updateHostname), IPVersion: p.ipVersion.String(), diff --git a/internal/provider/providers/dd24/provider.go b/internal/provider/providers/dd24/provider.go index ed0b859d0..eb134e3a2 100644 --- a/internal/provider/providers/dd24/provider.go +++ b/internal/provider/providers/dd24/provider.go @@ -20,14 +20,14 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix password string useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -40,7 +40,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, password: extraSettings.Password, @@ -61,15 +61,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Dd24, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Dd24, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -85,13 +85,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "DD24", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/ddnss/provider.go b/internal/provider/providers/ddnss/provider.go index 6a6962cad..c2967887a 100644 --- a/internal/provider/providers/ddnss/provider.go +++ b/internal/provider/providers/ddnss/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -29,7 +29,7 @@ type Provider struct { useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -44,7 +44,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -65,22 +65,22 @@ func (p *Provider) isValid() error { return fmt.Errorf("%w", errors.ErrUsernameNotSet) case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.DdnssDe, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.DdnssDe, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -96,13 +96,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "DDNSS.de", IPVersion: p.ipVersion.String(), } @@ -117,7 +117,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add values := url.Values{} values.Set("user", p.username) values.Set("pwd", p.password) - values.Set("host", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("host", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { ipKey := "ip" diff --git a/internal/provider/providers/desec/provider.go b/internal/provider/providers/desec/provider.go index 0115b7820..1fc9b53bd 100644 --- a/internal/provider/providers/desec/provider.go +++ b/internal/provider/providers/desec/provider.go @@ -20,14 +20,14 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix token string useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -38,12 +38,12 @@ func New(data json.RawMessage, domain, host string, if err != nil { return nil, err } - if host == "" { - host = "@" // default + if owner == "" { + owner = "@" // default } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, token: extraSettings.Token, @@ -64,15 +64,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.DeSEC, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.DeSEC, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -88,13 +88,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "deSEC", IPVersion: p.ipVersion.String(), } @@ -108,7 +108,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/nic/update", } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if useProviderIP { values.Set("myip", ip.String()) diff --git a/internal/provider/providers/digitalocean/provider.go b/internal/provider/providers/digitalocean/provider.go index 993a599e2..62c11ce7a 100644 --- a/internal/provider/providers/digitalocean/provider.go +++ b/internal/provider/providers/digitalocean/provider.go @@ -19,13 +19,13 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix token string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -37,7 +37,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, token: extraSettings.Token, @@ -57,15 +57,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.DigitalOcean, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.DigitalOcean, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -81,13 +81,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "DigitalOcean", IPVersion: p.ipVersion.String(), } @@ -102,7 +102,7 @@ func (p *Provider) setCommonHeaders(request *http.Request) { func (p *Provider) getRecordID(ctx context.Context, recordType string, client *http.Client) ( recordID int, err error) { values := url.Values{} - values.Set("name", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("name", utils.BuildURLQueryHostname(p.owner, p.domain)) values.Set("type", recordType) u := url.URL{ Scheme: "https", @@ -173,7 +173,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Data string `json:"data"` }{ Type: recordType, - Name: p.host, + Name: p.owner, Data: ip.String(), } err = encoder.Encode(requestData) diff --git a/internal/provider/providers/dnsomatic/provider.go b/internal/provider/providers/dnsomatic/provider.go index 87a871323..6077c372d 100644 --- a/internal/provider/providers/dnsomatic/provider.go +++ b/internal/provider/providers/dnsomatic/provider.go @@ -21,7 +21,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -29,7 +29,7 @@ type Provider struct { useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -43,7 +43,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -68,15 +68,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.DNSOMatic, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.DNSOMatic, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -88,24 +88,24 @@ func (p *Provider) IPv6Suffix() netip.Prefix { } func (p *Provider) Proxied() bool { - return p.host == "all" + return p.owner == "all" } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "dnsomatic", IPVersion: p.ipVersion.String(), } } func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Addr) (newIP netip.Addr, err error) { - // Multiple hosts can be updated in one query, see https://www.dnsomatic.com/docs/api + // Multiple hostnames can be updated in one query, see https://www.dnsomatic.com/docs/api u := url.URL{ Scheme: "https", Host: "updates.dnsomatic.com", @@ -118,11 +118,11 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add values.Set("myip", ip.String()) } values.Set("wildcard", "NOCHG") - if p.host == "*" { + if p.owner == "*" { values.Set("hostname", p.domain) values.Set("wildcard", "ON") } else { - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) } values.Set("mx", "NOCHG") values.Set("backmx", "NOCHG") diff --git a/internal/provider/providers/dnspod/provider.go b/internal/provider/providers/dnspod/provider.go index 87ffb02b5..c06be814a 100644 --- a/internal/provider/providers/dnspod/provider.go +++ b/internal/provider/providers/dnspod/provider.go @@ -20,13 +20,13 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix token string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -38,7 +38,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, token: extraSettings.Token, @@ -58,15 +58,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.DNSPod, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.DNSPod, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -82,13 +82,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "DNSPod", IPVersion: p.ipVersion.String(), } @@ -116,7 +116,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add values.Set("format", "json") values.Set("domain", p.domain) values.Set("length", "200") - values.Set("sub_domain", p.host) + values.Set("sub_domain", p.owner) values.Set("record_type", recordType) encodedValues := values.Encode() buffer := bytes.NewBufferString(encodedValues) @@ -155,7 +155,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add var recordID, recordLine string for _, record := range recordResp.Records { - if record.Type == recordType && record.Name == p.host { + if record.Type == recordType && record.Name == p.owner { receivedIP, err := netip.ParseAddr(record.Value) if err == nil && ip.Compare(receivedIP) == 0 { return ip, nil @@ -177,7 +177,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add values.Set("record_id", recordID) values.Set("value", ip.String()) values.Set("record_line", recordLine) - values.Set("sub_domain", p.host) + values.Set("sub_domain", p.owner) encodedValues = values.Encode() buffer = bytes.NewBufferString(encodedValues) diff --git a/internal/provider/providers/dondominio/provider.go b/internal/provider/providers/dondominio/provider.go index f5ee93ed6..eaa4facf7 100644 --- a/internal/provider/providers/dondominio/provider.go +++ b/internal/provider/providers/dondominio/provider.go @@ -19,7 +19,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -27,7 +27,7 @@ type Provider struct { name string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -40,8 +40,8 @@ func New(data json.RawMessage, domain, host string, if err != nil { return nil, err } - if host == "" { - host = "@" // default + if owner == "" { + owner = "@" // default } if extraSettings.Password != "" { // retro-compatibility extraSettings.Key = extraSettings.Password @@ -49,7 +49,7 @@ func New(data json.RawMessage, domain, host string, p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -76,15 +76,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.DonDominio, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.DonDominio, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -100,13 +100,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "DonDominio", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/dreamhost/provider.go b/internal/provider/providers/dreamhost/provider.go index e1abe1269..175596209 100644 --- a/internal/provider/providers/dreamhost/provider.go +++ b/internal/provider/providers/dreamhost/provider.go @@ -20,13 +20,13 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix key string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -36,12 +36,12 @@ func New(data json.RawMessage, domain, host string, if err != nil { return nil, err } - if host == "" { // TODO-v2 remove default - host = "@" // default + if owner == "" { // TODO-v2 remove default + owner = "@" // default } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, key: extraSettings.Key, @@ -64,15 +64,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Dreamhost, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Dreamhost, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -88,13 +88,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Dreamhost", IPVersion: p.ipVersion.String(), } @@ -113,7 +113,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add var oldIP netip.Addr for _, data := range records.Data { - if data.Type == recordType && data.Record == utils.BuildURLQueryHostname(p.host, p.domain) { + if data.Type == recordType && data.Record == utils.BuildURLQueryHostname(p.owner, p.domain) { if data.Editable == "0" { return netip.Addr{}, fmt.Errorf("%w", errors.ErrRecordNotEditable) } @@ -222,7 +222,7 @@ func (p *Provider) removeRecord(ctx context.Context, client *http.Client, ip net } values := p.defaultURLValues() values.Set("cmd", "dns-remove_record") - values.Set("record", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("record", utils.BuildURLQueryHostname(p.owner, p.domain)) values.Set("type", recordType) values.Set("value", ip.String()) u.RawQuery = values.Encode() @@ -270,7 +270,7 @@ func (p *Provider) createRecord(ctx context.Context, client *http.Client, ip net } values := p.defaultURLValues() values.Set("cmd", "dns-add_record") - values.Set("record", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("record", utils.BuildURLQueryHostname(p.owner, p.domain)) values.Set("type", recordType) values.Set("value", ip.String()) u.RawQuery = values.Encode() diff --git a/internal/provider/providers/duckdns/provider.go b/internal/provider/providers/duckdns/provider.go index e50d028f4..93e3029e3 100644 --- a/internal/provider/providers/duckdns/provider.go +++ b/internal/provider/providers/duckdns/provider.go @@ -20,14 +20,14 @@ import ( ) type Provider struct { - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix token string useProviderIP bool } -func New(data json.RawMessage, _, host string, +func New(data json.RawMessage, _, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -39,7 +39,7 @@ func New(data json.RawMessage, _, host string, return nil, err } p = &Provider{ - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, token: extraSettings.Token, @@ -59,23 +59,23 @@ func (p *Provider) isValid() error { case !tokenRegex.MatchString(p.token): return fmt.Errorf("%w: token %q does not match regex %q", errors.ErrTokenNotValid, p.token, tokenRegex) - case p.host == "@", p.host == "*": + case p.owner == "@", p.owner == "*": return fmt.Errorf("%w: %q is not valid", - errors.ErrHostOnlySubdomain, p.host) + errors.ErrOwnerRootOrWildcard, p.owner) } return nil } func (p *Provider) String() string { - return utils.ToString("duckdns.org", p.host, constants.DuckDNS, p.ipVersion) + return utils.ToString("duckdns.org", p.owner, constants.DuckDNS, p.ipVersion) } func (p *Provider) Domain() string { return "duckdns.org" } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -91,13 +91,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, "duckdns.org") + return utils.BuildDomainName(p.owner, "duckdns.org") } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "DuckDNS", IPVersion: p.ipVersion.String(), } @@ -111,7 +111,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add } values := url.Values{} values.Set("verbose", "true") - values.Set("domains", p.host) + values.Set("domains", p.owner) values.Set("token", p.token) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { diff --git a/internal/provider/providers/dyn/provider.go b/internal/provider/providers/dyn/provider.go index 707ed2fdb..f67059ec6 100644 --- a/internal/provider/providers/dyn/provider.go +++ b/internal/provider/providers/dyn/provider.go @@ -20,14 +20,14 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string clientKey string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -47,7 +47,7 @@ func New(data json.RawMessage, domain, host string, p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -71,15 +71,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Dyn, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Dyn, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -95,13 +95,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Dyn DNS", IPVersion: p.ipVersion.String(), } @@ -116,7 +116,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/v3/update", } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) values.Set("myip", ip.String()) u.RawQuery = values.Encode() diff --git a/internal/provider/providers/dynu/provider.go b/internal/provider/providers/dynu/provider.go index 0b07dc1a3..03eb2e35c 100644 --- a/internal/provider/providers/dynu/provider.go +++ b/internal/provider/providers/dynu/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -29,7 +29,7 @@ type Provider struct { group string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -43,13 +43,13 @@ func New(data json.RawMessage, domain, host string, return nil, err } - if host == "" { - host = "@" // default + if owner == "" { + owner = "@" // default } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, group: extraSettings.Group, @@ -70,22 +70,22 @@ func (p *Provider) isValid() error { return fmt.Errorf("%w", errors.ErrUsernameNotSet) case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Dynu, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Dynu, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -101,13 +101,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Dynu", IPVersion: p.ipVersion.String(), } @@ -123,7 +123,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add values.Set("username", p.username) values.Set("password", p.password) values.Set("location", p.group) - hostname := utils.BuildDomainName(p.host, p.domain) + hostname := utils.BuildDomainName(p.owner, p.domain) values.Set("hostname", hostname) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { diff --git a/internal/provider/providers/dynv6/provider.go b/internal/provider/providers/dynv6/provider.go index 8008494fa..1410570d5 100644 --- a/internal/provider/providers/dynv6/provider.go +++ b/internal/provider/providers/dynv6/provider.go @@ -18,14 +18,14 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix token string useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -38,7 +38,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, token: extraSettings.Token, @@ -55,22 +55,22 @@ func (p *Provider) isValid() error { switch { case p.token == "": return fmt.Errorf("%w", errors.ErrTokenNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.DynV6, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.DynV6, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -86,13 +86,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "DynV6 DNS", IPVersion: p.ipVersion.String(), } @@ -113,7 +113,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add } values := url.Values{} values.Set("token", p.token) - values.Set("zone", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("zone", utils.BuildURLQueryHostname(p.owner, p.domain)) ipValue := ip.String() useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if useProviderIP { diff --git a/internal/provider/providers/easydns/provider.go b/internal/provider/providers/easydns/provider.go index 86bab4642..335332e52 100644 --- a/internal/provider/providers/easydns/provider.go +++ b/internal/provider/providers/easydns/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -28,7 +28,7 @@ type Provider struct { useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -42,7 +42,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -67,15 +67,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.EasyDNS, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.EasyDNS, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -91,13 +91,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "EasyDNS", IPVersion: p.ipVersion.String(), } @@ -112,12 +112,12 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add User: url.UserPassword(p.username, p.token), } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { values.Set("myip", ip.String()) } - if p.host == "*" { + if p.owner == "*" { values.Set("wildcard", "ON") } u.RawQuery = values.Encode() diff --git a/internal/provider/providers/example/provider.go b/internal/provider/providers/example/provider.go index e06aaa0a6..d325b590f 100644 --- a/internal/provider/providers/example/provider.go +++ b/internal/provider/providers/example/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string // TODO: remove ipVersion and ipv6Suffix if the provider does not support IPv6. // Usually they do support IPv6 though. ipVersion ipversion.IPVersion @@ -29,7 +29,7 @@ type Provider struct { password string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( provider *Provider, err error) { var providerSpecificSettings settings @@ -38,14 +38,14 @@ func New(data json.RawMessage, domain, host string, return nil, fmt.Errorf("decoding provider specific settings: %w", err) } - err = validateSettings(providerSpecificSettings, domain, host) + err = validateSettings(providerSpecificSettings, domain, owner) if err != nil { return nil, fmt.Errorf("validating provider specific settings: %w", err) } return &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: providerSpecificSettings.Username, @@ -59,7 +59,7 @@ type settings struct { Password string `json:"password"` } -func validateSettings(providerSpecificSettings settings, domain, host string) error { +func validateSettings(providerSpecificSettings settings, domain, owner string) error { // TODO: update this switch to be as restrictive as possible // to fail early for the user. Use errors already defined // in the internal/provider/errors package, or add your own @@ -68,11 +68,11 @@ func validateSettings(providerSpecificSettings settings, domain, host string) er switch { case domain == "": return fmt.Errorf("%w", errors.ErrDomainNotSet) - case host == "": - return fmt.Errorf("%w", errors.ErrHostNotSet) - // TODO: does the provider support wildcard hosts? If not, disallow * hosts - // case host == "*": - // return fmt.Errorf("%w", errors.ErrHostWildcard) + case owner == "": + return fmt.Errorf("%w", errors.ErrOwnerNotSet) + // TODO: does the provider support wildcard owners? If not, disallow * owners + // case owner == "*": + // return fmt.Errorf("%w", errors.ErrOwnerWildcard) case providerSpecificSettings.Username == "": return fmt.Errorf("%w", errors.ErrUsernameNotSet) case providerSpecificSettings.Password == "": @@ -84,15 +84,15 @@ func validateSettings(providerSpecificSettings settings, domain, host string) er func (p *Provider) String() string { // TODO update the name of the provider and add it to the // internal/provider/constants package. - return utils.ToString(p.domain, p.host, constants.Dyn, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Dyn, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -108,13 +108,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), // TODO: update the provider name and link below Provider: "Dyn DNS", IPVersion: p.ipVersion.String(), @@ -132,7 +132,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/nic/update", } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) values.Set("myip", ip.String()) u.RawQuery = values.Encode() diff --git a/internal/provider/providers/freedns/provider.go b/internal/provider/providers/freedns/provider.go index 89248ac5c..93ae37a8c 100644 --- a/internal/provider/providers/freedns/provider.go +++ b/internal/provider/providers/freedns/provider.go @@ -20,13 +20,13 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix token string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -38,7 +38,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, token: extraSettings.Token, @@ -58,15 +58,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.FreeDNS, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.FreeDNS, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) Proxied() bool { @@ -82,13 +82,13 @@ func (p *Provider) IPv6Suffix() netip.Prefix { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "FreeDNS", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/gandi/provider.go b/internal/provider/providers/gandi/provider.go index 2d0673797..9935f9bee 100644 --- a/internal/provider/providers/gandi/provider.go +++ b/internal/provider/providers/gandi/provider.go @@ -19,7 +19,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix ttl uint32 @@ -32,7 +32,7 @@ type Provider struct { apiKey string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -46,7 +46,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, personalAccessToken: extraSettings.PersonalAccessToken, @@ -68,15 +68,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Gandi, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Gandi, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -92,13 +92,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "gandi", IPVersion: p.ipVersion.String(), } @@ -113,7 +113,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add u := url.URL{ Scheme: "https", Host: "dns.api.gandi.net", - Path: fmt.Sprintf("/api/v5/domains/%s/records/%s/%s", p.domain, p.host, recordType), + Path: fmt.Sprintf("/api/v5/domains/%s/records/%s/%s", p.domain, p.owner, recordType), } buffer := bytes.NewBuffer(nil) diff --git a/internal/provider/providers/gcp/provider.go b/internal/provider/providers/gcp/provider.go index 4669b1cec..641e8a0d5 100644 --- a/internal/provider/providers/gcp/provider.go +++ b/internal/provider/providers/gcp/provider.go @@ -14,7 +14,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix project string @@ -22,7 +22,7 @@ type Provider struct { credentials json.RawMessage } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { var extraSettings struct { @@ -38,7 +38,7 @@ func New(data json.RawMessage, domain, host string, p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, project: extraSettings.Project, @@ -79,15 +79,15 @@ func (p *Provider) isValid() (err error) { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.GCP, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.GCP, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -103,13 +103,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Google Cloud", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/gcp/update.go b/internal/provider/providers/gcp/update.go index 20919c5e5..64249b95f 100644 --- a/internal/provider/providers/gcp/update.go +++ b/internal/provider/providers/gcp/update.go @@ -22,7 +22,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add return netip.Addr{}, fmt.Errorf("creating OAuth2 client: %w", err) } - fqdn := fmt.Sprintf("%s.%s.", p.host, p.domain) + fqdn := fmt.Sprintf("%s.%s.", p.owner, p.domain) recordResourceSet, err := p.getRRSet(ctx, client, fqdn, recordType) rrSetFound := true diff --git a/internal/provider/providers/godaddy/provider.go b/internal/provider/providers/godaddy/provider.go index eb8ca56bf..4c1dd029c 100644 --- a/internal/provider/providers/godaddy/provider.go +++ b/internal/provider/providers/godaddy/provider.go @@ -21,14 +21,14 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix key string secret string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -41,7 +41,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, key: extraSettings.Key, @@ -68,15 +68,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.GoDaddy, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.GoDaddy, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -92,13 +92,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "GoDaddy", IPVersion: p.ipVersion.String(), } @@ -115,7 +115,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add u := url.URL{ Scheme: "https", Host: "api.godaddy.com", - Path: fmt.Sprintf("/v1/domains/%s/records/%s/%s", p.domain, recordType, p.host), + Path: fmt.Sprintf("/v1/domains/%s/records/%s/%s", p.domain, recordType, p.owner), } buffer := bytes.NewBuffer(nil) diff --git a/internal/provider/providers/goip/provider.go b/internal/provider/providers/goip/provider.go index 791a53e88..a40752426 100644 --- a/internal/provider/providers/goip/provider.go +++ b/internal/provider/providers/goip/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -30,7 +30,7 @@ type Provider struct { const defaultDomain = "goip.de" -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { if domain == "" { @@ -48,7 +48,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -71,22 +71,22 @@ func (p *Provider) isValid() error { case p.domain != defaultDomain && p.domain != "goip.it": return fmt.Errorf(`%w: %q must be "goip.de" or "goip.it"`, errors.ErrDomainNotValid, p.domain) - case p.host == "@" || p.host == "*": - return fmt.Errorf("%w: host %q is not valid", errors.ErrHostOnlySubdomain, p.host) + case p.owner == "@" || p.owner == "*": + return fmt.Errorf("%w: %q", errors.ErrOwnerRootOrWildcard, p.owner) } return nil } func (p *Provider) String() string { - return utils.ToString(p.host, p.domain, constants.GoIP, p.ipVersion) + return utils.ToString(p.owner, p.domain, constants.GoIP, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -102,13 +102,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "" + p.domain + "", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/he/provider.go b/internal/provider/providers/he/provider.go index ba17f2767..a65522b6d 100644 --- a/internal/provider/providers/he/provider.go +++ b/internal/provider/providers/he/provider.go @@ -21,14 +21,14 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix password string useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -41,7 +41,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, password: extraSettings.Password, @@ -62,15 +62,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.HE, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.HE, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -86,13 +86,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "he.net", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/hetzner/create.go b/internal/provider/providers/hetzner/create.go index 63691e4dd..fb164e498 100644 --- a/internal/provider/providers/hetzner/create.go +++ b/internal/provider/providers/hetzner/create.go @@ -34,7 +34,7 @@ func (p *Provider) createRecord(ctx context.Context, client *http.Client, ip net TTL uint32 `json:"ttl"` }{ Type: recordType, - Name: p.host, + Name: p.owner, Value: ip.String(), ZoneIdentifier: p.zoneIdentifier, TTL: p.ttl, diff --git a/internal/provider/providers/hetzner/getrecord.go b/internal/provider/providers/hetzner/getrecord.go index 259c4bc66..f702c94fd 100644 --- a/internal/provider/providers/hetzner/getrecord.go +++ b/internal/provider/providers/hetzner/getrecord.go @@ -29,7 +29,7 @@ func (p *Provider) getRecordID(ctx context.Context, client *http.Client, ip neti values := url.Values{} values.Set("zone_id", p.zoneIdentifier) - values.Set("name", p.host) + values.Set("name", p.owner) values.Set("type", recordType) values.Set("page", "1") values.Set("per_page", "1") diff --git a/internal/provider/providers/hetzner/provider.go b/internal/provider/providers/hetzner/provider.go index 742f82405..a04a99500 100644 --- a/internal/provider/providers/hetzner/provider.go +++ b/internal/provider/providers/hetzner/provider.go @@ -17,7 +17,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix token string @@ -25,7 +25,7 @@ type Provider struct { ttl uint32 } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -39,7 +39,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, token: extraSettings.Token, @@ -67,15 +67,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Hetzner, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Hetzner, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -91,13 +91,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Hetzner", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/hetzner/update.go b/internal/provider/providers/hetzner/update.go index 02d450694..c3954512e 100644 --- a/internal/provider/providers/hetzner/update.go +++ b/internal/provider/providers/hetzner/update.go @@ -35,7 +35,7 @@ func (p *Provider) updateRecord(ctx context.Context, client *http.Client, TTL uint32 `json:"ttl"` }{ Type: recordType, - Name: p.host, + Name: p.owner, Value: ip.String(), ZoneIdentifier: p.zoneIdentifier, TTL: p.ttl, diff --git a/internal/provider/providers/infomaniak/provider.go b/internal/provider/providers/infomaniak/provider.go index b1cb45c8f..1bf6c2b73 100644 --- a/internal/provider/providers/infomaniak/provider.go +++ b/internal/provider/providers/infomaniak/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -28,7 +28,7 @@ type Provider struct { useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -42,7 +42,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -62,22 +62,22 @@ func (p *Provider) isValid() error { return fmt.Errorf("%w", errors.ErrUsernameNotSet) case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Infomaniak, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Infomaniak, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -93,13 +93,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Infomaniak", IPVersion: p.ipVersion.String(), } @@ -113,7 +113,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add User: url.UserPassword(p.username, p.password), } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { values.Set("myip", ip.String()) diff --git a/internal/provider/providers/inwx/provider.go b/internal/provider/providers/inwx/provider.go index 7006abb83..50ef04ff8 100644 --- a/internal/provider/providers/inwx/provider.go +++ b/internal/provider/providers/inwx/provider.go @@ -20,14 +20,14 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string password string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -40,7 +40,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -64,15 +64,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.INWX, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.INWX, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -88,13 +88,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "INWX", IPVersion: p.ipVersion.String(), } @@ -108,7 +108,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/nic/update", } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) if ip.Is4() { values.Set("myip", ip.String()) } else { diff --git a/internal/provider/providers/ionos/create.go b/internal/provider/providers/ionos/create.go index 76a7f03e6..97cffd68a 100644 --- a/internal/provider/providers/ionos/create.go +++ b/internal/provider/providers/ionos/create.go @@ -31,7 +31,7 @@ func (p *Provider) createRecord(ctx context.Context, client *http.Client, const defaultPrio = 0 recordsList := []apiRecord{ { - Name: utils.BuildURLQueryHostname(p.host, p.domain), + Name: utils.BuildURLQueryHostname(p.owner, p.domain), Type: recordType, Content: ip.String(), TTL: defaultTTL, diff --git a/internal/provider/providers/ionos/provider.go b/internal/provider/providers/ionos/provider.go index 703e3d8b6..6bd5113a7 100644 --- a/internal/provider/providers/ionos/provider.go +++ b/internal/provider/providers/ionos/provider.go @@ -16,13 +16,13 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix apiKey string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -33,7 +33,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, apiKey: extraSettings.APIKey, @@ -52,15 +52,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Ionos, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Ionos, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -76,13 +76,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Ionos", IPVersion: p.ipVersion.String(), } @@ -121,7 +121,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add const usualRecordsCount = 1 matchingRecords := make([]apiRecord, 0, usualRecordsCount) - fullDomainName := utils.BuildURLQueryHostname(p.host, p.domain) + fullDomainName := utils.BuildURLQueryHostname(p.owner, p.domain) for _, record := range records { if record.Name == fullDomainName { matchingRecords = append(matchingRecords, record) diff --git a/internal/provider/providers/linode/provider.go b/internal/provider/providers/linode/provider.go index 1e13ce638..6cc40732d 100644 --- a/internal/provider/providers/linode/provider.go +++ b/internal/provider/providers/linode/provider.go @@ -21,13 +21,13 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix token string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -39,7 +39,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, token: extraSettings.Token, @@ -59,15 +59,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Linode, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Linode, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -83,13 +83,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Linode", IPVersion: p.ipVersion.String(), } @@ -239,7 +239,7 @@ func (p *Provider) getRecordID(ctx context.Context, client *http.Client, } for _, domainRecord := range obj.Data { - if domainRecord.Type == recordType && domainRecord.Host == p.host { + if domainRecord.Type == recordType && domainRecord.Host == p.owner { return domainRecord.ID, nil } } diff --git a/internal/provider/providers/luadns/provider.go b/internal/provider/providers/luadns/provider.go index eb3da698e..9a4e2fcb4 100644 --- a/internal/provider/providers/luadns/provider.go +++ b/internal/provider/providers/luadns/provider.go @@ -21,14 +21,14 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix email string token string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -41,7 +41,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, email: extraSettings.Email, @@ -70,15 +70,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.LuaDNS, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.LuaDNS, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -94,13 +94,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "LuaDNS", IPVersion: p.ipVersion.String(), } @@ -241,7 +241,7 @@ func (p *Provider) getRecord(ctx context.Context, client *http.Client, zoneID in if ip.Is6() { recordType = constants.AAAA } - recordName := utils.BuildURLQueryHostname(p.host, p.domain) + "." + recordName := utils.BuildURLQueryHostname(p.owner, p.domain) + "." for _, record := range records { if record.Type == recordType && record.Name == recordName { return record, nil diff --git a/internal/provider/providers/namecheap/provider.go b/internal/provider/providers/namecheap/provider.go index 9fc2078c4..08daee6e7 100644 --- a/internal/provider/providers/namecheap/provider.go +++ b/internal/provider/providers/namecheap/provider.go @@ -21,12 +21,12 @@ import ( type Provider struct { domain string - host string + owner string password string useProviderIP bool } -func New(data json.RawMessage, domain, host string) ( +func New(data json.RawMessage, domain, owner string) ( p *Provider, err error) { extraSettings := struct { Password string `json:"password"` @@ -38,7 +38,7 @@ func New(data json.RawMessage, domain, host string) ( } p = &Provider{ domain: domain, - host: host, + owner: owner, password: extraSettings.Password, useProviderIP: extraSettings.UseProviderIP, } @@ -60,15 +60,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Namecheap, ipversion.IP4) + return utils.ToString(p.domain, p.owner, constants.Namecheap, ipversion.IP4) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -84,13 +84,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Namecheap", IPVersion: ipversion.IP4.String(), } @@ -108,7 +108,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/update", } values := url.Values{} - values.Set("host", p.host) + values.Set("host", p.owner) values.Set("domain", p.domain) values.Set("password", p.password) if !p.useProviderIP { diff --git a/internal/provider/providers/namecom/createrecord.go b/internal/provider/providers/namecom/createrecord.go index 1ca571e6f..0310961b7 100644 --- a/internal/provider/providers/namecom/createrecord.go +++ b/internal/provider/providers/namecom/createrecord.go @@ -33,7 +33,7 @@ func (p *Provider) createRecord(ctx context.Context, client *http.Client, Answer string `json:"answer"` TTL *uint32 `json:"ttl,omitempty"` }{ - Host: p.host, + Host: p.owner, Type: recordType, Answer: ip.String(), TTL: p.ttl, diff --git a/internal/provider/providers/namecom/getrecord.go b/internal/provider/providers/namecom/getrecord.go index 1a575c9e3..25a3f8129 100644 --- a/internal/provider/providers/namecom/getrecord.go +++ b/internal/provider/providers/namecom/getrecord.go @@ -57,7 +57,7 @@ func (p *Provider) getRecordID(ctx context.Context, client *http.Client, if record.Host == "" { record.Host = "@" } - if record.Host == p.host && record.Type == recordType { + if record.Host == p.owner && record.Type == recordType { return record.RecordID, nil } } diff --git a/internal/provider/providers/namecom/provider.go b/internal/provider/providers/namecom/provider.go index d93489387..c0fa610ed 100644 --- a/internal/provider/providers/namecom/provider.go +++ b/internal/provider/providers/namecom/provider.go @@ -17,7 +17,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -25,7 +25,7 @@ type Provider struct { ttl *uint32 } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -51,7 +51,7 @@ func New(data json.RawMessage, domain, host string, return &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -61,15 +61,15 @@ func New(data json.RawMessage, domain, host string, } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.NameCom, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.NameCom, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -85,13 +85,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Name.com", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/namecom/updaterecord.go b/internal/provider/providers/namecom/updaterecord.go index d6db3691a..f3cdadf40 100644 --- a/internal/provider/providers/namecom/updaterecord.go +++ b/internal/provider/providers/namecom/updaterecord.go @@ -28,8 +28,8 @@ func (p *Provider) updateRecord(ctx context.Context, client *http.Client, } host := "" - if p.host != "@" { - host = p.host + if p.owner != "@" { + host = p.owner } postRecordsParams := struct { Host string `json:"host"` diff --git a/internal/provider/providers/netcup/provider.go b/internal/provider/providers/netcup/provider.go index 76ab444e6..dfcd70ce2 100644 --- a/internal/provider/providers/netcup/provider.go +++ b/internal/provider/providers/netcup/provider.go @@ -16,7 +16,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix customerNumber string @@ -24,7 +24,7 @@ type Provider struct { password string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { var extraSettings struct { @@ -39,7 +39,7 @@ func New(data json.RawMessage, domain, host string, p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, customerNumber: extraSettings.CustomerNumber, @@ -63,22 +63,22 @@ func (p *Provider) isValid() error { return fmt.Errorf("%w", errors.ErrAPIKeyNotSet) case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Netcup, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Netcup, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -94,13 +94,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Netcup.eu", IPVersion: p.ipVersion.String(), } @@ -132,7 +132,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add found := false for _, record = range updateResponse.DNSRecords { - if record.Hostname == p.host && record.Type == recordType { + if record.Hostname == p.owner && record.Type == recordType { found = true break } diff --git a/internal/provider/providers/netcup/update.go b/internal/provider/providers/netcup/update.go index 313dfe603..619e5ec61 100644 --- a/internal/provider/providers/netcup/update.go +++ b/internal/provider/providers/netcup/update.go @@ -23,14 +23,14 @@ func (p *Provider) getRecordToUpdate(ctx context.Context, } for _, record = range recordSet.DNSRecords { - if record.Hostname == p.host && record.Type == recordType { + if record.Hostname == p.owner && record.Type == recordType { record.Destination = ip.String() return record, nil } } return dnsRecord{ - Hostname: p.host, + Hostname: p.owner, Type: recordType, Destination: ip.String(), }, nil diff --git a/internal/provider/providers/njalla/provider.go b/internal/provider/providers/njalla/provider.go index 25a4a4353..276c1d6b9 100644 --- a/internal/provider/providers/njalla/provider.go +++ b/internal/provider/providers/njalla/provider.go @@ -18,14 +18,14 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix key string useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -38,7 +38,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, key: extraSettings.Key, @@ -59,15 +59,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Njalla, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Njalla, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -83,13 +83,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Njalla", IPVersion: p.ipVersion.String(), } @@ -102,7 +102,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/update", } values := url.Values{} - values.Set("h", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("h", utils.BuildURLQueryHostname(p.owner, p.domain)) values.Set("k", p.key) updatingIP6 := ip.Is6() useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) diff --git a/internal/provider/providers/noip/provider.go b/internal/provider/providers/noip/provider.go index 43154017d..e0dd7eaa4 100644 --- a/internal/provider/providers/noip/provider.go +++ b/internal/provider/providers/noip/provider.go @@ -21,7 +21,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -29,7 +29,7 @@ type Provider struct { useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -43,7 +43,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -66,22 +66,22 @@ func (p *Provider) isValid() error { return fmt.Errorf("%w: longer than 50 characters", errors.ErrUsernameNotValid) case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.NoIP, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.NoIP, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -97,13 +97,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "NoIP", IPVersion: p.ipVersion.String(), } @@ -117,7 +117,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add User: url.UserPassword(p.username, p.password), } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { // See https://help.dyn.com/remote-access-api/perform-update/ stating: diff --git a/internal/provider/providers/nowdns/provider.go b/internal/provider/providers/nowdns/provider.go index 9c35f843d..d690fb78f 100644 --- a/internal/provider/providers/nowdns/provider.go +++ b/internal/provider/providers/nowdns/provider.go @@ -72,7 +72,7 @@ func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { +func (p *Provider) Owner() string { return "@" } @@ -95,7 +95,7 @@ func (p *Provider) BuildDomainName() string { func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Now-DNS", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/opendns/provider.go b/internal/provider/providers/opendns/provider.go index 748f701e6..63f1b71d3 100644 --- a/internal/provider/providers/opendns/provider.go +++ b/internal/provider/providers/opendns/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -28,7 +28,7 @@ type Provider struct { useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -42,7 +42,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -62,22 +62,22 @@ func (p *Provider) isValid() error { return fmt.Errorf("%w", errors.ErrUsernameNotSet) case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.OpenDNS, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.OpenDNS, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -93,13 +93,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Opendns DNS", IPVersion: p.ipVersion.String(), } @@ -113,7 +113,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/nic/update", } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { values.Set("myip", ip.String()) diff --git a/internal/provider/providers/ovh/provider.go b/internal/provider/providers/ovh/provider.go index f3ca66475..0e3616b14 100644 --- a/internal/provider/providers/ovh/provider.go +++ b/internal/provider/providers/ovh/provider.go @@ -21,7 +21,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -36,7 +36,7 @@ type Provider struct { serverDelta time.Duration } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -61,7 +61,7 @@ func New(data json.RawMessage, domain, host string, p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -97,23 +97,23 @@ func (p *Provider) isValid() error { return fmt.Errorf("%w", errors.ErrUsernameNotSet) case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.OVH, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.OVH, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -129,13 +129,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "OVH DNS", IPVersion: p.ipVersion.String(), } @@ -151,7 +151,7 @@ func (p *Provider) updateWithDynHost(ctx context.Context, client *http.Client, } values := url.Values{} values.Set("system", "dyndns") - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { values.Set("myip", ip.String()) @@ -204,7 +204,7 @@ func (p *Provider) updateWithZoneDNS(ctx context.Context, client *http.Client, i recordType = constants.AAAA } // subDomain filter of the ovh api expect an empty string to get @ record - subDomain := p.host + subDomain := p.owner if subDomain == "@" { subDomain = "" } diff --git a/internal/provider/providers/porkbun/api.go b/internal/provider/providers/porkbun/api.go index 13473c5bf..e40dc17a3 100644 --- a/internal/provider/providers/porkbun/api.go +++ b/internal/provider/providers/porkbun/api.go @@ -20,8 +20,8 @@ func (p *Provider) getRecordIDs(ctx context.Context, client *http.Client, record Host: "porkbun.com", Path: "/api/json/v3/dns/retrieveByNameType/" + p.domain + "/" + recordType + "/", } - if p.host != "@" && p.host != "*" { - u.Path += p.host + if p.owner != "@" && p.owner != "*" { + u.Path += p.owner } postRecordsParams := struct { @@ -93,7 +93,7 @@ func (p *Provider) createRecord(ctx context.Context, client *http.Client, APIKey: p.apiKey, Content: ipStr, Type: recordType, - Name: p.host, + Name: p.owner, TTL: strconv.FormatUint(uint64(p.ttl), 10), } buffer := bytes.NewBuffer(nil) @@ -143,7 +143,7 @@ func (p *Provider) updateRecord(ctx context.Context, client *http.Client, Content: ipStr, Type: recordType, TTL: strconv.FormatUint(uint64(p.ttl), 10), - Name: p.host, + Name: p.owner, } buffer := bytes.NewBuffer(nil) encoder := json.NewEncoder(buffer) @@ -174,8 +174,8 @@ func (p *Provider) updateRecord(ctx context.Context, client *http.Client, // See https://porkbun.com/api/json/v3/documentation#DNS%20Delete%20Records%20by%20Domain,%20Subdomain%20and%20Type func (p *Provider) deleteAliasRecord(ctx context.Context, client *http.Client) (err error) { var subdomain string - if p.host != "@" { - subdomain = p.host + "." + if p.owner != "@" { + subdomain = p.owner + "." } u := url.URL{ Scheme: "https", diff --git a/internal/provider/providers/porkbun/provider.go b/internal/provider/providers/porkbun/provider.go index 34591f969..3cb6e0198 100644 --- a/internal/provider/providers/porkbun/provider.go +++ b/internal/provider/providers/porkbun/provider.go @@ -17,7 +17,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix ttl uint32 @@ -25,7 +25,7 @@ type Provider struct { secretAPIKey string } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -39,7 +39,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, secretAPIKey: extraSettings.SecretAPIKey, @@ -64,15 +64,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Porkbun, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Porkbun, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -88,13 +88,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Porkbun DNS", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/route53/provider.go b/internal/provider/providers/route53/provider.go index ceb075045..f9957a09a 100644 --- a/internal/provider/providers/route53/provider.go +++ b/internal/provider/providers/route53/provider.go @@ -21,7 +21,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix zoneID string @@ -36,7 +36,7 @@ type settings struct { TTL *uint32 `json:"ttl,omitempty"` } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( provider *Provider, err error) { var providerSpecificSettings settings @@ -45,7 +45,7 @@ func New(data json.RawMessage, domain, host string, return nil, fmt.Errorf("decoding provider specific settings: %w", err) } - err = validateSettings(providerSpecificSettings, domain, host) + err = validateSettings(providerSpecificSettings, domain, owner) if err != nil { return nil, fmt.Errorf("validating provider specific settings: %w", err) } @@ -71,7 +71,7 @@ func New(data json.RawMessage, domain, host string, return &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, signer: signer, @@ -80,12 +80,12 @@ func New(data json.RawMessage, domain, host string, }, nil } -func validateSettings(providerSpecificSettings settings, domain, host string) error { +func validateSettings(providerSpecificSettings settings, domain, owner string) error { switch { case domain == "": return fmt.Errorf("%w", errors.ErrDomainNotSet) - case host == "": - return fmt.Errorf("%w", errors.ErrHostNotSet) + case owner == "": + return fmt.Errorf("%w", errors.ErrOwnerNotSet) case providerSpecificSettings.AccessKey == "": return fmt.Errorf("%w", errors.ErrAccessKeyNotSet) case providerSpecificSettings.SecretKey == "": @@ -97,15 +97,15 @@ func validateSettings(providerSpecificSettings settings, domain, host string) er } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Route53, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Route53, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -121,13 +121,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Amazon Route 53", IPVersion: p.ipVersion.String(), } diff --git a/internal/provider/providers/selfhostde/provider.go b/internal/provider/providers/selfhostde/provider.go index 1dc4ab854..a7f0bbf98 100644 --- a/internal/provider/providers/selfhostde/provider.go +++ b/internal/provider/providers/selfhostde/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -28,7 +28,7 @@ type Provider struct { useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -42,7 +42,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -62,22 +62,22 @@ func (p *Provider) isValid() error { return fmt.Errorf("%w", errors.ErrUsernameNotSet) case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.SelfhostDe, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.SelfhostDe, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -93,13 +93,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Selfhost.de", IPVersion: p.ipVersion.String(), } @@ -113,7 +113,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/nic/update", } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { values.Set("myip", ip.String()) diff --git a/internal/provider/providers/servercow/provider.go b/internal/provider/providers/servercow/provider.go index 0fedff1fc..c3fb43764 100644 --- a/internal/provider/providers/servercow/provider.go +++ b/internal/provider/providers/servercow/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -29,8 +29,13 @@ type Provider struct { ttl uint32 } -func New(data json.RawMessage, domain, host string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { + // retro compatibility + if owner == "" { + owner = "@" + } + extraSettings := struct { Username string `json:"username"` Password string `json:"password"` @@ -44,7 +49,7 @@ func New(data json.RawMessage, domain, host string, ipVersion ipversion.IPVersio p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -60,27 +65,28 @@ func New(data json.RawMessage, domain, host string, ipVersion ipversion.IPVersio } func (p *Provider) isValid() error { + // v3: enforce owner is not empty switch { case p.username == "": return fmt.Errorf("%w", errors.ErrUsernameNotSet) case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case strings.Contains(p.host, "*"): - return fmt.Errorf("%w", errors.ErrHostWildcard) + case strings.Contains(p.owner, "*"): + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString("servercow.de", p.host, constants.Servercow, p.ipVersion) + return utils.ToString("servercow.de", p.owner, constants.Servercow, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -96,13 +102,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Servercow", IPVersion: p.ipVersion.String(), } @@ -119,9 +125,9 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/dns/v1/domains/" + p.domain, } - updateHost := p.host - if updateHost == "@" { - updateHost = "" + name := p.owner + if name == "@" { + name = "" } requestData := struct { @@ -131,7 +137,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add TTL uint32 `json:"ttl"` }{ Type: recordType, - Name: updateHost, + Name: name, Content: ip.String(), TTL: p.ttl, } diff --git a/internal/provider/providers/spdyn/provider.go b/internal/provider/providers/spdyn/provider.go index 4d34508e4..15f9d7e44 100644 --- a/internal/provider/providers/spdyn/provider.go +++ b/internal/provider/providers/spdyn/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix user string @@ -29,7 +29,7 @@ type Provider struct { useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -44,7 +44,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, user: extraSettings.User, @@ -69,22 +69,22 @@ func (p *Provider) isValid() error { } } - if p.host == "*" { - return fmt.Errorf("%w", errors.ErrHostWildcard) + if p.owner == "*" { + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Spdyn, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Spdyn, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -100,13 +100,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Spdyn DNS", IPVersion: p.ipVersion.String(), } @@ -119,7 +119,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Host: "update.spdyn.de", Path: "/nic/update", } - hostname := utils.BuildURLQueryHostname(p.host, p.domain) + hostname := utils.BuildURLQueryHostname(p.owner, p.domain) values := url.Values{} values.Set("hostname", hostname) if p.useProviderIP { diff --git a/internal/provider/providers/strato/provider.go b/internal/provider/providers/strato/provider.go index 9298ba08b..b5be5016a 100644 --- a/internal/provider/providers/strato/provider.go +++ b/internal/provider/providers/strato/provider.go @@ -20,14 +20,14 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix password string useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -40,7 +40,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, password: extraSettings.Password, @@ -57,22 +57,22 @@ func (p *Provider) isValid() error { switch { case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Strato, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Strato, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -88,13 +88,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Strato DNS", IPVersion: p.ipVersion.String(), } @@ -108,7 +108,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/nic/update", } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { values.Set("myip", ip.String()) diff --git a/internal/provider/providers/variomedia/provider.go b/internal/provider/providers/variomedia/provider.go index cfec7054a..6b91fee5f 100644 --- a/internal/provider/providers/variomedia/provider.go +++ b/internal/provider/providers/variomedia/provider.go @@ -20,7 +20,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix email string @@ -28,7 +28,7 @@ type Provider struct { useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -42,7 +42,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, email: extraSettings.Email, @@ -62,22 +62,22 @@ func (p *Provider) isValid() error { return fmt.Errorf("%w", errors.ErrEmailNotSet) case p.password == "": return fmt.Errorf("%w", errors.ErrPasswordNotSet) - case p.host == "*": - return fmt.Errorf("%w", errors.ErrHostWildcard) + case p.owner == "*": + return fmt.Errorf("%w", errors.ErrOwnerWildcard) } return nil } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Variomedia, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Variomedia, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -93,13 +93,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Variomedia", IPVersion: p.ipVersion.String(), } @@ -123,7 +123,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add Path: "/nic/update", } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) if !p.useProviderIP { values.Set("myip", ip.String()) } diff --git a/internal/provider/providers/zoneedit/provider.go b/internal/provider/providers/zoneedit/provider.go index 01f3a0cef..f7c02ea48 100644 --- a/internal/provider/providers/zoneedit/provider.go +++ b/internal/provider/providers/zoneedit/provider.go @@ -21,7 +21,7 @@ import ( type Provider struct { domain string - host string + owner string ipVersion ipversion.IPVersion ipv6Suffix netip.Prefix username string @@ -29,7 +29,7 @@ type Provider struct { useProviderIP bool } -func New(data json.RawMessage, domain, host string, +func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) ( p *Provider, err error) { extraSettings := struct { @@ -43,7 +43,7 @@ func New(data json.RawMessage, domain, host string, } p = &Provider{ domain: domain, - host: host, + owner: owner, ipVersion: ipVersion, ipv6Suffix: ipv6Suffix, username: extraSettings.Username, @@ -68,15 +68,15 @@ func (p *Provider) isValid() error { } func (p *Provider) String() string { - return utils.ToString(p.domain, p.host, constants.Zoneedit, p.ipVersion) + return utils.ToString(p.domain, p.owner, constants.Zoneedit, p.ipVersion) } func (p *Provider) Domain() string { return p.domain } -func (p *Provider) Host() string { - return p.host +func (p *Provider) Owner() string { + return p.owner } func (p *Provider) IPVersion() ipversion.IPVersion { @@ -92,13 +92,13 @@ func (p *Provider) Proxied() bool { } func (p *Provider) BuildDomainName() string { - return utils.BuildDomainName(p.host, p.domain) + return utils.BuildDomainName(p.owner, p.domain) } func (p *Provider) HTML() models.HTMLRow { return models.HTMLRow{ Domain: fmt.Sprintf("%s", p.BuildDomainName(), p.BuildDomainName()), - Host: p.Host(), + Owner: p.Owner(), Provider: "Zoneedit", IPVersion: p.ipVersion.String(), } @@ -113,12 +113,12 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add User: url.UserPassword(p.username, p.token), } values := url.Values{} - values.Set("hostname", utils.BuildURLQueryHostname(p.host, p.domain)) + values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain)) useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid()) if !useProviderIP { values.Set("myip", ip.String()) } - if p.host == "*" { + if p.owner == "*" { values.Set("wildcard", "ON") } u.RawQuery = values.Encode() diff --git a/internal/provider/utils/domain.go b/internal/provider/utils/domain.go index ba07fce03..cf69b426a 100644 --- a/internal/provider/utils/domain.go +++ b/internal/provider/utils/domain.go @@ -2,17 +2,17 @@ package utils import "strings" -func BuildDomainName(host, domain string) string { - if host == "@" { +func BuildDomainName(owner, domain string) string { + if owner == "@" { return domain } - host = strings.ReplaceAll(host, "*", "any") - return host + "." + domain + owner = strings.ReplaceAll(owner, "*", "any") + return owner + "." + domain } -func BuildURLQueryHostname(host, domain string) string { - if host == "@" { +func BuildURLQueryHostname(owner, domain string) string { + if owner == "@" { return domain } - return host + "." + domain + return owner + "." + domain } diff --git a/internal/provider/utils/provider.go b/internal/provider/utils/provider.go index ac5d0b385..eac9ba682 100644 --- a/internal/provider/utils/provider.go +++ b/internal/provider/utils/provider.go @@ -5,7 +5,7 @@ import ( "github.com/qdm12/ddns-updater/pkg/publicip/ipversion" ) -func ToString(domain, host string, provider models.Provider, ipVersion ipversion.IPVersion) string { - return "[domain: " + domain + " | host: " + host + " | provider: " + +func ToString(domain, owner string, provider models.Provider, ipVersion ipversion.IPVersion) string { + return "[domain: " + domain + " | owner: " + owner + " | provider: " + string(provider) + " | ip: " + ipVersion.String() + "]" } diff --git a/internal/server/ui/index.html b/internal/server/ui/index.html index 23fa7be1e..92c88fbfb 100644 --- a/internal/server/ui/index.html +++ b/internal/server/ui/index.html @@ -15,7 +15,7 @@ Domain - Host + Owner Provider IP Version Update Status @@ -27,7 +27,7 @@ {{range .Rows}} {{.Domain}} - {{.Host}} + {{.Owner}} {{.Provider}} {{.IPVersion}} {{.Status}} diff --git a/k8s/base/secret-config.yaml b/k8s/base/secret-config.yaml index 0b8d6e5fb..2323ae654 100644 --- a/k8s/base/secret-config.yaml +++ b/k8s/base/secret-config.yaml @@ -4,4 +4,4 @@ metadata: name: ddns-updater-config type: Opaque stringData: - CONFIG: '{"settings":[{"provider":"ddnss","provider_ip":true,"domain":"YOUR-DOMAIN","host":"@","username":"YOUR-USERNAME","password":"YOUR-PASSWORD","ip_version":"ipv4"}]}' + CONFIG: '{"settings":[{"provider":"ddnss","provider_ip":true,"domain":"YOUR-DOMAIN","owner":"@","username":"YOUR-USERNAME","password":"YOUR-PASSWORD","ip_version":"ipv4"}]}'