dnsexit2: Inline some unnecessary variables

This commit is contained in:
Richard Hansen 2024-05-29 18:27:44 -04:00
parent 6c89eaf4ac
commit da9f39917f

View file

@ -4180,35 +4180,32 @@ sub nic_dnsexit2_update {
for my $ipv ('4', '6') { for my $ipv ('4', '6') {
my $ip = delete($config{$h}{"wantipv$ipv"}) or next; my $ip = delete($config{$h}{"wantipv$ipv"}) or next;
$ips{$ipv} = $ip; $ips{$ipv} = $ip;
my $type = ($ipv eq '6') ? 'AAAA' : 'A';
info("Going to update IPv%s address to %s for %s.", $ipv, $ip, $h); info("Going to update IPv%s address to %s for %s.", $ipv, $ip, $h);
$config{$h}{'status-ipv$ipv'} = 'failed'; $config{$h}{'status-ipv$ipv'} = 'failed';
push(@updates, { push(@updates, {
name => $h, name => $h,
type => $type, type => ($ipv eq '6') ? 'AAAA' : 'A',
content => $ip, content => $ip,
ttl => $config{$h}{'ttl'}, ttl => $config{$h}{'ttl'},
}); });
}; };
my $url = "https://$config{$h}{'server'}$config{$h}{'path'}"; my $url = "https://$config{$h}{'server'}$config{$h}{'path'}";
my $header = "Content-Type: application/json\nAccept: application/json";
if (not defined $config{$h}{'zone'}) { if (not defined $config{$h}{'zone'}) {
debug("Zone not defined, setting to default hostname: %s", $h); debug("Zone not defined, setting to default hostname: %s", $h);
$config{$h}{'zone'} = $h $config{$h}{'zone'} = $h
} else { } else {
debug("Zone is: %s", $config{$h}{'zone'}); debug("Zone is: %s", $config{$h}{'zone'});
} }
my $data = encode_json({
apikey => $config{$h}{'password'},
domain => $config{$h}{'zone'},
update => \@updates,
});
my $reply = geturl( my $reply = geturl(
proxy => opt('proxy'), proxy => opt('proxy'),
url => $url, url => $url,
headers => $header, headers => "Content-Type: application/json\nAccept: application/json",
method => 'POST', method => 'POST',
data => $data, data => encode_json({
apikey => $config{$h}{'password'},
domain => $config{$h}{'zone'},
update => \@updates,
}),
); );
unless ($reply && header_ok($h, $reply)) { unless ($reply && header_ok($h, $reply)) {
failed("updating %s: Could not connect to %s%s.", $h, $url); failed("updating %s: Could not connect to %s%s.", $h, $url);