From ca18391d258a6809e671248b576f3575b0fa1565 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 24 Aug 2022 21:32:39 +0200 Subject: [PATCH] loopia: add configuratble API endpoint (#1704) --- cmd/zz_gen_cmd_dnshelp.go | 1 + docs/content/dns/zz_gen_loopia.md | 1 + providers/dns/loopia/loopia.go | 7 ++++++- providers/dns/loopia/loopia.toml | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/zz_gen_cmd_dnshelp.go b/cmd/zz_gen_cmd_dnshelp.go index 2c083c1f..cc847119 100644 --- a/cmd/zz_gen_cmd_dnshelp.go +++ b/cmd/zz_gen_cmd_dnshelp.go @@ -1390,6 +1390,7 @@ func displayDNSHelp(name string) error { ew.writeln() ew.writeln(`Additional Configuration:`) + ew.writeln(` - "LOOPIA_API_URL": API endpoint. Ex: https://api.loopia.se/RPCSERV or https://api.loopia.rs/RPCSERV`) ew.writeln(` - "LOOPIA_HTTP_TIMEOUT": API request timeout`) ew.writeln(` - "LOOPIA_POLLING_INTERVAL": Time between DNS propagation check`) ew.writeln(` - "LOOPIA_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`) diff --git a/docs/content/dns/zz_gen_loopia.md b/docs/content/dns/zz_gen_loopia.md index 1769b68e..013c51e1 100644 --- a/docs/content/dns/zz_gen_loopia.md +++ b/docs/content/dns/zz_gen_loopia.md @@ -49,6 +49,7 @@ More information [here]({{< ref "dns#configuration-and-credentials" >}}). | Environment Variable Name | Description | |--------------------------------|-------------| +| `LOOPIA_API_URL` | API endpoint. Ex: https://api.loopia.se/RPCSERV or https://api.loopia.rs/RPCSERV | | `LOOPIA_HTTP_TIMEOUT` | API request timeout | | `LOOPIA_POLLING_INTERVAL` | Time between DNS propagation check | | `LOOPIA_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation | diff --git a/providers/dns/loopia/loopia.go b/providers/dns/loopia/loopia.go index 639a9872..446ce228 100644 --- a/providers/dns/loopia/loopia.go +++ b/providers/dns/loopia/loopia.go @@ -22,6 +22,7 @@ const ( EnvAPIUser = envNamespace + "API_USER" EnvAPIPassword = envNamespace + "API_PASSWORD" + EnvAPIURL = envNamespace + "API_URL" EnvTTL = envNamespace + "TTL" EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT" @@ -50,7 +51,6 @@ type Config struct { // NewDefaultConfig returns a default configuration for the DNSProvider. func NewDefaultConfig() *Config { return &Config{ - BaseURL: internal.DefaultBaseURL, TTL: env.GetOrDefaultInt(EnvTTL, minTTL), PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 40*time.Minute), PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 60*time.Second), @@ -83,6 +83,7 @@ func NewDNSProvider() (*DNSProvider, error) { config := NewDefaultConfig() config.APIUser = values[EnvAPIUser] config.APIPassword = values[EnvAPIPassword] + config.BaseURL = env.GetOrDefaultString(EnvAPIURL, internal.DefaultBaseURL) return NewDNSProviderConfig(config) } @@ -108,6 +109,10 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { client.HTTPClient = config.HTTPClient } + if config.BaseURL != "" { + client.BaseURL = config.BaseURL + } + return &DNSProvider{ config: config, client: client, diff --git a/providers/dns/loopia/loopia.toml b/providers/dns/loopia/loopia.toml index 471b815a..e0a75eff 100644 --- a/providers/dns/loopia/loopia.toml +++ b/providers/dns/loopia/loopia.toml @@ -28,6 +28,7 @@ It needs to have the following permissions: LOOPIA_API_USER = "API username" LOOPIA_API_PASSWORD = "API password" [Configuration.Additional] + LOOPIA_API_URL = "API endpoint. Ex: https://api.loopia.se/RPCSERV or https://api.loopia.rs/RPCSERV" LOOPIA_POLLING_INTERVAL = "Time between DNS propagation check" LOOPIA_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation" LOOPIA_TTL = "The TTL of the TXT record used for the DNS challenge"