From f410b915cec7911b28b6f6561643ab250039ae1b Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 28 Jul 2024 03:17:39 -0400 Subject: [PATCH 1/5] Delete redundant checks `header_ok` already asserts that the reply is defined and non-empty. --- ddclient.in | 157 +++++++--------------------------------------------- 1 file changed, 21 insertions(+), 136 deletions(-) diff --git a/ddclient.in b/ddclient.in index 728558d..2509bc1 100755 --- a/ddclient.in +++ b/ddclient.in @@ -3737,11 +3737,7 @@ sub nic_dyndns1_update { url => $url, login => $config{$h}{'login'}, 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); my @reply = split /\n/, $reply; @@ -3868,11 +3864,7 @@ sub nic_dyndns2_update { url => $url, login => $groupcfg{'login'}, password => $groupcfg{'password'}, - ) // ''; - if ($reply eq '') { - failed("$hosts: Could not connect to $groupcfg{'server'}"); - next; - } + ); next if !header_ok($hosts, $reply); # 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. @@ -4323,10 +4315,6 @@ sub nic_domeneshop_update { login => $config{$h}{'login'}, password => $config{$h}{'password'}, ); - if (!defined($reply) || !$reply) { - failed("$h: Request to $config{$h}{'server'} failed"); - next; - } next if !header_ok($h, $reply); $config{$h}{"ipv$ipv"} = $ip; $config{$h}{'mtime'} = $now; @@ -4399,11 +4387,7 @@ sub nic_zoneedit1_update { url => $url, login => $groupcfg{'login'}, password => $groupcfg{'password'}, - ) // ''; - if ($reply eq '') { - failed("updating %s: Could not connect to %s.", $hosts, $groupcfg{'server'}); - next; - } + ); next if !header_ok($hosts, $reply); my @reply = split /\n/, $reply; @@ -4518,11 +4502,7 @@ sub nic_easydns_update { url => $url, login => $config{$h}{'login'}, password => $config{$h}{'password'}, - ) // ''; - if ($reply eq '') { - failed("$h: Could not connect to $config{$h}{'server'}"); - next; - } + ); next if !header_ok($h, $reply); (my $body = $reply) =~ s/^.*?\n\n//s or do { failed("$h: Could not connect to $config{$h}{'server'}"); @@ -4608,12 +4588,8 @@ sub nic_namecheap_update { $url .= "&ip="; $url .= $ip if $ip; - my $reply = geturl(proxy => opt('proxy'), url => $url) // ''; - if ($reply eq '') { - failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'}); - next; - } - next if !header_ok($h, $reply); + my $reply = geturl(proxy => opt('proxy'), url => $url); + next if !header_ok($reply); my @reply = split /\n/, $reply; if (grep /0/i, @reply) { @@ -5021,10 +4997,6 @@ sub nic_sitelutions_update { $url .= $ip if $ip; 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); my @reply = split /\n/, $reply; @@ -5112,7 +5084,7 @@ sub nic_freedns_update { url => $url ); my $record_list_error = ''; - if ($reply && header_ok($_[0], $reply)) { + if (header_ok($_[0], $reply)) { $reply =~ s/^.*?\n\n//s; # Strip the headers. for (split("\n", $reply)) { my @rec = split(/\|/); @@ -5171,7 +5143,7 @@ sub nic_freedns_update { my $reply = geturl(proxy => opt('proxy'), url => $url ); - if ($reply && header_ok($h, $reply)) { + if (header_ok($h, $reply)) { $reply =~ s/^.*?\n\n//s; # Strip the headers. if ($reply =~ /Updated.*$h.*to.*$ip/) { $config{$h}{"ipv$ipv"} = $ip; @@ -5240,11 +5212,7 @@ sub nic_1984_update { my $reply = geturl( proxy => opt('proxy'), url => $url, - ) // ''; - if ($reply eq '') { - failed("Updating %s: Could not connect to %s.", $host, $config{$host}{'server'}); - next; - } + ); next if !header_ok($host, $reply); # Strip header @@ -5325,10 +5293,6 @@ sub nic_changeip_update { login => $config{$h}{'login'}, 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); my @reply = split /\n/, $reply; @@ -5512,11 +5476,7 @@ sub nic_henet_update { url => "https://$config{$h}{'server'}/nic/update?hostname=$h&myip=$ip", login => $h, 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); # 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. @@ -5603,11 +5563,6 @@ sub nic_mythicdyn_update { password => $config{$h}{'password'}, ipversion => $mythver, ); - unless ($reply) { - failed("Updating service %s failed: %s", $h, $config{$h}{'server'}); - next; - } - my $ok = header_ok($h, $reply); if ($ok) { $config{$h}{'mtime'} = $now; @@ -5816,7 +5771,7 @@ sub nic_cloudflare_update { url => $url, headers => $headers ); - unless ($reply && header_ok($domain, $reply)) { + unless (header_ok($domain, $reply)) { failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); next; } @@ -5854,7 +5809,7 @@ sub nic_cloudflare_update { url => $url, headers => $headers ); - unless ($reply && header_ok($domain, $reply)) { + unless (header_ok($domain, $reply)) { failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); next; } @@ -5881,7 +5836,7 @@ sub nic_cloudflare_update { method => "PATCH", data => $data ); - unless ($reply && header_ok($domain, $reply)) { + unless (header_ok($domain, $reply)) { failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); next; } @@ -5949,7 +5904,7 @@ sub nic_hetzner_update { url => $url, headers => $headers ); - unless ($reply && header_ok($domain, $reply)) { + unless (header_ok($domain, $reply)) { failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); next; } @@ -5985,7 +5940,7 @@ sub nic_hetzner_update { url => $url, headers => $headers ); - unless ($reply && header_ok($domain, $reply)) { + unless (header_ok($domain, $reply)) { failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); next; } @@ -6019,7 +5974,7 @@ sub nic_hetzner_update { method => $http_method, data => $data ); - unless ($reply && header_ok($domain, $reply)) { + unless (header_ok($domain, $reply)) { failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); next; } @@ -6136,11 +6091,7 @@ sub nic_inwx_update { url => $url, login => $groupcfg{'login'}, password => $groupcfg{'password'}, - ) // ''; - if ($reply eq '') { - failed("$hosts: Could not connect to $groupcfg{'server'}"); - next; - } + ); next if !header_ok($hosts, $reply); # 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. @@ -6250,10 +6201,6 @@ sub nic_yandex_update { $url .= "domain="; $url .= $config{$host}{'login'}; 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); # Strip header @@ -6287,10 +6234,6 @@ sub nic_yandex_update { method => 'POST', data => $data, ); - unless ($reply) { - failed("updating %s: Could not connect to %s.", $host, $config{$host}{'server'}); - next; - } next if !header_ok($host, $reply); # Strip header @@ -6355,10 +6298,6 @@ sub nic_duckdns_update { $url .= "&ip=$ipv4" if $ipv4; $url .= "&ipv6=$ipv6" if $ipv6; 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); (my $body = $reply) =~ s/^.*?\n\n//s or do { failed("$hosts: Invalid response from server"); @@ -6419,10 +6358,6 @@ sub nic_freemyip_update { info("$h: setting IP address to $ip"); my $url = "https://$config{$h}{'server'}/update?token=$config{$h}{'password'}&domain=$h"; 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); (my $body = $reply) =~ s/^.*?\n\n//s; if ($body !~ /OK/) { @@ -6478,10 +6413,6 @@ sub nic_ddnsfm_update { proxy => opt('proxy'), 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); $config{$h}{"ipv$ipv"} = $ip; $config{$h}{'mtime'} = $now; @@ -6525,10 +6456,6 @@ sub nic_dondominio_update { 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 $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); my @reply = split /\n/, $reply; my $returned = pop(@reply); @@ -6592,10 +6519,6 @@ sub nic_dnsmadeeasy_update { 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 $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); my @reply = split /\n/, $reply; my $returned = pop(@reply); @@ -6799,10 +6722,6 @@ sub nic_porkbun_update { apikey => $config{$h}{'apikey'}, }), ); - if (!defined($reply) || !$reply) { - failed("$h: request to porkbun.com failed"); - next; - } if (!header_ok($h, $reply)) { failed("$h: $reply"); next; @@ -6847,10 +6766,6 @@ sub nic_porkbun_update { notes => $notes, }), ); - if (!defined($reply) || !$reply) { - failed("$h: request to porkbun.com failed"); - next; - } if (!header_ok($h, $reply)) { failed("$h: $reply"); next; @@ -6905,7 +6820,7 @@ sub nic_cloudns_update { url => $dynurl . '&proxy=1', headers => "X-Forwarded-For: $ip\n", ); - if (($reply // '') eq '' || !header_ok($hosts, $reply)) { + if (!header_ok($hosts, $reply)) { $config{$_}{'status'} = 'failed' for @hosts; failed("updating %s: failed to visit DynURL", $hosts); next; @@ -6971,10 +6886,6 @@ sub nic_dinahosting_update { url => $url, ); $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); $reply =~ s/^.*?\n\n//s; # Strip the headers. if ($reply !~ /Success/i) { @@ -7079,10 +6990,6 @@ sub nic_gandi_update { headers => $headers, method => 'GET' ); - unless ($reply) { - failed("%s -- Could not connect to %s.", $h, $config{$h}{'server'}); - next; - } my $ok = header_ok($h, $reply); $reply =~ s/^.*?\n\n//s; @@ -7113,10 +7020,6 @@ sub nic_gandi_update { method => 'PUT', data => $data, ); - unless ($reply) { - failed("%s -- Could not connect to %s.", $h, $config{$h}{'server'}); - next; - } $ok = header_ok($h, $reply); if ($ok) { $config{$h}{'ip'} = $ip; @@ -7177,13 +7080,7 @@ sub nic_keysystems_update { my $ip = delete $config{$h}{'wantip'}; 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 $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; - } + my $reply = geturl(proxy => opt('proxy'), url => $url); last if !header_ok($h, $reply); if ($reply =~ /code = 200/) { @@ -7237,12 +7134,6 @@ sub nic_regfishde_update { # Try to get 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); if ($reply !~ /success/) { failed("updating %s: Server said: '%s'", $h, $reply); @@ -7318,12 +7209,6 @@ sub nic_enom_update { proxy => opt('proxy'), 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); my @reply = split /\n/, $reply; @@ -7393,7 +7278,7 @@ sub nic_digitalocean_update_one { url => $list_url, headers => $headers, ); - unless ($list_resp && header_ok($h, $list_resp)) { + unless (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; @@ -7430,7 +7315,7 @@ sub nic_digitalocean_update_one { headers => $headers, data => $update_data, ); - unless ($update_resp && header_ok($h, $update_resp)) { + unless (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; From ee0940175e3f20c236b379d87093e75cf52d7a3f Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 28 Jul 2024 00:24:23 -0400 Subject: [PATCH 2/5] Delete redundant calls to `failed` `header_ok` already calls `failed` if there's an error. --- ddclient.in | 69 ++++++++++------------------------------------------- 1 file changed, 12 insertions(+), 57 deletions(-) diff --git a/ddclient.in b/ddclient.in index 2509bc1..09f6422 100755 --- a/ddclient.in +++ b/ddclient.in @@ -4016,10 +4016,7 @@ sub dnsexit2_update_host { update => \@updates, }), ); - if (!header_ok($h, $reply)) { - failed("$h: request to $url failed"); - return; - } + return if !header_ok($h, $reply); (my $body = $reply) =~ s/^.*?\r?\n\r?\n//s; my $response = eval { decode_json($body); }; if (ref($response) ne 'HASH') { @@ -5155,8 +5152,6 @@ sub nic_freedns_update { warning("REPLIED: %s", $reply); 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"; success("%s -- IPV%s Updated successfully.", $h, $mythver); - } else { - failed("%s -- Failed to update.", $h); } } else { info("No configuration for IPV%s -------------", $mythver); @@ -5771,11 +5764,7 @@ sub nic_cloudflare_update { url => $url, headers => $headers ); - unless (header_ok($domain, $reply)) { - failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); - next; - } - + next if !header_ok($domain, $reply); # Strip header $reply =~ qr/{(?:[^{}]*|(?R))*}/mp; my $response = eval {decode_json(${^MATCH})}; @@ -5809,10 +5798,7 @@ sub nic_cloudflare_update { url => $url, headers => $headers ); - unless (header_ok($domain, $reply)) { - failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); - next; - } + next if !header_ok($domain, $reply); # Strip header $reply =~ qr/{(?:[^{}]*|(?R))*}/mp; $response = eval {decode_json(${^MATCH})}; @@ -5836,10 +5822,7 @@ sub nic_cloudflare_update { method => "PATCH", data => $data ); - unless (header_ok($domain, $reply)) { - failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); - next; - } + next if !header_ok($domain, $reply); # Strip header $reply =~ qr/{(?:[^{}]*|(?R))*}/mp; $response = eval {decode_json(${^MATCH})}; @@ -5904,11 +5887,7 @@ sub nic_hetzner_update { url => $url, headers => $headers ); - unless (header_ok($domain, $reply)) { - failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); - next; - } - + next if !header_ok($domain, $reply); # Strip header $reply =~ qr/{(?:[^{}]*|(?R))*}/mp; my $response = eval {decode_json(${^MATCH})}; @@ -5940,10 +5919,7 @@ sub nic_hetzner_update { url => $url, headers => $headers ); - unless (header_ok($domain, $reply)) { - failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); - next; - } + next if !header_ok($domain, $reply); # Strip header $reply =~ qr/{(?:[^{}]*|(?R))*}/mp; $response = eval {decode_json(${^MATCH})}; @@ -5974,10 +5950,7 @@ sub nic_hetzner_update { method => $http_method, data => $data ); - unless (header_ok($domain, $reply)) { - failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'}); - next; - } + next if !header_ok($domain, $reply); # Strip header $reply =~ qr/{(?:[^{}]*|(?R))*}/mp; $response = eval {decode_json(${^MATCH})}; @@ -6722,10 +6695,7 @@ sub nic_porkbun_update { apikey => $config{$h}{'apikey'}, }), ); - if (!header_ok($h, $reply)) { - failed("$h: $reply"); - next; - } + next if !header_ok($h, $reply); (my $body = $reply) =~ s/^.*?\n\n//s; $body =~ qr/{(?:[^{}]*|(?R))*}/mp; my $response = eval { decode_json(${^MATCH}) }; @@ -6766,10 +6736,7 @@ sub nic_porkbun_update { notes => $notes, }), ); - if (!header_ok($h, $reply)) { - failed("$h: $reply"); - next; - } + next if !header_ok($h, $reply); $config{$h}{"status-ipv$ipv"} = "good"; success("$h: IPv%s address set to $ip"); } @@ -6820,11 +6787,7 @@ sub nic_cloudns_update { url => $dynurl . '&proxy=1', headers => "X-Forwarded-For: $ip\n", ); - if (!header_ok($hosts, $reply)) { - $config{$_}{'status'} = 'failed' for @hosts; - failed("updating %s: failed to visit DynURL", $hosts); - next; - } + next if !header_ok($hosts, $reply); $reply =~ s/^.*?\n\n//s; # Strip the headers. chomp($reply); 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, headers => $headers, ); - unless (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; - } + return if !header_ok($h, $list_resp); $list_resp =~ s/^.*?\n\n//s; # Strip header my $list = eval { decode_json($list_resp) }; @@ -7315,11 +7274,7 @@ sub nic_digitalocean_update_one { headers => $headers, data => $update_data, ); - unless (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; - } + return if !header_ok($h, $update_resp); } $config{$h}{"status-$ipv"} = 'good'; From 61cc5d66ae403906e958f528403ec9357924b213 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 27 Jul 2024 17:04:23 -0400 Subject: [PATCH 3/5] logging: Delete unnecessary `verbose` calls The same information (or more) is logged in the previous line. --- ddclient.in | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/ddclient.in b/ddclient.in index 09f6422..50c1cf2 100755 --- a/ddclient.in +++ b/ddclient.in @@ -3718,7 +3718,6 @@ sub nic_dyndns1_update { for my $h (@_) { my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); - verbose("UPDATE:", "updating %s", $h); my $url; $url = "https://$config{$h}{'server'}/nic/"; @@ -4371,7 +4370,6 @@ sub nic_zoneedit1_update { delete $config{$_}{'wantip'} for @hosts; info("setting IP address to %s for %s", $ip, $hosts); - verbose("UPDATE:", "updating %s", $hosts); my $url = ''; $url .= "https://$groupcfg{'server'}/auth/dynamic.html"; @@ -4572,7 +4570,6 @@ sub nic_namecheap_update { for my $h (@_) { my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); - verbose("UPDATE:", "updating %s", $h); my $url; $url = "https://$config{$h}{'server'}/update"; @@ -4774,7 +4771,6 @@ sub nic_nfsn_update { my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); - verbose("UPDATE:", "updating %s", $h); my $list_path = "/dns/$zone/listRRs"; my $list_body = encode_www_form_urlencoded({name => $name, type => 'A'}); @@ -4893,7 +4889,6 @@ sub nic_njalla_update { $url .= (($quietreply eq 1)) ? '&quiet' : ''; info("setting address to%s for %s", ($ip_output eq '') ? ' auto' : $ip_output, $h); - verbose("UPDATE:", "updating %s", $h); debug("url: %s", $url); # Try to get URL @@ -4983,7 +4978,6 @@ sub nic_sitelutions_update { for my $h (@_) { my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); - verbose("UPDATE:", "updating %s", $h); my $url; $url = "https://$config{$h}{'server'}/dnsup"; @@ -5196,7 +5190,6 @@ sub nic_1984_update { for my $host (@_) { my $ip = delete $config{$host}{'wantip'}; info("setting IP address to %s for %s", $ip, $host); - verbose("UPDATE:", "updating %s", $host); my $url; $url = "https://$config{$host}{'server'}/1.0/freedns/"; @@ -5274,7 +5267,6 @@ sub nic_changeip_update { for my $h (@_) { my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); - verbose("UPDATE:", "updating %s", $h); my $url; $url = "https://$config{$h}{'server'}/nic/update"; @@ -5465,7 +5457,6 @@ sub nic_henet_update { for my $ipv ('4', '6') { my $ip = delete($config{$h}{"wantipv$ipv"}) or next; info("Setting IPv%s address to %s for %s", $ipv, $ip, $h); - verbose("UPDATE:", "updating %s", $h); my $reply = geturl( proxy => opt('proxy'), url => "https://$config{$h}{'server'}/nic/update?hostname=$h&myip=$ip", @@ -5642,7 +5633,6 @@ sub nic_nsupdate_update { info("setting IPv4 address to %s for %s", $ipv4, $hosts) if ($ipv4); 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 my $instructions = <<"EoINSTR1"; @@ -6167,7 +6157,6 @@ sub nic_yandex_update { my $headers = "PddToken: $config{$host}{'password'}\n"; info("setting IP address to %s for %s", $ip, $host); - verbose("UPDATE:", "updating %s", $host); # Get record ID for host my $url = "https://$config{$host}{'server'}/api2/admin/dns/list?"; @@ -6546,7 +6535,6 @@ sub nic_ovh_update { for my $h (@_) { my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); - verbose("UPDATE:","updating %s", $h); # Set the URL that we're going to update my $url; @@ -6835,7 +6823,6 @@ sub nic_dinahosting_update { for my $h (@_) { my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); - verbose("UPDATE:", "updating %s", $h); my ($hostname, $domain) = split(/\./, $h, 2); my $url = "https://$config{$h}{'server'}$config{$h}{'script'}"; $url .= "?hostname=$hostname"; @@ -6928,7 +6915,6 @@ sub nic_gandi_update { } (my $hostname = $h) =~ s/\.\Q$config{$h}{zone}\E$//; info("%s -- Setting IP address to %s.", $h, $ip); - verbose("UPDATE:", "updating %s", $h); my $headers; $headers = "Content-Type: application/json\n"; @@ -7158,7 +7144,6 @@ sub nic_enom_update { for my $h (@_) { my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); - verbose("UPDATE:","updating %s", $h); my $url; $url = "https://$config{$h}{'server'}/interface.asp?Command=SetDNSHost"; From 54d381a18e8d2610aca4765decf944b8aa83bac7 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 27 Jul 2024 16:58:37 -0400 Subject: [PATCH 4/5] nsupdate: Convert some `verbase` log messages to `debug` --- ddclient.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddclient.in b/ddclient.in index 50c1cf2..916371f 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5655,8 +5655,8 @@ EoINSTR4 my $command = "$binary -k $keyfile"; $command .= " -v" if ynu($groupcfg{'tcp'}, 1, 0, 0); $command .= " -d" if (opt('debug')); - verbose("UPDATE:", "nsupdate command is: %s", $command); - verbose("UPDATE:", "nsupdate instructions are:\n%s", $instructions); + debug("nsupdate command: $command"); + debug("nsupdate instructions:\n$instructions"); my $status = pipecmd($command, $instructions); if ($status eq 1) { From 0fa7e132b16ed0212ae7208b451a71d389b8e80a Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 27 Jul 2024 17:11:29 -0400 Subject: [PATCH 5/5] logging: Delete now-unused `verbose` function --- ddclient.in | 1 - 1 file changed, 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index 916371f..99e4095 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2392,7 +2392,6 @@ sub logmsg { } } 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 debug { logmsg( pfx => 'DEBUG:', _logmsg_fmt(@_)) if opt('debug'); } sub debug2 { logmsg( pfx => 'DEBUG:', _logmsg_fmt(@_)) if opt('debug') && opt('verbose'); }