Updated GoDaddy to new IPv4/IPv6 logic. During testing a missing ip_strategie for old "use" was detected. Now old "use" can be set to "disabled" as well, to prevent a third lookup if "usev4" and "usev6" was enabled.

This commit is contained in:
Awalon 2022-08-16 05:39:55 +02:00
parent 36b8db950f
commit 7b245acf4f
No known key found for this signature in database
GPG key ID: 73C00BFA11FDC12E
2 changed files with 87 additions and 70 deletions

View file

@ -205,6 +205,16 @@ ssl=yes # use ssl-support. Works with
# ttl=3h \ # ttl=3h \
# myhost.example.com # myhost.example.com
##
## GoDaddy (godaddy.com)
##
# protocol=godaddy, \
# password=my-godaddy-api-key, \
# password=my-godaddy-secret, \
# ttl=600 \
# zone=example.com, \
# myhost.example.com,nexthost.example.com
## ##
## Google Domains (www.google.com/domains) ## Google Domains (www.google.com/domains)
## ##

View file

@ -360,6 +360,7 @@ my %builtinfw = (
my %ip_strategies = ( my %ip_strategies = (
'no' => ": deprecated, see 'usev4' and 'usev6'", 'no' => ": deprecated, see 'usev4' and 'usev6'",
'disabled' => ": deprecated, see 'usev4' and 'usev6'",
'ip' => ": deprecated, see 'usev4' and 'usev6'", 'ip' => ": deprecated, see 'usev4' and 'usev6'",
'web' => ": deprecated, see 'usev4' and 'usev6'", 'web' => ": deprecated, see 'usev4' and 'usev6'",
'fw' => ": deprecated, see 'usev4' and 'usev6'", 'fw' => ": deprecated, see 'usev4' and 'usev6'",
@ -5474,21 +5475,26 @@ sub nic_godaddy_update {
# Update each set configured host. # Update each set configured host.
for my $host (@hosts) { for my $host (@hosts) {
my $ip = delete $config{$host}{'wantip'}; my $ipv4 = delete $config{$host}{'wantipv4'};
my $ipv6 = delete $config{$host}{'wantipv6'};
my $zone = $config{$host}{'zone'}; my $zone = $config{$host}{'zone'};
(my $hostname = $host) =~ s/\.\Q$zone\E$//; (my $hostname = $host) =~ s/\.\Q$zone\E$//;
foreach my $ip ($ipv4, $ipv6) {
next if (!$ip);
info("%s.%s -- Setting IP address to %s.", $hostname, $zone, $ip); info("%s.%s -- Setting IP address to %s.", $hostname, $zone, $ip);
verbose("UPDATE:", "updating %s.%s", $hostname, $zone); verbose("UPDATE:", "updating %s.%s", $hostname, $zone);
my $ipversion = is_ipv6($ip) ? "6" : "4"; my $ipversion = ($ip eq ($ipv6 // '')) ? '6' : '4';
my $rrset_type = $ipversion == "6" ? "AAAA" : "A"; my $rrset_type = ($ipversion eq '6') ? 'AAAA' : 'A';
my $data = encode_json([{ my $data = encode_json([ {
data => $ip, data => $ip,
defined($config{$host}{'ttl'}) ? (ttl => $config{$host}{'ttl'}) : (), defined($config{$host}{'ttl'}) ? (ttl => $config{$host}{'ttl'}) : (),
name => $hostname, name => $hostname,
type => $rrset_type, type => $rrset_type,
}]); } ]);
my $url = "https://$config{$host}{'server'}"; my $url = "https://$config{$host}{'server'}";
$url .= "/${zone}/records/${rrset_type}/${hostname}"; $url .= "/${zone}/records/${rrset_type}/${hostname}";
@ -5512,7 +5518,7 @@ sub nic_godaddy_update {
my $ok = header_ok($host, $reply); my $ok = header_ok($host, $reply);
my $msg; my $msg;
$reply =~ s/^.*?\n\n//s; # extract payload $reply =~ s/^.*?\n\n//s; # extract payload
my $response = eval { decode_json($reply) }; my $response = eval {decode_json($reply)};
if (!defined($response) && $status != "200") { if (!defined($response) && $status != "200") {
$config{$host}{'status'} = "bad"; $config{$host}{'status'} = "bad";
@ -5522,9 +5528,9 @@ sub nic_godaddy_update {
} }
if ($ok) { if ($ok) {
# read data # read data
$config{$host}{'ip'} = $ip; $config{$host}{"ipv$ipversion"} = $ip;
$config{$host}{'mtime'} = $now; $config{$host}{'mtime'} = $now;
$config{$host}{'status'} = "good"; $config{$host}{"status-ipv$ipversion"} = 'good';
success("%s.%s -- Updated successfully to %s (status: %s).", $hostname, $zone, $ip, $status); success("%s.%s -- Updated successfully to %s (status: %s).", $hostname, $zone, $ip, $status);
next; next;
@ -5551,10 +5557,11 @@ sub nic_godaddy_update {
$msg = 'Unexpected service response.'; $msg = 'Unexpected service response.';
} }
$config{$host}{'status'} = "bad"; $config{$host}{"status-ipv$ipversion"} = 'bad';
failed("%s.%s -- %s", $hostname, $zone, $msg); failed("%s.%s -- %s", $hostname, $zone, $msg);
} }
} }
}
} }
###################################################################### ######################################################################