From 82bbb893873ad403c13687d8c117c7c3e01ec177 Mon Sep 17 00:00:00 2001 From: Monviech Date: Fri, 21 Feb 2025 20:56:31 +0000 Subject: [PATCH 1/5] www/caddy: Consolidate all selective DNS Provider logic to includeDnsProvider --- .../templates/OPNsense/Caddy/Caddyfile | 10 +++--- .../OPNsense/Caddy/includeDnsProvider | 33 +++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile index afe9898087..33ffc9cc03 100644 --- a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile +++ b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile @@ -174,12 +174,8 @@ {% endfor %} {% endfor %} - {# - # Define special DNS Providers that have more than one API key, or special requirements that do not allow the use of the default. - # The same providers have to be added to "OPNsense/Caddy/includeDnsProvider", best in the same order as in this array for maintainability. - # For a new provider to work, it has to be compiled into the caddy binary. - #} - {% set dnsProviderSpecialConfig = ['duckdns', 'porkbun', 'desec', 'route53', 'acmedns', 'googleclouddns', 'azure', 'ovh', 'namecheap', 'powerdns', 'ddnss', 'linode', 'tencentcloud', 'dinahosting', 'hexonet', 'mailinabox', 'netcup', 'rfc2136', 'dnsmadeeasy', 'civo', 'scaleway', 'acmeproxy', 'inwx', 'namedotcom', 'easydns', 'directadmin', 'cloudns'] %} + {% import "OPNsense/Caddy/includeDnsProvider" as dns_includes %} + {% set dnsProviderSpecialConfig = dns_includes.dnsProviderSpecialConfig() %} {# Conditionally add the dynamic_dns section, acmedns provider is special, it does not support dynamic_dns. #} {% if dnsProvider and dynDnsDomains|length > 0 and dnsProvider != "acmedns" %} @@ -187,6 +183,7 @@ {# duckdns provider is special, it has a different configuration for dynamic dns than for the dns-01 challenge. #} {% if dnsProvider in dnsProviderSpecialConfig and dnsProvider != "duckdns" %} provider {{ dnsProvider }} { + {% set context_var = 'dnsProviderSpecialLogic' %} {% include "OPNsense/Caddy/includeDnsProvider" %} } {% else %} @@ -332,6 +329,7 @@ http://{{ domain }} { tls {% if customCert %}/var/db/caddy/data/caddy/certificates/temp/{{ customCert }}.pem /var/db/caddy/data/caddy/certificates/temp/{{ customCert }}.key{% endif %} {% if not customCert and dnsChallenge == "1" and dnsProvider %}{ issuer acme { dns {{ dnsProvider }} {% if dnsProvider not in dnsProviderSpecialConfig %}{{ dnsApiKey }}{% else %}{ + {% set context_var = 'dnsProviderSpecialLogic' %} {% include "OPNsense/Caddy/includeDnsProvider" %} } {% endif %} diff --git a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider index e771a66b74..a590c3d578 100644 --- a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider +++ b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider @@ -6,6 +6,38 @@ # It only includes DNS Providers that need specific settings and do not default to # "dns {{ dnsProvider }} {{ dnsApiKey }}" #} +{% macro dnsProviderSpecialConfig() %} + [ + 'duckdns', + 'porkbun', + 'desec', + 'route53', + 'acmedns', + 'googleclouddns', + 'azure', + 'ovh', + 'namecheap', + 'powerdns', + 'ddnss', + 'linode', + 'tencentcloud', + 'dinahosting', + 'hexonet', + 'mailinabox', + 'netcup', + 'rfc2136', + 'dnsmadeeasy', + 'civo', + 'scaleway', + 'acmeproxy', + 'inwx', + 'namedotcom', + 'easydns', + 'directadmin', + 'cloudns' + ] +{% endmacro %} +{% if context_var == 'dnsProviderSpecialLogic' %} {% if dnsProvider == 'duckdns' %} {% if dnsApiKey %}api_token {{ dnsApiKey }} {% endif %} @@ -191,3 +223,4 @@ {% if dnsOptionalField1 %}sub_auth_id {{ dnsOptionalField1 }} {% endif %} {% endif %} +{% endif %} From dbaec278ac8498b3924f976c52230261ccebbe2a Mon Sep 17 00:00:00 2001 From: Monviech Date: Fri, 21 Feb 2025 21:29:53 +0000 Subject: [PATCH 2/5] www/caddy: Update list of DNS providers with optional remaining or new ones from caddy-dns --- .../mvc/app/models/OPNsense/Caddy/Caddy.xml | 27 ++++++ .../OPNsense/Caddy/includeDnsProvider | 90 ++++++++++++++++++- 2 files changed, 116 insertions(+), 1 deletion(-) diff --git a/www/caddy/src/opnsense/mvc/app/models/OPNsense/Caddy/Caddy.xml b/www/caddy/src/opnsense/mvc/app/models/OPNsense/Caddy/Caddy.xml index 7a851ce706..0a7fd90fd8 100644 --- a/www/caddy/src/opnsense/mvc/app/models/OPNsense/Caddy/Caddy.xml +++ b/www/caddy/src/opnsense/mvc/app/models/OPNsense/Caddy/Caddy.xml @@ -62,6 +62,33 @@ EasyDNS (optional) Hosttech (optional) ClouDNS (optional) + Gcore (optional) + Huawei Cloud (optional) + DNSExit (optional) + Nanelo (optional) + Katapult (optional) + Regfish (optional) + Leaseweb (optional) + DreamHost (optional) + Exoscale (optional) + TransIP (optional) + Selectel (optional) + DNSimple (optional) + LuaDNS (optional) + Hurricane Electric (optional) + Namesilo (optional) + Dode (optional) + Dynu (optional) + Glesys (optional) + NFSN (optional) + GoDaddy (optional) + Vercel (optional) + Loopia (optional) + DNSPod (optional) + Mythic Beasts (optional) + Dynv6 (optional) + AliDNS (optional) + Metaname (optional) diff --git a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider index a590c3d578..7444c46d4f 100644 --- a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider +++ b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider @@ -34,7 +34,22 @@ 'namedotcom', 'easydns', 'directadmin', - 'cloudns' + 'cloudns', + 'huaweicloud', + 'regfish', + 'dreamhost', + 'exoscale', + 'transip', + 'selectel', + 'luadns', + 'he', + 'dynu', + 'glesys', + 'nfsn', + 'loopia', + 'mythicbeasts', + 'alidns', + 'metaname' ] {% endmacro %} {% if context_var == 'dnsProviderSpecialLogic' %} @@ -222,5 +237,78 @@ {% endif %} {% if dnsOptionalField1 %}sub_auth_id {{ dnsOptionalField1 }} {% endif %} +{% elif dnsProvider == 'huaweicloud' %} + {% if dnsApiKey %}access_key_id {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}secret_access_key {{ dnsSecretApiKey }} + {% endif %} +{% elif dnsProvider == 'regfish' %} + {% if dnsApiKey %}api_key {{ dnsApiKey }} + {% endif %} +{% elif dnsProvider == 'dreamhost' %} + {% if dnsApiKey %}api_key {{ dnsApiKey }} + {% endif %} +{% elif dnsProvider == 'exoscale' %} + {% if dnsApiKey %}api_key {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}api_secret {{ dnsSecretApiKey }} + {% endif %} +{% elif dnsProvider == 'exoscale' %} + {% if dnsApiKey %}account_name {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}private_key_path {{ dnsSecretApiKey }} + {% endif %} +{% elif dnsProvider == 'selectel' %} + {% if dnsApiKey %}user {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}password {{ dnsSecretApiKey }} + {% endif %} + {% if dnsOptionalField1 %}account_id {{ dnsOptionalField1 }} + {% endif %} + {% if dnsOptionalField2 %}project_name {{ dnsOptionalField2 }} + {% endif %} +{% elif dnsProvider == 'luadns' %} + {% if dnsApiKey %}email {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}api_key {{ dnsSecretApiKey }} + {% endif %} +{% elif dnsProvider == 'he' %} + {% if dnsApiKey %}api_key {{ dnsApiKey }} + {% endif %} +{% elif dnsProvider == 'dynu' %} + {% if dnsApiKey %}api_token {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}own_domain {{ dnsSecretApiKey }} + {% endif %} +{% elif dnsProvider == 'dynu' %} + {% if dnsApiKey %}project {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}api_key {{ dnsSecretApiKey }} + {% endif %} +{% elif dnsProvider == 'nfsn' %} + {% if dnsApiKey %}login {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}api_key {{ dnsSecretApiKey }} + {% endif %} +{% elif dnsProvider == 'loopia' %} + {% if dnsApiKey %}username {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}password {{ dnsSecretApiKey }} + {% endif %} +{% elif dnsProvider == 'mythicbeasts' %} + {% if dnsApiKey %}key_id {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}secret {{ dnsSecretApiKey }} + {% endif %} +{% elif dnsProvider == 'alidns' %} + {% if dnsApiKey %}access_key_id {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}access_key_secret {{ dnsSecretApiKey }} + {% endif %} +{% elif dnsProvider == 'metaname' %} + {% if dnsApiKey %}api_key {{ dnsApiKey }} + {% endif %} + {% if dnsSecretApiKey %}account_reference {{ dnsSecretApiKey }} + {% endif %} {% endif %} {% endif %} From 9b1c1a6e9fbe29b9c2e8c820be0c7a5708a7679a Mon Sep 17 00:00:00 2001 From: Monviech Date: Fri, 21 Feb 2025 21:45:27 +0000 Subject: [PATCH 3/5] www/caddy: Change help text language strings for DNS Providers to multiple newlines to improve tracking changes and maintainability. I know it is bad for translation, but this stuff is not really for translation, it shows which fields are to be filled out for a chosen dns provider. --- .../OPNsense/Caddy/forms/general.xml | 130 +++++++++++++++++- 1 file changed, 123 insertions(+), 7 deletions(-) diff --git a/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml b/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml index 573fbce1d6..181b634577 100644 --- a/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml +++ b/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml @@ -108,7 +108,7 @@ caddy.general.TlsDnsProvider dropdown - + header @@ -118,37 +118,153 @@ caddy.general.TlsDnsApiKey text - + + + caddy.general.TlsDnsSecretApiKey text - + + + caddy.general.TlsDnsOptionalField1 text - + + + caddy.general.TlsDnsOptionalField2 text - + + + caddy.general.TlsDnsOptionalField3 text - + + + caddy.general.TlsDnsOptionalField4 text - + + + header From d59aad956e32bf092f97cb0ed3acf33917cacd72 Mon Sep 17 00:00:00 2001 From: Monviech Date: Sat, 22 Feb 2025 06:54:26 +0000 Subject: [PATCH 4/5] www/caddy: Add missing help text to providers, correct small template error. --- .../OPNsense/Caddy/forms/general.xml | 52 ++++++++++++++++--- .../OPNsense/Caddy/includeDnsProvider | 4 +- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml b/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml index 181b634577..ec42dd7b46 100644 --- a/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml +++ b/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml @@ -159,7 +159,33 @@ Hosttech "api_token", Vultr "api_token", Hetzner "api_token", - ClouDNS "auth_id". + ClouDNS "auth_id", + Gcore "api_token", + Huawei Cloud "access_key_id", + DNSExit "api_token", + Nanelo "api_token", + Katapult "api_token", + Regfish "api_key", + Leaseweb "api_token", + DreamHost "api_key", + Exoscale "api_key", + TransIP "account_name", + Selectel "user", + LuaDNS "email", + Hurricane Electric "api_key", + Namesilo "api_token", + Dode "api_token", + Dynu "api_token", + Glesys "project", + NFSN "login", + GoDaddy "api_token", + Vercel "api_token", + Loopia "username", + DNSPod "api_token", + Mythic Beasts "key_id", + Dynv6 "api_token", + AliDNS "access_key_id", + Metaname "api_key", ]]> @@ -193,7 +219,19 @@ Name.com "server", EasyDNS "api_key", DirectAdmin "user", - ClouDNS "auth_password". + ClouDNS "auth_password", + Huawei Cloud "secret_access_key", + Exoscale "api_secret", + TransIP "private_key_path", + Selectel "password", + LuaDNS "api_key", + Dynu "own_domain", + Glesys "api_key", + NFSN "api_key", + Loopia "password", + Mythic Beasts "secret", + AliDNS "access_key_secret", + Metaname "account_reference", ]]> @@ -220,7 +258,8 @@ EasyDNS "api_url", DirectAdmin "login_key", RFC2136 "key", - ClouDNS "sub_auth_id". + ClouDNS "sub_auth_id", + Selectel "account_id", ]]> @@ -239,7 +278,8 @@ DDNS "password", INWX "endpoint_url", DirectAdmin "insecure_requests", - RFC2136 "server". + RFC2136 "server", + Selectel "project_name", ]]> @@ -251,7 +291,7 @@ @@ -262,7 +302,7 @@ diff --git a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider index 7444c46d4f..aa76b2ef76 100644 --- a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider +++ b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/includeDnsProvider @@ -253,7 +253,7 @@ {% endif %} {% if dnsSecretApiKey %}api_secret {{ dnsSecretApiKey }} {% endif %} -{% elif dnsProvider == 'exoscale' %} +{% elif dnsProvider == 'transip' %} {% if dnsApiKey %}account_name {{ dnsApiKey }} {% endif %} {% if dnsSecretApiKey %}private_key_path {{ dnsSecretApiKey }} @@ -280,7 +280,7 @@ {% endif %} {% if dnsSecretApiKey %}own_domain {{ dnsSecretApiKey }} {% endif %} -{% elif dnsProvider == 'dynu' %} +{% elif dnsProvider == 'glesys' %} {% if dnsApiKey %}project {{ dnsApiKey }} {% endif %} {% if dnsSecretApiKey %}api_key {{ dnsSecretApiKey }} From 39daa034ba8d8082fd3c191cdd5d78460f4a676a Mon Sep 17 00:00:00 2001 From: Monviech Date: Sat, 22 Feb 2025 06:56:33 +0000 Subject: [PATCH 5/5] www/caddy: Make DNS Provider helptext clearer. --- .../mvc/app/controllers/OPNsense/Caddy/forms/general.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml b/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml index ec42dd7b46..88d4e7aab9 100644 --- a/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml +++ b/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/general.xml @@ -108,7 +108,7 @@ caddy.general.TlsDnsProvider dropdown - + header