Delete redundant calls to failed

`header_ok` already calls `failed` if there's an error.
This commit is contained in:
Richard Hansen 2024-07-28 00:24:23 -04:00
parent f410b915ce
commit ee0940175e

View file

@ -4016,10 +4016,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') {
@ -5155,8 +5152,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);
} }
} }
} }
@ -5569,8 +5564,6 @@ sub nic_mythicdyn_update {
$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);
@ -5771,11 +5764,7 @@ sub nic_cloudflare_update {
url => $url, url => $url,
headers => $headers headers => $headers
); );
unless (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})};
@ -5809,10 +5798,7 @@ sub nic_cloudflare_update {
url => $url, url => $url,
headers => $headers headers => $headers
); );
unless (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})};
@ -5836,10 +5822,7 @@ sub nic_cloudflare_update {
method => "PATCH", method => "PATCH",
data => $data data => $data
); );
unless (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})};
@ -5904,11 +5887,7 @@ sub nic_hetzner_update {
url => $url, url => $url,
headers => $headers headers => $headers
); );
unless (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})};
@ -5940,10 +5919,7 @@ sub nic_hetzner_update {
url => $url, url => $url,
headers => $headers headers => $headers
); );
unless (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})};
@ -5974,10 +5950,7 @@ sub nic_hetzner_update {
method => $http_method, method => $http_method,
data => $data data => $data
); );
unless (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})};
@ -6722,10 +6695,7 @@ sub nic_porkbun_update {
apikey => $config{$h}{'apikey'}, apikey => $config{$h}{'apikey'},
}), }),
); );
if (!header_ok($h, $reply)) { 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}) };
@ -6766,10 +6736,7 @@ sub nic_porkbun_update {
notes => $notes, notes => $notes,
}), }),
); );
if (!header_ok($h, $reply)) { 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");
} }
@ -6820,11 +6787,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 (!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.") {
@ -7278,11 +7241,7 @@ sub nic_digitalocean_update_one {
url => $list_url, url => $list_url,
headers => $headers, headers => $headers,
); );
unless (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) };
@ -7315,11 +7274,7 @@ sub nic_digitalocean_update_one {
headers => $headers, headers => $headers,
data => $update_data, data => $update_data,
); );
unless (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';