diff --git a/docs/custom.md b/docs/custom.md index 65753e13..10e2e96c 100644 --- a/docs/custom.md +++ b/docs/custom.md @@ -30,8 +30,8 @@ Feel free to open issues to extend its configuration options. - `"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. - `"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. +- `"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`. In the rare case you do not wish to send an IPv4 query parameter to the registrar API when updating your A (IPv4) record, leave it to `"ipv4key": ""`. +- `"ipv6key"` is the URL query parameter name for the IPv6 address, for example `ipv6` will be added to the URL with `&ipv6=::aaff`. In the rare case you do not wish to send an IPv6 query parameter to the registrar API when updating your AAAA (IPv6) record, leave it to `"ipv6key": ""`. - `"success_regex"` is a regular expression to match the response from the server to determine if the update was successful. You can use [regex101.com](https://regex101.com/) to find the regular expression you want. For example `good` would match any response containing the word "good". ### Optional parameters diff --git a/internal/provider/errors/validation.go b/internal/provider/errors/validation.go index 6d930a77..9a11ca99 100644 --- a/internal/provider/errors/validation.go +++ b/internal/provider/errors/validation.go @@ -19,8 +19,6 @@ var ( ErrGCPProjectNotSet = errors.New("GCP project is not set") ErrDomainNotValid = errors.New("domain is not valid") 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") ErrKeyNotValid = errors.New("key is not valid") ErrPasswordNotSet = errors.New("password is not set") diff --git a/internal/provider/providers/custom/provider.go b/internal/provider/providers/custom/provider.go index 92cc72c1..514ce7df 100644 --- a/internal/provider/providers/custom/provider.go +++ b/internal/provider/providers/custom/provider.go @@ -49,7 +49,7 @@ func New(data json.RawMessage, domain, owner string, return nil, fmt.Errorf("parsing URL: %w", err) } - err = validateSettings(domain, parsedURL, extraSettings.IPv4Key, extraSettings.IPv6Key, extraSettings.SuccessRegex) + err = validateSettings(domain, parsedURL, extraSettings.SuccessRegex) if err != nil { return nil, fmt.Errorf("validating provider specific settings: %w", err) } @@ -67,7 +67,7 @@ func New(data json.RawMessage, domain, owner string, } func validateSettings(domain string, url *url.URL, - ipv4Key, ipv6Key string, successRegex regexp.Regexp, + successRegex regexp.Regexp, ) (err error) { err = utils.CheckDomain(domain) if err != nil { @@ -79,10 +79,6 @@ func validateSettings(domain string, url *url.URL, return fmt.Errorf("%w", errors.ErrURLNotSet) case url.Scheme != "https": return fmt.Errorf("%w: %s", errors.ErrURLNotHTTPS, url.Scheme) - case ipv4Key == "": - return fmt.Errorf("%w", errors.ErrIPv4KeyNotSet) - case ipv6Key == "": - return fmt.Errorf("%w", errors.ErrIPv6KeyNotSet) case successRegex.String() == "": return fmt.Errorf("%w", errors.ErrSuccessRegexNotSet) default: @@ -138,7 +134,9 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add if ip.Is6() { ipKey = p.ipv6Key } - values.Set(ipKey, ip.String()) + if ipKey != "" { + values.Set(ipKey, ip.String()) + } p.url.RawQuery = values.Encode() request, err := http.NewRequestWithContext(ctx, http.MethodGet, p.url.String(), nil)