porkbun: Move "ipv" out of $ipv for consistency
This also makes it possible to change "ipv4" and "ipv6" in log messages to "IPv4" and "IPv6".
This commit is contained in:
parent
4273580bdf
commit
630a2d5d49
1 changed files with 12 additions and 12 deletions
24
ddclient.in
24
ddclient.in
|
|
@ -6790,10 +6790,10 @@ sub nic_porkbun_update {
|
||||||
($sub_domain, $domain) = split(/\./, $h, 2);
|
($sub_domain, $domain) = split(/\./, $h, 2);
|
||||||
}
|
}
|
||||||
info("subdomain %s, root domain %s", $sub_domain, $domain) if $sub_domain ne '';
|
info("subdomain %s, root domain %s", $sub_domain, $domain) if $sub_domain ne '';
|
||||||
for my $ipv ('ipv4', 'ipv6') {
|
for my $ipv ('4', '6') {
|
||||||
my $ip = delete $config{$h}{"want$ipv"} or next;
|
my $ip = delete $config{$h}{"wantipv$ipv"} or next;
|
||||||
my $rrset_type = is_ipv6($ip) ? "AAAA" : "A";
|
my $rrset_type = is_ipv6($ip) ? "AAAA" : "A";
|
||||||
info("setting %s address to %s for %s", $ipv, $ip, $h);
|
info("setting ipv%s address to %s for %s", $ipv, $ip, $h);
|
||||||
verbose("UPDATE:","updating %s", $h);
|
verbose("UPDATE:","updating %s", $h);
|
||||||
my $url = "https://porkbun.com/api/json/v3/dns/retrieveByNameType/$domain/$rrset_type/$sub_domain";
|
my $url = "https://porkbun.com/api/json/v3/dns/retrieveByNameType/$domain/$rrset_type/$sub_domain";
|
||||||
my $data = encode_json({
|
my $data = encode_json({
|
||||||
|
|
@ -6809,24 +6809,24 @@ sub nic_porkbun_update {
|
||||||
data => $data,
|
data => $data,
|
||||||
);
|
);
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
$config{$h}{"status-$ipv"} = "bad";
|
$config{$h}{"status-ipv$ipv"} = "bad";
|
||||||
failed("updating %s: Could not connect to porkbun.com.", $h);
|
failed("updating %s: Could not connect to porkbun.com.", $h);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if (!header_ok($h, $reply)) {
|
if (!header_ok($h, $reply)) {
|
||||||
$config{$h}{"status-$ipv"} = "bad";
|
$config{$h}{"status-ipv$ipv"} = "bad";
|
||||||
failed("updating %s: failed (%s)", $h, $reply);
|
failed("updating %s: failed (%s)", $h, $reply);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
|
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
|
||||||
my $response = eval { decode_json(${^MATCH}) };
|
my $response = eval { decode_json(${^MATCH}) };
|
||||||
if (!defined($response)) {
|
if (!defined($response)) {
|
||||||
$config{$h}{"status-$ipv"} = "bad";
|
$config{$h}{"status-ipv$ipv"} = "bad";
|
||||||
failed("%s -- Unexpected service response.", $h);
|
failed("%s -- Unexpected service response.", $h);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if ($response->{status} ne 'SUCCESS') {
|
if ($response->{status} ne 'SUCCESS') {
|
||||||
$config{$h}{"status-$ipv"} = "bad";
|
$config{$h}{"status-ipv$ipv"} = "bad";
|
||||||
failed("%s -- Unexpected status. (status = %s)", $h, $response->{status});
|
failed("%s -- Unexpected status. (status = %s)", $h, $response->{status});
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
@ -6838,8 +6838,8 @@ sub nic_porkbun_update {
|
||||||
}
|
}
|
||||||
my $current_content = $records->[0]->{'content'};
|
my $current_content = $records->[0]->{'content'};
|
||||||
if ($current_content eq $ip) {
|
if ($current_content eq $ip) {
|
||||||
$config{$h}{"status-$ipv"} = "good";
|
$config{$h}{"status-ipv$ipv"} = "good";
|
||||||
success("updating %s: skipped: %s address was already set to %s.", $ipv, $h, $ip);
|
success("updating %s: skipped: ipv%s address was already set to %s.", $ipv, $h, $ip);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
my $ttl = $records->[0]->{'ttl'};
|
my $ttl = $records->[0]->{'ttl'};
|
||||||
|
|
@ -6869,11 +6869,11 @@ sub nic_porkbun_update {
|
||||||
failed("updating %s: failed (%s)", $h, $reply);
|
failed("updating %s: failed (%s)", $h, $reply);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
$config{$h}{"status-$ipv"} = "good";
|
$config{$h}{"status-ipv$ipv"} = "good";
|
||||||
success("updating %s: good: %s address set to %s", $ipv, $h, $ip);
|
success("updating %s: good: ipv%s address set to %s", $ipv, $h, $ip);
|
||||||
next;
|
next;
|
||||||
} else {
|
} else {
|
||||||
$config{$h}{"status-$ipv"} = "bad";
|
$config{$h}{"status-ipv$ipv"} = "bad";
|
||||||
failed("updating %s: No applicable existing records.", $h);
|
failed("updating %s: No applicable existing records.", $h);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue