Pull request #560: Updated GoDaddy to new IPv4/IPv6 logic
Changes by Lenard Hess based on Awalon's pull request: - Rebased to master - Removed use=disabled addition from this commit
This commit is contained in:
parent
fc4f87b33e
commit
f5a1a906d1
2 changed files with 86 additions and 70 deletions
|
@ -203,6 +203,16 @@ ssl=yes # use ssl-support. Works with
|
|||
# ttl=10800 # optional
|
||||
# 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)
|
||||
##
|
||||
|
|
24
ddclient.in
24
ddclient.in
|
@ -5698,21 +5698,26 @@ sub nic_godaddy_update {
|
|||
|
||||
# Update each set configured host.
|
||||
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 $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);
|
||||
verbose("UPDATE:", "updating %s.%s", $hostname, $zone);
|
||||
|
||||
my $ipversion = is_ipv6($ip) ? "6" : "4";
|
||||
my $rrset_type = $ipversion == "6" ? "AAAA" : "A";
|
||||
my $data = encode_json([{
|
||||
my $ipversion = ($ip eq ($ipv6 // '')) ? '6' : '4';
|
||||
my $rrset_type = ($ipversion eq '6') ? 'AAAA' : 'A';
|
||||
my $data = encode_json([ {
|
||||
data => $ip,
|
||||
defined($config{$host}{'ttl'}) ? (ttl => $config{$host}{'ttl'}) : (),
|
||||
name => $hostname,
|
||||
type => $rrset_type,
|
||||
}]);
|
||||
} ]);
|
||||
|
||||
my $url = "https://$config{$host}{'server'}";
|
||||
$url .= "/${zone}/records/${rrset_type}/${hostname}";
|
||||
|
@ -5736,7 +5741,7 @@ sub nic_godaddy_update {
|
|||
my $ok = header_ok($host, $reply);
|
||||
my $msg;
|
||||
$reply =~ s/^.*?\n\n//s; # extract payload
|
||||
my $response = eval { decode_json($reply) };
|
||||
my $response = eval {decode_json($reply)};
|
||||
if (!defined($response) && $status != "200") {
|
||||
$config{$host}{'status'} = "bad";
|
||||
|
||||
|
@ -5746,9 +5751,9 @@ sub nic_godaddy_update {
|
|||
}
|
||||
if ($ok) {
|
||||
# read data
|
||||
$config{$host}{'ip'} = $ip;
|
||||
$config{$host}{"ipv$ipversion"} = $ip;
|
||||
$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);
|
||||
next;
|
||||
|
@ -5775,10 +5780,11 @@ sub nic_godaddy_update {
|
|||
$msg = 'Unexpected service response.';
|
||||
}
|
||||
|
||||
$config{$host}{'status'} = "bad";
|
||||
$config{$host}{"status-ipv$ipversion"} = 'bad';
|
||||
failed("%s.%s -- %s", $hostname, $zone, $msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
######################################################################
|
||||
|
|
Loading…
Reference in a new issue