From 2530adb39ebf5a6102280231aac8b03f81c5e5e7 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 24 Jul 2024 15:56:39 -0400 Subject: [PATCH] get_ip: Log message improvements --- ddclient.in | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ddclient.in b/ddclient.in index cc0c7af..4c15373 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2769,7 +2769,7 @@ sub get_ip { if ($use eq 'ip') { $ip = opt('ip', $h); if (!is_ipv4($ip) && !is_ipv6($ip)) { - warning("'%s' is not a valid IPv4 or IPv6 address", $ip // ''); + warning('not a valid IPv4 or IPv6 address: ' . ($ip // '')); $ip = undef; } } elsif ($use eq 'if') { @@ -2822,7 +2822,7 @@ sub get_ip { ) // ''; } } else { - warning("ignoring unsupported '--use=$use'"); + warning("ignoring unsupported '--use' strategy: $use"); } if (!defined $reply) { $reply = ''; @@ -2832,12 +2832,11 @@ sub get_ip { $reply =~ s/^.*?${skip}//is; } $ip //= extract_ipv4($reply) // extract_ipv6($reply); - warning("found neither IPv4 nor IPv6 address") if !defined($ip); if ($use ne 'ip' && ($ip // '') eq '0.0.0.0') { $ip = undef; } - - debug("get_ip: using %s, %s reports %s", $use, $arg // '', $ip // ''); + warning('did not find an IPv4 or IPv6 address') if !defined($ip); + debug("get_ip: using %s, %s reports %s", $use, $arg // '', $ip) if $ip; return $ip; } @@ -3158,7 +3157,7 @@ sub get_ipv4 { ## Static IPv4 address is provided in "ipv4=
" $ipv4 = $arg; if (!is_ipv4($ipv4)) { - warning("'%s' is not a valid IPv4", $ipv4 // ''); + warning('not a valid IPv4 address: ' . ($ipv4 // '')); $ipv4 = undef; } } elsif ($usev4 eq 'ifv4') { @@ -3221,7 +3220,7 @@ sub get_ipv4 { ) // ''; } } else { - warning("ignoring unsupported '--usev4=$usev4'"); + warning("ignoring unsupported '--usev4' strategy: $usev4"); } ## Set to loopback address if no text set yet @@ -3234,8 +3233,8 @@ sub get_ipv4 { $ipv4 //= extract_ipv4($reply); ## Return undef for loopback address unless statically assigned by "ipv4=0.0.0.0" $ipv4 = undef if (($usev4 ne 'ipv4') && (($ipv4 // '') eq '0.0.0.0')); - debug("get_ipv4: using (%s, %s) reports %s", - $usev4, $arg // "", $ipv4 // ""); + warning('did not find an IPv4 address') if !defined($ipv4); + debug("get_ipv4: using (%s, %s) reports %s", $usev4, $arg // "", $ipv4) if $ipv4; return $ipv4; } @@ -3260,7 +3259,7 @@ sub get_ipv6 { } $ipv6 = $arg; if (!is_ipv6($ipv6)) { - warning("'%s' is not a valid IPv6", $ipv6 // ''); + warning('not a valid IPv6 address: ' . ($ipv6 // '')); $ipv6 = undef; } } elsif ($usev6 eq 'ifv6' || $usev6 eq 'if') { @@ -3316,7 +3315,7 @@ sub get_ipv6 { warning("'--usev6=%s' is not implemented and does nothing", $usev6); } } else { - warning("ignoring unsupported '--usev6=$usev6'"); + warning("ignoring unsupported '--usev6' strategy: $usev6"); } ## Set to loopback address if no text set yet @@ -3329,8 +3328,8 @@ sub get_ipv6 { $ipv6 //= extract_ipv6($reply); ## Return undef for loopback address unless statically assigned by "ipv6=::" $ipv6 = undef if (($usev6 ne 'ipv6') && ($usev6 ne 'ip') && (($ipv6 // '') eq '::')); - debug("get_ipv6: using (%s, %s) reports %s", - $usev6, $arg // '', $ipv6 // ''); + warning('did not find an IPv6 address') if !defined($ipv6); + debug("get_ipv6: using (%s, %s) reports %s", $usev6, $arg // '', $ipv6) if $ipv6; return $ipv6; }