]> git.proxmox.com Git - proxmox-acme.git/blobdiff - src/PVE/ACME/DNSChallenge.pm
move DNS plugin schema to separate JSON based file
[proxmox-acme.git] / src / PVE / ACME / DNSChallenge.pm
index 2bef36963f0ac2cc5b69d46031d8947415c98bec..9b2897001145c070f5e34a5e56295dfe4a5b32d8 100644 (file)
@@ -4,8 +4,12 @@ use strict;
 use warnings;
 
 use Digest::SHA qw(sha256);
+use JSON;
+
 use PVE::Tools;
 
+use PVE::ACME;
+
 use base qw(PVE::ACME::Challenge);
 
 my $ACME_PATH = '/usr/share/proxmox-acme/proxmox-acme';
@@ -18,142 +22,8 @@ sub type {
     return 'dns';
 }
 
-# describe the data schema of the supported plugins
-my $plugins = {
-    'acmedns' => {},
-    'acmeproxy' => {},
-    'active24' => {},
-    'ad' => {},
-    'ali' => {},
-    'autodns' => {},
-    'aws' => {},
-    'azure' => {},
-    'cf' => {},
-    'clouddns' => {},
-    'cloudns' => {},
-    'cn' => {},
-    'conoha' => {},
-    'constellix' => {},
-    'cx' => {},
-    'cyon' => {},
-    'da' => {},
-    'ddnss' => {},
-    'desec' => {},
-    'dgon' => {},
-    'dnsimple' => {},
-    'do' => {},
-    'doapi' => {},
-    'domeneshop' => {},
-    'dp' => {},
-    'dpi' => {},
-    'dreamhost' => {},
-    'duckdns' => {},
-    'durabledns' => {},
-    'dyn' => {},
-    'dynu' => {},
-    'dynv6' => {},
-    'easydns' => {},
-    'euserv' => {},
-    'exoscale' => {},
-    'freedns' => {},
-    'gandi_livedns' => {},
-    'gcloud' => {},
-    'gd' => {},
-    'gdnsdk' => {},
-    'he' => {},
-    'hexonet' => {},
-    'hostingde' => {},
-    'infoblox' => {},
-    'internetbs' => {},
-    'inwx' => {},
-    'ispconfig' => {},
-    'jd' => {},
-    'kas' => {},
-    'kinghost' => {},
-    'knot' => {},
-    'leaseweb' => {},
-    'lexicon' => {},
-    'linode' => {},
-    'linode_v4' => {},
-    'loopia' => {},
-    'lua' => {},
-    'maradns' => {},
-    'me' => {},
-    'miab' => {},
-    'misaka' => {},
-    'myapi' => {},
-    'mydevil' => {},
-    'mydnsjp' => {},
-    'namecheap' => {},
-    'namecom' => {},
-    'namesilo' => {},
-    'nederhost' => {},
-    'neodigit' => {},
-    'netcup' => {},
-    'nic' => {},
-    'nsd' => {},
-    'nsone' => {},
-    'nsupdate' => {},
-    'nw' => {},
-    'one' => {},
-    'online' => {},
-    'openprovider' => {},
-    'opnsense' => {},
-    'ovh' => {
-       'OVH_END_POINT' => {
-           description => "The OVH endpoint",
-           default => "ovh-eu",
-           optional => 1,
-           type => 'string',
-       },
-       'OVH_AK' => {
-           description => "The application key.",
-           type => 'string',
-       },
-       'OVH_AS' => {
-           description => "The application secret.",
-           type => 'string',
-       },
-       'OVH_CK' => {
-           description => "The consumer key.",
-           optional => 1,
-           type => 'string',
-       },
-    },
-    'pdns' => {
-       'PDNS_Url' => {
-           description => "The PowerDNS API endpoint.",
-           type => 'string',
-       },
-       'PDNS_ServerId'=> {
-           type => 'string',
-       },
-       'PDNS_Token'=> {
-           type => 'string',
-       },
-       'PDNS_Ttl'=> {
-           type => 'integer',
-       },
-    },
-    'pleskxml' => {},
-    'pointhq' => {},
-    'rackspace' => {},
-    'rcode0' => {},
-    'regru' => {},
-    'schlundtech' => {},
-    'selectel' => {},
-    'servercow' => {},
-    'tele3' => {},
-    'ultra' => {},
-    'unoeuro' => {},
-    'variomedia' => {},
-    'vscale' => {},
-    'vultr' => {},
-    'yandex' => {},
-    'zilore' => {},
-    'zone' => {},
-    'zonomi' => {},
-};
+my $DNS_API_CHALLENGE_SCHEMA_FN = '/usr/share/proxmox-acme/dns-challenge-schema.json';
+my $plugins = from_json(PVE::Tools::file_get_contents($DNS_API_CHALLENGE_SCHEMA_FN));
 
 sub get_supported_plugins {
     return $plugins;
@@ -237,10 +107,7 @@ sub setup {
     my $domain = $proxmox_acme_command->($self, $acme, $auth, $data, 'setup');
     print "Add TXT record: _acme-challenge.$domain\n";
 
-    # FIXME: probe ourself for propagation of TXT record, while not 100%
-    # failsafe it's good enough of a heuristic to do away with fixed sleep
-    # intervalls - original acme.sh employs that heuristic too.
-    my $delay = $data->{'validation-delay'} // 30;
+    my $delay = $data->{plugin}->{'validation-delay'} // 30;
     if ($delay > 0) {
        print "Sleeping $delay seconds to wait for TXT record propagation\n";
        sleep($delay); # don't care for EINTR