Merge pull request #720 from rhansen/delete

Delete some unnecessary code
This commit is contained in:
Richard Hansen 2024-07-28 18:22:19 -04:00 committed by GitHub
commit 26d7aa500a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2392,7 +2392,6 @@ sub logmsg {
} }
} }
sub _logmsg_fmt { return (@_ > 1) ? sprintf(shift, @_) : shift; } sub _logmsg_fmt { return (@_ > 1) ? sprintf(shift, @_) : shift; }
sub verbose { logmsg(email => 1, pfx => shift, _logmsg_fmt(@_)) if opt('verbose'); }
sub info { logmsg(email => 1, pfx => 'INFO:', _logmsg_fmt(@_)) if opt('verbose'); } sub info { logmsg(email => 1, pfx => 'INFO:', _logmsg_fmt(@_)) if opt('verbose'); }
sub debug { logmsg( pfx => 'DEBUG:', _logmsg_fmt(@_)) if opt('debug'); } sub debug { logmsg( pfx => 'DEBUG:', _logmsg_fmt(@_)) if opt('debug'); }
sub debug2 { logmsg( pfx => 'DEBUG:', _logmsg_fmt(@_)) if opt('debug') && opt('verbose'); } sub debug2 { logmsg( pfx => 'DEBUG:', _logmsg_fmt(@_)) if opt('debug') && opt('verbose'); }
@ -3718,7 +3717,6 @@ sub nic_dyndns1_update {
for my $h (@_) { for my $h (@_) {
my $ip = delete $config{$h}{'wantip'}; my $ip = delete $config{$h}{'wantip'};
info("setting IP address to %s for %s", $ip, $h); info("setting IP address to %s for %s", $ip, $h);
verbose("UPDATE:", "updating %s", $h);
my $url; my $url;
$url = "https://$config{$h}{'server'}/nic/"; $url = "https://$config{$h}{'server'}/nic/";
@ -3737,11 +3735,7 @@ sub nic_dyndns1_update {
url => $url, url => $url,
login => $config{$h}{'login'}, login => $config{$h}{'login'},
password => $config{$h}{'password'}, password => $config{$h}{'password'},
) // ''; );
if ($reply eq '') {
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
next;
}
next if !header_ok($h, $reply); next if !header_ok($h, $reply);
my @reply = split /\n/, $reply; my @reply = split /\n/, $reply;
@ -3868,11 +3862,7 @@ sub nic_dyndns2_update {
url => $url, url => $url,
login => $groupcfg{'login'}, login => $groupcfg{'login'},
password => $groupcfg{'password'}, password => $groupcfg{'password'},
) // ''; );
if ($reply eq '') {
failed("$hosts: Could not connect to $groupcfg{'server'}");
next;
}
next if !header_ok($hosts, $reply); next if !header_ok($hosts, $reply);
# Some services can return 200 OK even if there is an error (e.g., bad authentication, # Some services can return 200 OK even if there is an error (e.g., bad authentication,
# updates too frequent) so the body of the response must also be checked. # updates too frequent) so the body of the response must also be checked.
@ -4024,10 +4014,7 @@ sub dnsexit2_update_host {
update => \@updates, update => \@updates,
}), }),
); );
if (!header_ok($h, $reply)) { return if !header_ok($h, $reply);
failed("$h: request to $url failed");
return;
}
(my $body = $reply) =~ s/^.*?\r?\n\r?\n//s; (my $body = $reply) =~ s/^.*?\r?\n\r?\n//s;
my $response = eval { decode_json($body); }; my $response = eval { decode_json($body); };
if (ref($response) ne 'HASH') { if (ref($response) ne 'HASH') {
@ -4323,10 +4310,6 @@ sub nic_domeneshop_update {
login => $config{$h}{'login'}, login => $config{$h}{'login'},
password => $config{$h}{'password'}, password => $config{$h}{'password'},
); );
if (!defined($reply) || !$reply) {
failed("$h: Request to $config{$h}{'server'} failed");
next;
}
next if !header_ok($h, $reply); next if !header_ok($h, $reply);
$config{$h}{"ipv$ipv"} = $ip; $config{$h}{"ipv$ipv"} = $ip;
$config{$h}{'mtime'} = $now; $config{$h}{'mtime'} = $now;
@ -4386,7 +4369,6 @@ sub nic_zoneedit1_update {
delete $config{$_}{'wantip'} for @hosts; delete $config{$_}{'wantip'} for @hosts;
info("setting IP address to %s for %s", $ip, $hosts); info("setting IP address to %s for %s", $ip, $hosts);
verbose("UPDATE:", "updating %s", $hosts);
my $url = ''; my $url = '';
$url .= "https://$groupcfg{'server'}/auth/dynamic.html"; $url .= "https://$groupcfg{'server'}/auth/dynamic.html";
@ -4399,11 +4381,7 @@ sub nic_zoneedit1_update {
url => $url, url => $url,
login => $groupcfg{'login'}, login => $groupcfg{'login'},
password => $groupcfg{'password'}, password => $groupcfg{'password'},
) // ''; );
if ($reply eq '') {
failed("updating %s: Could not connect to %s.", $hosts, $groupcfg{'server'});
next;
}
next if !header_ok($hosts, $reply); next if !header_ok($hosts, $reply);
my @reply = split /\n/, $reply; my @reply = split /\n/, $reply;
@ -4518,11 +4496,7 @@ sub nic_easydns_update {
url => $url, url => $url,
login => $config{$h}{'login'}, login => $config{$h}{'login'},
password => $config{$h}{'password'}, password => $config{$h}{'password'},
) // ''; );
if ($reply eq '') {
failed("$h: Could not connect to $config{$h}{'server'}");
next;
}
next if !header_ok($h, $reply); next if !header_ok($h, $reply);
(my $body = $reply) =~ s/^.*?\n\n//s or do { (my $body = $reply) =~ s/^.*?\n\n//s or do {
failed("$h: Could not connect to $config{$h}{'server'}"); failed("$h: Could not connect to $config{$h}{'server'}");
@ -4595,7 +4569,6 @@ sub nic_namecheap_update {
for my $h (@_) { for my $h (@_) {
my $ip = delete $config{$h}{'wantip'}; my $ip = delete $config{$h}{'wantip'};
info("setting IP address to %s for %s", $ip, $h); info("setting IP address to %s for %s", $ip, $h);
verbose("UPDATE:", "updating %s", $h);
my $url; my $url;
$url = "https://$config{$h}{'server'}/update"; $url = "https://$config{$h}{'server'}/update";
@ -4608,12 +4581,8 @@ sub nic_namecheap_update {
$url .= "&ip="; $url .= "&ip=";
$url .= $ip if $ip; $url .= $ip if $ip;
my $reply = geturl(proxy => opt('proxy'), url => $url) // ''; my $reply = geturl(proxy => opt('proxy'), url => $url);
if ($reply eq '') { next if !header_ok($reply);
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
next;
}
next if !header_ok($h, $reply);
my @reply = split /\n/, $reply; my @reply = split /\n/, $reply;
if (grep /<ErrCount>0/i, @reply) { if (grep /<ErrCount>0/i, @reply) {
@ -4801,7 +4770,6 @@ sub nic_nfsn_update {
my $ip = delete $config{$h}{'wantip'}; my $ip = delete $config{$h}{'wantip'};
info("setting IP address to %s for %s", $ip, $h); info("setting IP address to %s for %s", $ip, $h);
verbose("UPDATE:", "updating %s", $h);
my $list_path = "/dns/$zone/listRRs"; my $list_path = "/dns/$zone/listRRs";
my $list_body = encode_www_form_urlencoded({name => $name, type => 'A'}); my $list_body = encode_www_form_urlencoded({name => $name, type => 'A'});
@ -4920,7 +4888,6 @@ sub nic_njalla_update {
$url .= (($quietreply eq 1)) ? '&quiet' : ''; $url .= (($quietreply eq 1)) ? '&quiet' : '';
info("setting address to%s for %s", ($ip_output eq '') ? ' auto' : $ip_output, $h); info("setting address to%s for %s", ($ip_output eq '') ? ' auto' : $ip_output, $h);
verbose("UPDATE:", "updating %s", $h);
debug("url: %s", $url); debug("url: %s", $url);
# Try to get URL # Try to get URL
@ -5010,7 +4977,6 @@ sub nic_sitelutions_update {
for my $h (@_) { for my $h (@_) {
my $ip = delete $config{$h}{'wantip'}; my $ip = delete $config{$h}{'wantip'};
info("setting IP address to %s for %s", $ip, $h); info("setting IP address to %s for %s", $ip, $h);
verbose("UPDATE:", "updating %s", $h);
my $url; my $url;
$url = "https://$config{$h}{'server'}/dnsup"; $url = "https://$config{$h}{'server'}/dnsup";
@ -5021,10 +4987,6 @@ sub nic_sitelutions_update {
$url .= $ip if $ip; $url .= $ip if $ip;
my $reply = geturl(proxy => opt('proxy'), url => $url); my $reply = geturl(proxy => opt('proxy'), url => $url);
if (!defined($reply) || !$reply) {
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
next;
}
next if !header_ok($h, $reply); next if !header_ok($h, $reply);
my @reply = split /\n/, $reply; my @reply = split /\n/, $reply;
@ -5112,7 +5074,7 @@ sub nic_freedns_update {
url => $url url => $url
); );
my $record_list_error = ''; my $record_list_error = '';
if ($reply && header_ok($_[0], $reply)) { if (header_ok($_[0], $reply)) {
$reply =~ s/^.*?\n\n//s; # Strip the headers. $reply =~ s/^.*?\n\n//s; # Strip the headers.
for (split("\n", $reply)) { for (split("\n", $reply)) {
my @rec = split(/\|/); my @rec = split(/\|/);
@ -5171,7 +5133,7 @@ sub nic_freedns_update {
my $reply = geturl(proxy => opt('proxy'), my $reply = geturl(proxy => opt('proxy'),
url => $url url => $url
); );
if ($reply && header_ok($h, $reply)) { if (header_ok($h, $reply)) {
$reply =~ s/^.*?\n\n//s; # Strip the headers. $reply =~ s/^.*?\n\n//s; # Strip the headers.
if ($reply =~ /Updated.*$h.*to.*$ip/) { if ($reply =~ /Updated.*$h.*to.*$ip/) {
$config{$h}{"ipv$ipv"} = $ip; $config{$h}{"ipv$ipv"} = $ip;
@ -5183,8 +5145,6 @@ sub nic_freedns_update {
warning("REPLIED: %s", $reply); warning("REPLIED: %s", $reply);
failed("updating %s: Invalid reply.", $h); failed("updating %s: Invalid reply.", $h);
} }
} else {
failed("updating %s: Could not connect to %s.", $h, $url_tmpl);
} }
} }
} }
@ -5229,7 +5189,6 @@ sub nic_1984_update {
for my $host (@_) { for my $host (@_) {
my $ip = delete $config{$host}{'wantip'}; my $ip = delete $config{$host}{'wantip'};
info("setting IP address to %s for %s", $ip, $host); info("setting IP address to %s for %s", $ip, $host);
verbose("UPDATE:", "updating %s", $host);
my $url; my $url;
$url = "https://$config{$host}{'server'}/1.0/freedns/"; $url = "https://$config{$host}{'server'}/1.0/freedns/";
@ -5240,11 +5199,7 @@ sub nic_1984_update {
my $reply = geturl( my $reply = geturl(
proxy => opt('proxy'), proxy => opt('proxy'),
url => $url, url => $url,
) // ''; );
if ($reply eq '') {
failed("Updating %s: Could not connect to %s.", $host, $config{$host}{'server'});
next;
}
next if !header_ok($host, $reply); next if !header_ok($host, $reply);
# Strip header # Strip header
@ -5311,7 +5266,6 @@ sub nic_changeip_update {
for my $h (@_) { for my $h (@_) {
my $ip = delete $config{$h}{'wantip'}; my $ip = delete $config{$h}{'wantip'};
info("setting IP address to %s for %s", $ip, $h); info("setting IP address to %s for %s", $ip, $h);
verbose("UPDATE:", "updating %s", $h);
my $url; my $url;
$url = "https://$config{$h}{'server'}/nic/update"; $url = "https://$config{$h}{'server'}/nic/update";
@ -5325,10 +5279,6 @@ sub nic_changeip_update {
login => $config{$h}{'login'}, login => $config{$h}{'login'},
password => $config{$h}{'password'}, password => $config{$h}{'password'},
); );
if (!defined($reply) || !$reply) {
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
next;
}
next if !header_ok($h, $reply); next if !header_ok($h, $reply);
my @reply = split /\n/, $reply; my @reply = split /\n/, $reply;
@ -5506,17 +5456,12 @@ sub nic_henet_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;
info("Setting IPv%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);
my $reply = geturl( my $reply = geturl(
proxy => opt('proxy'), proxy => opt('proxy'),
url => "https://$config{$h}{'server'}/nic/update?hostname=$h&myip=$ip", url => "https://$config{$h}{'server'}/nic/update?hostname=$h&myip=$ip",
login => $h, login => $h,
password => $config{$h}{'password'}, password => $config{$h}{'password'},
) // ''; );
if ($reply eq '') {
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
next;
}
next if !header_ok($h, $reply); next if !header_ok($h, $reply);
# dyn.dns.he.net can return 200 OK even if there is an error (e.g., bad authentication, # dyn.dns.he.net can return 200 OK even if there is an error (e.g., bad authentication,
# updates too frequent) so the body of the response must also be checked. # updates too frequent) so the body of the response must also be checked.
@ -5603,19 +5548,12 @@ sub nic_mythicdyn_update {
password => $config{$h}{'password'}, password => $config{$h}{'password'},
ipversion => $mythver, ipversion => $mythver,
); );
unless ($reply) {
failed("Updating service %s failed: %s", $h, $config{$h}{'server'});
next;
}
my $ok = header_ok($h, $reply); my $ok = header_ok($h, $reply);
if ($ok) { if ($ok) {
$config{$h}{'mtime'} = $now; $config{$h}{'mtime'} = $now;
$config{$h}{"status-ipv$mythver"} = "good"; $config{$h}{"status-ipv$mythver"} = "good";
success("%s -- IPV%s Updated successfully.", $h, $mythver); success("%s -- IPV%s Updated successfully.", $h, $mythver);
} else {
failed("%s -- Failed to update.", $h);
} }
} else { } else {
info("No configuration for IPV%s -------------", $mythver); info("No configuration for IPV%s -------------", $mythver);
@ -5694,7 +5632,6 @@ sub nic_nsupdate_update {
info("setting IPv4 address to %s for %s", $ipv4, $hosts) if ($ipv4); info("setting IPv4 address to %s for %s", $ipv4, $hosts) if ($ipv4);
info("setting IPv6 address to %s for %s", $ipv6, $hosts) if ($ipv6); info("setting IPv6 address to %s for %s", $ipv6, $hosts) if ($ipv6);
verbose("UPDATE:", "updating %s", $hosts);
## send separate requests for each zone with all hosts in that zone ## send separate requests for each zone with all hosts in that zone
my $instructions = <<"EoINSTR1"; my $instructions = <<"EoINSTR1";
@ -5717,8 +5654,8 @@ EoINSTR4
my $command = "$binary -k $keyfile"; my $command = "$binary -k $keyfile";
$command .= " -v" if ynu($groupcfg{'tcp'}, 1, 0, 0); $command .= " -v" if ynu($groupcfg{'tcp'}, 1, 0, 0);
$command .= " -d" if (opt('debug')); $command .= " -d" if (opt('debug'));
verbose("UPDATE:", "nsupdate command is: %s", $command); debug("nsupdate command: $command");
verbose("UPDATE:", "nsupdate instructions are:\n%s", $instructions); debug("nsupdate instructions:\n$instructions");
my $status = pipecmd($command, $instructions); my $status = pipecmd($command, $instructions);
if ($status eq 1) { if ($status eq 1) {
@ -5816,11 +5753,7 @@ sub nic_cloudflare_update {
url => $url, url => $url,
headers => $headers headers => $headers
); );
unless ($reply && header_ok($domain, $reply)) { next if !header_ok($domain, $reply);
failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'});
next;
}
# Strip header # Strip header
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp; $reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
my $response = eval {decode_json(${^MATCH})}; my $response = eval {decode_json(${^MATCH})};
@ -5854,10 +5787,7 @@ sub nic_cloudflare_update {
url => $url, url => $url,
headers => $headers headers => $headers
); );
unless ($reply && header_ok($domain, $reply)) { next if !header_ok($domain, $reply);
failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'});
next;
}
# Strip header # Strip header
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp; $reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
$response = eval {decode_json(${^MATCH})}; $response = eval {decode_json(${^MATCH})};
@ -5881,10 +5811,7 @@ sub nic_cloudflare_update {
method => "PATCH", method => "PATCH",
data => $data data => $data
); );
unless ($reply && header_ok($domain, $reply)) { next if !header_ok($domain, $reply);
failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'});
next;
}
# Strip header # Strip header
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp; $reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
$response = eval {decode_json(${^MATCH})}; $response = eval {decode_json(${^MATCH})};
@ -5949,11 +5876,7 @@ sub nic_hetzner_update {
url => $url, url => $url,
headers => $headers headers => $headers
); );
unless ($reply && header_ok($domain, $reply)) { next if !header_ok($domain, $reply);
failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'});
next;
}
# Strip header # Strip header
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp; $reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
my $response = eval {decode_json(${^MATCH})}; my $response = eval {decode_json(${^MATCH})};
@ -5985,10 +5908,7 @@ sub nic_hetzner_update {
url => $url, url => $url,
headers => $headers headers => $headers
); );
unless ($reply && header_ok($domain, $reply)) { next if !header_ok($domain, $reply);
failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'});
next;
}
# Strip header # Strip header
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp; $reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
$response = eval {decode_json(${^MATCH})}; $response = eval {decode_json(${^MATCH})};
@ -6019,10 +5939,7 @@ sub nic_hetzner_update {
method => $http_method, method => $http_method,
data => $data data => $data
); );
unless ($reply && header_ok($domain, $reply)) { next if !header_ok($domain, $reply);
failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'});
next;
}
# Strip header # Strip header
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp; $reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
$response = eval {decode_json(${^MATCH})}; $response = eval {decode_json(${^MATCH})};
@ -6136,11 +6053,7 @@ sub nic_inwx_update {
url => $url, url => $url,
login => $groupcfg{'login'}, login => $groupcfg{'login'},
password => $groupcfg{'password'}, password => $groupcfg{'password'},
) // ''; );
if ($reply eq '') {
failed("$hosts: Could not connect to $groupcfg{'server'}");
next;
}
next if !header_ok($hosts, $reply); next if !header_ok($hosts, $reply);
# INWX can return 200 OK even if there is an error (e.g., bad authentication, # INWX can return 200 OK even if there is an error (e.g., bad authentication,
# updates too frequent) so the body of the response must also be checked. # updates too frequent) so the body of the response must also be checked.
@ -6243,17 +6156,12 @@ sub nic_yandex_update {
my $headers = "PddToken: $config{$host}{'password'}\n"; my $headers = "PddToken: $config{$host}{'password'}\n";
info("setting IP address to %s for %s", $ip, $host); info("setting IP address to %s for %s", $ip, $host);
verbose("UPDATE:", "updating %s", $host);
# Get record ID for host # Get record ID for host
my $url = "https://$config{$host}{'server'}/api2/admin/dns/list?"; my $url = "https://$config{$host}{'server'}/api2/admin/dns/list?";
$url .= "domain="; $url .= "domain=";
$url .= $config{$host}{'login'}; $url .= $config{$host}{'login'};
my $reply = geturl(proxy => opt('proxy'), url => $url, headers => $headers); my $reply = geturl(proxy => opt('proxy'), url => $url, headers => $headers);
unless ($reply) {
failed("updating %s: Could not connect to %s.", $host, $config{$host}{'server'});
next;
}
next if !header_ok($host, $reply); next if !header_ok($host, $reply);
# Strip header # Strip header
@ -6287,10 +6195,6 @@ sub nic_yandex_update {
method => 'POST', method => 'POST',
data => $data, data => $data,
); );
unless ($reply) {
failed("updating %s: Could not connect to %s.", $host, $config{$host}{'server'});
next;
}
next if !header_ok($host, $reply); next if !header_ok($host, $reply);
# Strip header # Strip header
@ -6355,10 +6259,6 @@ sub nic_duckdns_update {
$url .= "&ip=$ipv4" if $ipv4; $url .= "&ip=$ipv4" if $ipv4;
$url .= "&ipv6=$ipv6" if $ipv6; $url .= "&ipv6=$ipv6" if $ipv6;
my $reply = geturl(proxy => opt('proxy'), url => $url); my $reply = geturl(proxy => opt('proxy'), url => $url);
if (!defined($reply) || !$reply) {
failed("$hosts: Could not connect to $groupcfg{'server'}");
next;
}
next if !header_ok($hosts, $reply); next if !header_ok($hosts, $reply);
(my $body = $reply) =~ s/^.*?\n\n//s or do { (my $body = $reply) =~ s/^.*?\n\n//s or do {
failed("$hosts: Invalid response from server"); failed("$hosts: Invalid response from server");
@ -6419,10 +6319,6 @@ sub nic_freemyip_update {
info("$h: setting IP address to $ip"); info("$h: setting IP address to $ip");
my $url = "https://$config{$h}{'server'}/update?token=$config{$h}{'password'}&domain=$h"; my $url = "https://$config{$h}{'server'}/update?token=$config{$h}{'password'}&domain=$h";
my $reply = geturl(proxy => opt('proxy'), url => $url); my $reply = geturl(proxy => opt('proxy'), url => $url);
if (!defined($reply) || !$reply) {
failed("$h: Request to $config{$h}{'server'} failed");
next;
}
next if !header_ok($h, $reply); next if !header_ok($h, $reply);
(my $body = $reply) =~ s/^.*?\n\n//s; (my $body = $reply) =~ s/^.*?\n\n//s;
if ($body !~ /OK/) { if ($body !~ /OK/) {
@ -6478,10 +6374,6 @@ sub nic_ddnsfm_update {
proxy => opt('proxy'), proxy => opt('proxy'),
url => "$config{$h}{server}/update?key=$config{$h}{password}&domain=$h&myip=$ip", url => "$config{$h}{server}/update?key=$config{$h}{password}&domain=$h&myip=$ip",
); );
if (!$reply) {
failed("$h: Request to $config{$h}{'server'} failed");
next;
}
next if !header_ok($h, $reply); next if !header_ok($h, $reply);
$config{$h}{"ipv$ipv"} = $ip; $config{$h}{"ipv$ipv"} = $ip;
$config{$h}{'mtime'} = $now; $config{$h}{'mtime'} = $now;
@ -6525,10 +6417,6 @@ sub nic_dondominio_update {
info("$h: setting IP address to $ip"); info("$h: setting IP address to $ip");
my $url = "https://$config{$h}{'server'}/plain/?user=$config{$h}{'login'}&password=$config{$h}{'password'}&host=$h&ip=$ip"; my $url = "https://$config{$h}{'server'}/plain/?user=$config{$h}{'login'}&password=$config{$h}{'password'}&host=$h&ip=$ip";
my $reply = geturl(proxy => opt('proxy'), url => $url); my $reply = geturl(proxy => opt('proxy'), url => $url);
if (!defined($reply) || !$reply) {
failed("$h: Request to $config{$h}{'server'} failed");
next;
}
next if !header_ok($h, $reply); next if !header_ok($h, $reply);
my @reply = split /\n/, $reply; my @reply = split /\n/, $reply;
my $returned = pop(@reply); my $returned = pop(@reply);
@ -6592,10 +6480,6 @@ sub nic_dnsmadeeasy_update {
info("$h: Setting IP address to $ip"); info("$h: Setting IP address to $ip");
my $url = "$config{$h}{'server'}$config{$h}{'script'}?username=$config{$h}{'login'}&password=$config{$h}{'password'}&ip=$ip&id=$h"; my $url = "$config{$h}{'server'}$config{$h}{'script'}?username=$config{$h}{'login'}&password=$config{$h}{'password'}&ip=$ip&id=$h";
my $reply = geturl(proxy => opt('proxy'), url => $url); my $reply = geturl(proxy => opt('proxy'), url => $url);
if (!defined($reply) || !$reply) {
failed("$h: Request to $config{$h}{'server'} failed");
next;
}
next if !header_ok($h, $reply); next if !header_ok($h, $reply);
my @reply = split /\n/, $reply; my @reply = split /\n/, $reply;
my $returned = pop(@reply); my $returned = pop(@reply);
@ -6650,7 +6534,6 @@ sub nic_ovh_update {
for my $h (@_) { for my $h (@_) {
my $ip = delete $config{$h}{'wantip'}; my $ip = delete $config{$h}{'wantip'};
info("setting IP address to %s for %s", $ip, $h); info("setting IP address to %s for %s", $ip, $h);
verbose("UPDATE:","updating %s", $h);
# Set the URL that we're going to update # Set the URL that we're going to update
my $url; my $url;
@ -6799,14 +6682,7 @@ sub nic_porkbun_update {
apikey => $config{$h}{'apikey'}, apikey => $config{$h}{'apikey'},
}), }),
); );
if (!defined($reply) || !$reply) { next if !header_ok($h, $reply);
failed("$h: request to porkbun.com failed");
next;
}
if (!header_ok($h, $reply)) {
failed("$h: $reply");
next;
}
(my $body = $reply) =~ s/^.*?\n\n//s; (my $body = $reply) =~ s/^.*?\n\n//s;
$body =~ qr/{(?:[^{}]*|(?R))*}/mp; $body =~ qr/{(?:[^{}]*|(?R))*}/mp;
my $response = eval { decode_json(${^MATCH}) }; my $response = eval { decode_json(${^MATCH}) };
@ -6847,14 +6723,7 @@ sub nic_porkbun_update {
notes => $notes, notes => $notes,
}), }),
); );
if (!defined($reply) || !$reply) { next if !header_ok($h, $reply);
failed("$h: request to porkbun.com failed");
next;
}
if (!header_ok($h, $reply)) {
failed("$h: $reply");
next;
}
$config{$h}{"status-ipv$ipv"} = "good"; $config{$h}{"status-ipv$ipv"} = "good";
success("$h: IPv%s address set to $ip"); success("$h: IPv%s address set to $ip");
} }
@ -6905,11 +6774,7 @@ sub nic_cloudns_update {
url => $dynurl . '&proxy=1', url => $dynurl . '&proxy=1',
headers => "X-Forwarded-For: $ip\n", headers => "X-Forwarded-For: $ip\n",
); );
if (($reply // '') eq '' || !header_ok($hosts, $reply)) { next if !header_ok($hosts, $reply);
$config{$_}{'status'} = 'failed' for @hosts;
failed("updating %s: failed to visit DynURL", $hosts);
next;
}
$reply =~ s/^.*?\n\n//s; # Strip the headers. $reply =~ s/^.*?\n\n//s; # Strip the headers.
chomp($reply); chomp($reply);
if ($reply eq "The record's key is wrong!" || $reply eq "Invalid request.") { if ($reply eq "The record's key is wrong!" || $reply eq "Invalid request.") {
@ -6957,7 +6822,6 @@ sub nic_dinahosting_update {
for my $h (@_) { for my $h (@_) {
my $ip = delete $config{$h}{'wantip'}; my $ip = delete $config{$h}{'wantip'};
info("setting IP address to %s for %s", $ip, $h); info("setting IP address to %s for %s", $ip, $h);
verbose("UPDATE:", "updating %s", $h);
my ($hostname, $domain) = split(/\./, $h, 2); my ($hostname, $domain) = split(/\./, $h, 2);
my $url = "https://$config{$h}{'server'}$config{$h}{'script'}"; my $url = "https://$config{$h}{'server'}$config{$h}{'script'}";
$url .= "?hostname=$hostname"; $url .= "?hostname=$hostname";
@ -6971,10 +6835,6 @@ sub nic_dinahosting_update {
url => $url, url => $url,
); );
$config{$h}{'status'} = 'failed'; # assume failure until otherwise determined $config{$h}{'status'} = 'failed'; # assume failure until otherwise determined
if (!$reply) {
failed("updating %s: failed to visit URL %s", $h, $url);
next;
}
next if !header_ok($h, $reply); next if !header_ok($h, $reply);
$reply =~ s/^.*?\n\n//s; # Strip the headers. $reply =~ s/^.*?\n\n//s; # Strip the headers.
if ($reply !~ /Success/i) { if ($reply !~ /Success/i) {
@ -7054,7 +6914,6 @@ sub nic_gandi_update {
} }
(my $hostname = $h) =~ s/\.\Q$config{$h}{zone}\E$//; (my $hostname = $h) =~ s/\.\Q$config{$h}{zone}\E$//;
info("%s -- Setting IP address to %s.", $h, $ip); info("%s -- Setting IP address to %s.", $h, $ip);
verbose("UPDATE:", "updating %s", $h);
my $headers; my $headers;
$headers = "Content-Type: application/json\n"; $headers = "Content-Type: application/json\n";
@ -7079,10 +6938,6 @@ sub nic_gandi_update {
headers => $headers, headers => $headers,
method => 'GET' method => 'GET'
); );
unless ($reply) {
failed("%s -- Could not connect to %s.", $h, $config{$h}{'server'});
next;
}
my $ok = header_ok($h, $reply); my $ok = header_ok($h, $reply);
$reply =~ s/^.*?\n\n//s; $reply =~ s/^.*?\n\n//s;
@ -7113,10 +6968,6 @@ sub nic_gandi_update {
method => 'PUT', method => 'PUT',
data => $data, data => $data,
); );
unless ($reply) {
failed("%s -- Could not connect to %s.", $h, $config{$h}{'server'});
next;
}
$ok = header_ok($h, $reply); $ok = header_ok($h, $reply);
if ($ok) { if ($ok) {
$config{$h}{'ip'} = $ip; $config{$h}{'ip'} = $ip;
@ -7177,13 +7028,7 @@ sub nic_keysystems_update {
my $ip = delete $config{$h}{'wantip'}; my $ip = delete $config{$h}{'wantip'};
info("KEYSYSTEMS setting IP address to %s for %s", $ip, $h); info("KEYSYSTEMS setting IP address to %s for %s", $ip, $h);
my $url = "$config{$h}{'server'}/update.php?hostname=$h&password=$config{$h}{'password'}&ip=$ip"; my $url = "$config{$h}{'server'}/update.php?hostname=$h&password=$config{$h}{'password'}&ip=$ip";
my $reply = geturl(proxy => opt('proxy'), url => $url) // ''; my $reply = geturl(proxy => opt('proxy'), url => $url);
# No response, declare as failed
if (!defined($reply) || !$reply) {
failed("KEYSYSTEMS updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
last;
}
last if !header_ok($h, $reply); last if !header_ok($h, $reply);
if ($reply =~ /code = 200/) { if ($reply =~ /code = 200/) {
@ -7237,12 +7082,6 @@ sub nic_regfishde_update {
# Try to get URL # Try to get URL
my $reply = geturl(proxy => opt('proxy'), url => $url); my $reply = geturl(proxy => opt('proxy'), url => $url);
# No response, give error
if (!defined($reply) || !$reply) {
failed("regfish.de updating %s: failed: %s.", $h, $config{$h}{'server'});
last;
}
last if !header_ok($h, $reply); last if !header_ok($h, $reply);
if ($reply !~ /success/) { if ($reply !~ /success/) {
failed("updating %s: Server said: '%s'", $h, $reply); failed("updating %s: Server said: '%s'", $h, $reply);
@ -7304,7 +7143,6 @@ sub nic_enom_update {
for my $h (@_) { for my $h (@_) {
my $ip = delete $config{$h}{'wantip'}; my $ip = delete $config{$h}{'wantip'};
info("setting IP address to %s for %s", $ip, $h); info("setting IP address to %s for %s", $ip, $h);
verbose("UPDATE:","updating %s", $h);
my $url; my $url;
$url = "https://$config{$h}{'server'}/interface.asp?Command=SetDNSHost"; $url = "https://$config{$h}{'server'}/interface.asp?Command=SetDNSHost";
@ -7318,12 +7156,6 @@ sub nic_enom_update {
proxy => opt('proxy'), proxy => opt('proxy'),
url => $url url => $url
); );
if (!defined($reply) || !$reply) {
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
last;
}
last if !header_ok($h, $reply); last if !header_ok($h, $reply);
my @reply = split /\n/, $reply; my @reply = split /\n/, $reply;
@ -7393,11 +7225,7 @@ sub nic_digitalocean_update_one {
url => $list_url, url => $list_url,
headers => $headers, headers => $headers,
); );
unless ($list_resp && header_ok($h, $list_resp)) { return if !header_ok($h, $list_resp);
$config{$h}{"status-$ipv"} = 'failed';
failed("listing %s %s: Failed connection or bad response from %s.", $h, $ipv, $server);
return;
}
$list_resp =~ s/^.*?\n\n//s; # Strip header $list_resp =~ s/^.*?\n\n//s; # Strip header
my $list = eval { decode_json($list_resp) }; my $list = eval { decode_json($list_resp) };
@ -7430,11 +7258,7 @@ sub nic_digitalocean_update_one {
headers => $headers, headers => $headers,
data => $update_data, data => $update_data,
); );
unless ($update_resp && header_ok($h, $update_resp)) { return if !header_ok($h, $update_resp);
$config{$h}{"status-$ipv"} = 'failed';
failed("updating %s %s: Failed connection or bad response from %s.", $h, $ipv, $server);
return;
}
} }
$config{$h}{"status-$ipv"} = 'good'; $config{$h}{"status-$ipv"} = 'good';