change(all): deprecate provider_ip config field

- change should not affect any existing configurations
- change solves issues with dual stack updates (#767)
- was unneeded and adds unneeded complexity
This commit is contained in:
Quentin McGaw
2024-07-26 07:51:52 +00:00
parent 6d70ca078c
commit 918df24488
47 changed files with 431 additions and 633 deletions

View File

@@ -9,7 +9,6 @@
"settings": [
{
"provider": "ddnss",
"provider_ip": true,
"domain": "domain.com",
"username": "user",
"password": "password",
@@ -29,7 +28,7 @@
### Optional parameters
- `"dual_stack"` can be set to `true` **if you have turn on dual stack for your record** to update both IPv4 and IPv6 addresses. Note it is ignored if `"provider_ip": true`. More precisely:
- `"dual_stack"` can be set to `true` **if you have turn on dual stack for your record** to update both IPv4 and IPv6 addresses. More precisely:
- if it is `false`, the updates are done using the `ip` parameter and only one IP address can be set (ipv4 or ipv6, whichever is last sent).
- if it is `true`, the updates are done using the `ip` and `ip6` parameters, for IPv4 and IPv6 respectively, and both can be set on the same record
- `"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`.

View File

@@ -12,8 +12,7 @@
"domain": "sub.dedyn.io",
"token": "token",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": false
"ipv6_suffix": ""
}
]
}
@@ -28,7 +27,6 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -12,7 +12,6 @@
"domain": "domain.com",
"username": "username",
"password": "password",
"provider_ip": true,
"ip_version": "ipv4",
"ipv6_suffix": ""
}
@@ -25,7 +24,6 @@
- `"domain"` is the domain to update. It can be `example.com` (root domain), `sub.example.com` (subdomain of `example.com`) or `*.example.com` for the wildcard.
- `"username"`
- `"password"`
- `"provider_ip"`
### Optional parameters

View File

@@ -12,8 +12,7 @@
"domain": "sub.duckdns.org",
"token": "token",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -28,7 +27,6 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (**NOT** your IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -14,8 +14,7 @@
"username": "username",
"password": "password",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -31,7 +30,6 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
- `"group"` specify the Group for which you want to set the IP (will update any domains and subdomains in the same group)
## Domain setup

View File

@@ -12,8 +12,7 @@
"domain": "domain.com",
"token": "token",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -28,6 +27,5 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -13,8 +13,7 @@
"username": "username",
"token": "token",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -30,6 +29,5 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -12,7 +12,6 @@
"domain": "mysubdomain.goip.de",
"username": "username",
"password": "password",
"provider_ip": true,
"ip_version": "",
"ipv6_suffix": ""
@@ -29,7 +28,6 @@
### Optional parameters
- `"domain"` is the domain name which can be `goip.de` or `goip.it`, and defaults to `goip.de` if left unset.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request. This is automatically disabled for an IPv6 public address since it is not supported.
- `"domain"` is the domain name which can be `goip.de` or `goip.it`, and defaults to `goip.de` if left unset. This is automatically disabled for an IPv6 public address since it is not supported.
- `"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`.
- `"ipv6_suffix"` is the IPv6 interface identifier suffix to use. It can be for example `0:0:0:0:72ad:8fbb:a54e:bedd/64`. If left empty, it defaults to no suffix and the raw public IPv6 address obtained is used in the record updating.

View File

@@ -11,7 +11,6 @@
"provider": "he",
"domain": "domain.com",
"password": "password",
"provider_ip": true,
"ip_version": "ipv4",
"ipv6_suffix": ""
}
@@ -28,6 +27,5 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -13,8 +13,7 @@
"username": "username",
"password": "password",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -30,7 +29,6 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -10,8 +10,7 @@
{
"provider": "namecheap",
"domain": "domain.com",
"password": "password",
"provider_ip": true
"password": "password"
}
]
}
@@ -24,8 +23,6 @@
### Optional parameters
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
Note that Namecheap only supports ipv4 addresses for now.
## Domain setup

View File

@@ -12,8 +12,7 @@
"domain": "domain.com",
"key": "key",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -28,7 +27,6 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -13,8 +13,7 @@
"username": "username",
"password": "password",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -30,6 +29,5 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -13,8 +13,7 @@
"username": "username",
"password": "password",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -30,6 +29,5 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -13,8 +13,7 @@
"username": "username",
"password": "password",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -42,7 +41,6 @@ The ZoneDNS implementation allows you to update any record name including *.your
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
- `"mode"` select between two modes, OVH's dynamic hosting service (`"dynamic"`) or OVH's API (`"api"`). Default is `"dynamic"`
## Domain setup

View File

@@ -12,7 +12,6 @@
"domain": "domain.com",
"username": "username",
"password": "password",
"provider_ip": true,
"ip_version": "ipv4",
"ipv6_suffix": ""
}
@@ -30,6 +29,5 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -13,7 +13,6 @@
"username": "servercow_username",
"password": "servercow_password",
"ttl": 600,
"provider_ip": true,
"ip_version": "ipv4",
"ipv6_suffix": ""
}
@@ -32,7 +31,6 @@
- `"ttl"` can be set to an integer value for record TTL in seconds (if not set the default is 120)
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -14,8 +14,7 @@
"password": "password",
"token": "token",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -38,4 +37,3 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (**not IPv6**)automatically when you send an update request, without sending the new IP address detected by the program in the request.

View File

@@ -12,8 +12,7 @@
"domain": "domain.com",
"password": "password",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -28,7 +27,6 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -13,8 +13,7 @@
"email": "email@domain.com",
"password": "password",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -30,7 +29,6 @@
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -19,8 +19,7 @@ set the environment variable as `PERIOD=11m` to check your public IP address and
"username": "username",
"token": "token",
"ip_version": "ipv4",
"ipv6_suffix": "",
"provider_ip": true
"ipv6_suffix": ""
}
]
}
@@ -36,7 +35,6 @@ set the environment variable as `PERIOD=11m` to check your public IP address and
- `"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.
- `"provider_ip"` can be set to `true` to let your DNS provider determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.
## Domain setup

View File

@@ -28,8 +28,7 @@ type commonSettings struct {
IPVersion string `json:"ip_version"`
IPv6Suffix netip.Prefix `json:"ipv6_suffix,omitempty"`
// Retro values for warnings
IPMethod *string `json:"ip_method,omitempty"`
Delay *uint64 `json:"delay,omitempty"`
ProviderIP *bool `json:"provider_ip,omitempty"`
}
// JSONProviders obtain the update settings from the JSON content,
@@ -196,6 +195,13 @@ func makeSettingsFromObject(common commonSettings, rawSettings json.RawMessage,
ipv6Suffix, ipVersion))
}
if common.ProviderIP != nil {
warning := fmt.Sprintf("for domain %s and ip version %s: "+
`the field "provider_ip" is deprecated and no longer used`,
domain, ipVersion)
warnings = append(warnings, warning)
}
providerName := models.Provider(common.Provider)
providers = make([]provider.Provider, len(owners))
for i, owner := range owners {

View File

@@ -20,22 +20,20 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -48,13 +46,12 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
}, nil
}
@@ -121,13 +118,10 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
values.Set("host", utils.BuildURLQueryHostname(p.owner, p.domain))
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
if ip.Is6() {
values.Set("myip6", ip.String())
} else {
values.Set("myip", ip.String())
}
if ip.Is6() {
values.Set("myip6", ip.String())
} else {
values.Set("myip", ip.String())
}
u.RawQuery = values.Encode()
@@ -185,7 +179,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
newIP = ips[0]
if !useProviderIP && ip.Compare(newIP) != 0 {
if ip.Compare(newIP) != 0 {
return netip.Addr{}, fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}

View File

@@ -17,22 +17,20 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
var providerSpecificSettings struct {
Username string `json:"username"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Password string `json:"password"`
}
err = json.Unmarshal(data, &providerSpecificSettings)
if err != nil {
@@ -46,13 +44,12 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: providerSpecificSettings.Username,
password: providerSpecificSettings.Password,
useProviderIP: providerSpecificSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: providerSpecificSettings.Username,
password: providerSpecificSettings.Password,
}, nil
}
@@ -118,10 +115,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain))
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
values.Set("ip", ip.String())
}
values.Set("ip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)

View File

@@ -19,20 +19,18 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
password string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -45,12 +43,11 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
password: extraSettings.Password,
}, nil
}
@@ -113,12 +110,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
values := url.Values{}
values.Set("hostname", p.BuildDomainName())
values.Set("password", p.password)
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if useProviderIP {
values.Set("ip", "auto")
} else {
values.Set("ip", ip.String())
}
values.Set("ip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)

View File

@@ -19,24 +19,22 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
dualStack bool
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
dualStack bool
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
DualStack bool `json:"dual_stack"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Password string `json:"password"`
DualStack bool `json:"dual_stack"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -49,14 +47,13 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
dualStack: extraSettings.DualStack,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
dualStack: extraSettings.DualStack,
}, nil
}
@@ -124,14 +121,11 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
values.Set("user", p.username)
values.Set("pwd", p.password)
values.Set("host", utils.BuildURLQueryHostname(p.owner, p.domain))
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
ipKey := "ip"
if p.dualStack && ip.Is6() { // ipv6 update for dual stack
ipKey = "ip6"
}
values.Set(ipKey, ip.String())
ipKey := "ip"
if p.dualStack && ip.Is6() { // ipv6 update for dual stack
ipKey = "ip6"
}
values.Set(ipKey, ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)

View File

@@ -19,20 +19,18 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
token string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
token string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Token string `json:"token"`
UseProviderIP bool `json:"provider_ip"`
Token string `json:"token"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -48,12 +46,11 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
token: extraSettings.Token,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
token: extraSettings.Token,
}, nil
}
@@ -115,10 +112,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain))
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if useProviderIP {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)

View File

@@ -20,22 +20,20 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -48,13 +46,12 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
}, nil
}
@@ -119,10 +116,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
User: url.UserPassword(p.username, p.password),
}
values := url.Values{}
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if useProviderIP {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
values.Set("wildcard", "NOCHG")
if p.owner == "*" {
values.Set("hostname", p.domain)
@@ -186,7 +180,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
newIP = ips[0]
if !useProviderIP && ip.Compare(newIP) != 0 {
if ip.Compare(newIP) != 0 {
return netip.Addr{}, fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}

View File

@@ -21,12 +21,11 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
token string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
token string
}
const eTLD = "duckdns.org"
@@ -52,8 +51,7 @@ func New(data json.RawMessage, domain, owner string,
}
extraSettings := struct {
Token string `json:"token"`
UseProviderIP bool `json:"provider_ip"`
Token string `json:"token"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -66,12 +64,11 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
token: extraSettings.Token,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
token: extraSettings.Token,
}, nil
}
@@ -145,13 +142,10 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
values.Set("verbose", "true")
values.Set("domains", p.BuildDomainName())
values.Set("token", p.token)
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
if ip.Is6() {
values.Set("ipv6", ip.String())
} else {
values.Set("ip", ip.String())
}
if ip.Is6() {
values.Set("ipv6", ip.String())
} else {
values.Set("ip", ip.String())
}
u.RawQuery = values.Encode()
@@ -195,7 +189,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
return netip.Addr{}, fmt.Errorf("%w", errors.ErrReceivedNoIP)
}
newIP = ips[0]
if !useProviderIP && newIP.Compare(ip) != 0 {
if newIP.Compare(ip) != 0 {
return netip.Addr{}, fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}

View File

@@ -19,24 +19,22 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
group string
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
group string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Group string `json:"group"`
Username string `json:"username"`
Password string `json:"password"`
Group string `json:"group"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -53,14 +51,13 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
group: extraSettings.Group,
username: extraSettings.Username,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
group: extraSettings.Group,
username: extraSettings.Username,
password: extraSettings.Password,
}, nil
}
@@ -130,13 +127,10 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
values.Set("location", p.group)
hostname := utils.BuildDomainName(p.owner, p.domain)
values.Set("hostname", hostname)
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
if ip.Is6() {
values.Set("myipv6", ip.String())
} else {
values.Set("myip", ip.String())
}
if ip.Is6() {
values.Set("myipv6", ip.String())
} else {
values.Set("myip", ip.String())
}
u.RawQuery = values.Encode()

View File

@@ -17,20 +17,18 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
token string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
token string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Token string `json:"token"`
UseProviderIP bool `json:"provider_ip"`
Token string `json:"token"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -43,12 +41,11 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
token: extraSettings.Token,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
token: extraSettings.Token,
}, nil
}
@@ -120,15 +117,10 @@ 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.owner, p.domain))
ipValue := ip.String()
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if useProviderIP {
ipValue = "auto"
}
if isIPv4 {
values.Set("ipv4", ipValue)
values.Set("ipv4", ip.String())
} else {
values.Set("ipv6", ipValue)
values.Set("ipv6", ip.String())
}
u.RawQuery = values.Encode()

View File

@@ -19,22 +19,20 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
token string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
token string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Token string `json:"token"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Token string `json:"token"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -47,13 +45,12 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
token: extraSettings.Token,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
token: extraSettings.Token,
}, nil
}
@@ -119,10 +116,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain))
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
if p.owner == "*" {
values.Set("wildcard", "ON")
}

View File

@@ -20,13 +20,12 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
}
const defaultDomain = "goip.de"
@@ -52,9 +51,8 @@ func New(data json.RawMessage, domain, owner string,
}
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -67,13 +65,12 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
}, nil
}
@@ -149,11 +146,8 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
values.Set("password", p.password)
values.Set("shortResponse", "true")
if ip.Is4() {
if !p.useProviderIP {
values.Set("ip", ip.String())
}
values.Set("ip", ip.String())
} else {
// IPv6 cannot be automatically detected
values.Set("ip6", ip.String())
}
u.RawQuery = values.Encode()

View File

@@ -20,20 +20,18 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
password string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -46,12 +44,11 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
password: extraSettings.Password,
}, nil
}
@@ -114,10 +111,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
values.Set("hostname", fqdn)
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
@@ -161,7 +155,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
newIP = ips[0]
if !useProviderIP && ip.Compare(newIP) != 0 {
if ip.Compare(newIP) != 0 {
return netip.Addr{}, fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}

View File

@@ -19,22 +19,20 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -47,13 +45,12 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
}, nil
}
@@ -120,10 +117,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain))
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
@@ -166,7 +160,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
if err != nil {
return netip.Addr{}, fmt.Errorf("%w: for response %q: %w",
errors.ErrIPReceivedMalformed, ipString, err)
} else if !useProviderIP && ip.Compare(newIP) != 0 {
} else if ip.Compare(newIP) != 0 {
return netip.Addr{}, fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}

View File

@@ -20,17 +20,15 @@ import (
)
type Provider struct {
domain string
owner string
password string
useProviderIP bool
domain string
owner string
password string
}
func New(data json.RawMessage, domain, owner string) (
p *Provider, err error) {
extraSettings := struct {
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -43,10 +41,9 @@ func New(data json.RawMessage, domain, owner string) (
}
return &Provider{
domain: domain,
owner: owner,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
password: extraSettings.Password,
}, nil
}
@@ -117,9 +114,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
values.Set("host", p.owner)
values.Set("domain", p.domain)
values.Set("password", p.password)
if !p.useProviderIP {
values.Set("ip", ip.String())
}
values.Set("ip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
@@ -168,7 +163,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
newIP, err = netip.ParseAddr(parsedXML.IP)
if err != nil {
return netip.Addr{}, fmt.Errorf("%w: %w", errors.ErrIPReceivedMalformed, err)
} else if !p.useProviderIP && ip.Compare(newIP) != 0 {
} else if ip.Compare(newIP) != 0 {
return netip.Addr{}, fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}

View File

@@ -17,20 +17,18 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
key string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
key string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Key string `json:"key"`
UseProviderIP bool `json:"provider_ip"`
Key string `json:"key"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -43,12 +41,11 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
key: extraSettings.Key,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
key: extraSettings.Key,
}, nil
}
@@ -111,15 +108,10 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
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())
if useProviderIP {
values.Set("auto", "")
if updatingIP6 {
values.Set("aaaa", ip.String())
} else {
if updatingIP6 {
values.Set("aaaa", ip.String())
} else {
values.Set("a", ip.String())
}
values.Set("a", ip.String())
}
u.RawQuery = values.Encode()
@@ -161,7 +153,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
newIP, err = netip.ParseAddr(ipString)
if err != nil {
return netip.Addr{}, fmt.Errorf("%w: %w", errors.ErrIPReceivedMalformed, err)
} else if !useProviderIP && ip.Compare(newIP) != 0 {
} else if ip.Compare(newIP) != 0 {
return netip.Addr{}, fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}

View File

@@ -20,47 +20,38 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
return nil, err
}
if ipVersion == ipversion.IP6 {
// Thanks to @NightFurySL2001
// See https://github.com/qdm12/ddns-updater/discussions/750
extraSettings.UseProviderIP = false
}
err = validateSettings(domain, owner, extraSettings.Username, extraSettings.Password)
if err != nil {
return nil, fmt.Errorf("validating provider specific settings: %w", err)
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
}, nil
}
@@ -130,13 +121,10 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
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:
// This authentication method supports both IPv6 and IPv4 addresses.
// Use commas to separate multiple IP addresses in the myip field.
values.Set("myip", ip.String())
}
// See https://help.dyn.com/remote-access-api/perform-update/ stating:
// This authentication method supports both IPv6 and IPv4 addresses.
// Use commas to separate multiple IP addresses in the myip field.
values.Set("myip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
@@ -190,15 +178,11 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
if len(ips) == 0 {
if useProviderIP {
// No returned ip address from noip server
return ip, nil
}
return netip.Addr{}, fmt.Errorf("%w", errors.ErrReceivedNoIP)
}
newIP = ips[0]
if !useProviderIP && ip.Compare(newIP) != 0 {
if ip.Compare(newIP) != 0 {
return netip.Addr{}, fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}

View File

@@ -19,21 +19,19 @@ import (
)
type Provider struct {
domain string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
domain string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
}
func New(data json.RawMessage, domain string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -46,12 +44,11 @@ func New(data json.RawMessage, domain string,
}
return &Provider{
domain: domain,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
}, nil
}
@@ -117,9 +114,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
values := url.Values{}
values.Set("hostname", p.domain)
if !p.useProviderIP || (ip.Is6() && p.ipv6Suffix.IsValid()) {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
if err != nil {
@@ -146,7 +141,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
newIP, err = netip.ParseAddr(ip.String())
if err != nil {
return netip.Addr{}, fmt.Errorf("%w: %w", errors.ErrIPReceivedMalformed, err)
} else if !p.useProviderIP && ip.Compare(newIP) != 0 {
} else if ip.Compare(newIP) != 0 {
return netip.Addr{}, fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}
@@ -155,7 +150,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
newIP, err = netip.ParseAddr(ip.String())
if err != nil {
return netip.Addr{}, fmt.Errorf("%w: in response %q", errors.ErrReceivedNoResult, s)
} else if !p.useProviderIP && ip.Compare(newIP) != 0 {
} else if ip.Compare(newIP) != 0 {
return netip.Addr{}, fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}

View File

@@ -19,22 +19,20 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -47,13 +45,12 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
}, nil
}
@@ -120,10 +117,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain))
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
@@ -155,7 +149,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
newIP, err = netip.ParseAddr(responseIPString)
if err != nil {
return netip.Addr{}, fmt.Errorf("%w: %w", errors.ErrIPReceivedMalformed, err)
} else if !useProviderIP && newIP.Compare(ip) != 0 {
} else if newIP.Compare(ip) != 0 {
return netip.Addr{}, fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}

View File

@@ -20,34 +20,32 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
mode string
apiURL *url.URL
appKey string
appSecret string
consumerKey string
timeNow func() time.Time
serverDelta time.Duration
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
mode string
apiURL *url.URL
appKey string
appSecret string
consumerKey string
timeNow func() time.Time
serverDelta time.Duration
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Mode string `json:"mode"`
APIEndpoint string `json:"api_endpoint"`
AppKey string `json:"app_key"`
AppSecret string `json:"app_secret"`
ConsumerKey string `json:"consumer_key"`
Username string `json:"username"`
Password string `json:"password"`
Mode string `json:"mode"`
APIEndpoint string `json:"api_endpoint"`
AppKey string `json:"app_key"`
AppSecret string `json:"app_secret"`
ConsumerKey string `json:"consumer_key"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -66,19 +64,18 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
mode: extraSettings.Mode,
apiURL: apiURL,
appKey: extraSettings.AppKey,
appSecret: extraSettings.AppSecret,
consumerKey: extraSettings.ConsumerKey,
timeNow: time.Now,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
mode: extraSettings.Mode,
apiURL: apiURL,
appKey: extraSettings.AppKey,
appSecret: extraSettings.AppSecret,
consumerKey: extraSettings.ConsumerKey,
timeNow: time.Now,
}, nil
}
@@ -159,10 +156,7 @@ func (p *Provider) updateWithDynHost(ctx context.Context, client *http.Client,
values := url.Values{}
values.Set("system", "dyndns")
values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain))
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)

View File

@@ -19,22 +19,20 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -47,13 +45,12 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
}, nil
}
@@ -120,10 +117,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain))
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)

View File

@@ -19,14 +19,13 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
useProviderIP bool
ttl uint32
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
password string
ttl uint32
}
func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
@@ -37,10 +36,9 @@ func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersi
}
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
TTL uint32 `json:"ttl"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Password string `json:"password"`
TTL uint32 `json:"ttl"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -53,14 +51,13 @@ func New(data json.RawMessage, domain, owner string, ipVersion ipversion.IPVersi
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
ttl: extraSettings.TTL,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
password: extraSettings.Password,
ttl: extraSettings.TTL,
}, nil
}

View File

@@ -19,24 +19,22 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
user string
password string
token string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
user string
password string
token string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
User string `json:"user"`
Password string `json:"password"`
Token string `json:"token"`
UseProviderIP bool `json:"provider_ip"`
User string `json:"user"`
Password string `json:"password"`
Token string `json:"token"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -49,14 +47,13 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
user: extraSettings.User,
password: extraSettings.Password,
token: extraSettings.Token,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
user: extraSettings.User,
password: extraSettings.Password,
token: extraSettings.Token,
}, nil
}
@@ -129,11 +126,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
hostname := utils.BuildURLQueryHostname(p.owner, p.domain)
values := url.Values{}
values.Set("hostname", hostname)
if p.useProviderIP {
values.Set("myip", "10.0.0.1")
} else {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
if p.token != "" {
values.Set("user", hostname)
values.Set("pass", p.token)

View File

@@ -19,20 +19,18 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
password string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -45,12 +43,11 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
password: extraSettings.Password,
}, nil
}
@@ -115,10 +112,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain))
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)

View File

@@ -19,22 +19,20 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
email string
password string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
email string
password string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Email string `json:"email"`
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Email string `json:"email"`
Password string `json:"password"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -47,13 +45,12 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
email: extraSettings.Email,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
email: extraSettings.Email,
password: extraSettings.Password,
}, nil
}
@@ -112,14 +109,9 @@ func (p *Provider) HTML() models.HTMLRow {
}
func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Addr) (newIP netip.Addr, err error) {
host := "dyndns.variomedia.de"
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if useProviderIP {
if ip.Is6() {
host = "dyndns6.variomedia.de"
} else {
host = "dyndns4.variomedia.de"
}
host := "dyndns4.variomedia.de"
if ip.Is6() {
host = "dyndns6.variomedia.de"
}
u := url.URL{
@@ -130,9 +122,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain))
if !p.useProviderIP {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
u.RawQuery = values.Encode()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)

View File

@@ -20,22 +20,20 @@ import (
)
type Provider struct {
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
token string
useProviderIP bool
domain string
owner string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
username string
token string
}
func New(data json.RawMessage, domain, owner string,
ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Token string `json:"token"`
UseProviderIP bool `json:"provider_ip"`
Username string `json:"username"`
Token string `json:"token"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
@@ -48,13 +46,12 @@ func New(data json.RawMessage, domain, owner string,
}
return &Provider{
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
token: extraSettings.Token,
useProviderIP: extraSettings.UseProviderIP,
domain: domain,
owner: owner,
ipVersion: ipVersion,
ipv6Suffix: ipv6Suffix,
username: extraSettings.Username,
token: extraSettings.Token,
}, nil
}
@@ -120,10 +117,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}
values := url.Values{}
values.Set("hostname", utils.BuildURLQueryHostname(p.owner, p.domain))
useProviderIP := p.useProviderIP && (ip.Is4() || !p.ipv6Suffix.IsValid())
if !useProviderIP {
values.Set("myip", ip.String())
}
values.Set("myip", ip.String())
if p.owner == "*" {
values.Set("wildcard", "ON")
}