From b363fb48a51fd902335c0c99cd9a992cf1f8c4cf Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 13 Jun 2024 03:55:01 -0400 Subject: [PATCH 01/12] Fix string equality check The `$proto` interpolation wasn't quoted with `\Q` and `\E`, so metacharacters in `$proto` could break the matching. Switch from a regex to an expression to fix the equality check and improve readability. --- ddclient.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddclient.in b/ddclient.in index 0f4cf74..c0bec0f 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2019,8 +2019,8 @@ sub init_config { HOST: for my $h (keys %config) { my $proto = opt('protocol', $h); - load_sha1_support($proto) if (grep(/^$proto$/, ("freedns", "nfsn"))); - load_json_support($proto) if (grep(/^$proto$/, ("1984", "cloudflare", "digitalocean", "gandi", "godaddy", "hetzner", "yandex", "nfsn", "njalla", "porkbun", "dnsexit2"))); + load_sha1_support($proto) if (grep($_ eq $proto, ("freedns", "nfsn"))); + load_json_support($proto) if (grep($_ eq $proto, ("1984", "cloudflare", "digitalocean", "gandi", "godaddy", "hetzner", "yandex", "nfsn", "njalla", "porkbun", "dnsexit2"))); if (!exists($protocols{$proto})) { warning("skipping host: %s: unrecognized protocol '%s'", $h, $proto); From e1e8d5711aa39d0ac63fd9a337958f0dc53d41d6 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 13 Jun 2024 22:47:58 -0400 Subject: [PATCH 02/12] Fix `get_ip` argument in `--query` when testing `--fw` --- ddclient.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index c0bec0f..f9a1222 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2127,7 +2127,7 @@ sub test_possible_ip { } } local $opt{'use'} = 'fw'; - printf "use=fw, fw=%s address is %s\n", opt('fw'), get_ip(opt('fw')) // 'NOT FOUND' + printf "use=fw, fw=%s address is %s\n", opt('fw'), get_ip('fw') // 'NOT FOUND' if !exists $builtinfw{opt('fw')}; } From 27b50a3b93e5752836b0747e34802a92de4d84ed Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 14 Jun 2024 00:54:27 -0400 Subject: [PATCH 03/12] Fix `--usev4=cisco`, `--usev4=cisco-asa` warning messages --- ddclient.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddclient.in b/ddclient.in index f9a1222..4a05159 100755 --- a/ddclient.in +++ b/ddclient.in @@ -210,9 +210,9 @@ our %builtinweb = ( sub query_cisco { my ($h, $asa, $v4) = @_; - warning("'--if' is deprecated for '--usev4=ifv4; use '--ifv4' instead") + warning("'--if' is deprecated for '--usev4=cisco%s; use '--ifv4' instead", $asa ? '-asa' : '') if ($v4 && !defined(opt('ifv4')) && defined(opt('if', $h))); - warning("'--fw' is deprecated for '--usev4=fwv4; use '--fwv4' instead") + warning("'--fw' is deprecated for '--usev4=cisco%s; use '--fwv4' instead", $asa ? '-asa' : '') if ($v4 && !defined(opt('fwv4')) && defined(opt('fw', $h))); my $if = ($v4 ? opt('ifv4', $h) : undef) // opt('if', $h); my $fw = ($v4 ? opt('fwv4', $h) : undef) // opt('fw', $h); From c7c8c5f097e187fe7569cff3fe7e812b5fbd4df7 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 14 Jun 2024 03:48:15 -0400 Subject: [PATCH 04/12] Fix `usev4`, `usev6` output for `--query` --- ddclient.in | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ddclient.in b/ddclient.in index 4a05159..760509e 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2147,7 +2147,7 @@ sub test_possible_ip { # Now force IPv4 printf "----- Test_possible_ip with 'get_ipv4' ------\n"; - printf "use=ipv4, ipv4=%s address is %s\n", opt('ipv4'), get_ipv4('ipv4') // 'NOT FOUND' + printf "usev4=ipv4, ipv4=%s address is %s\n", opt('ipv4'), get_ipv4('ipv4') // 'NOT FOUND' if defined opt('ipv4'); { @@ -2161,27 +2161,27 @@ sub test_possible_ip { warning("failed to get list of interfaces") if !@ifs; for my $if (@ifs) { local $opt{'ifv4'} = $if; - printf "use=ifv4, ifv4=%s address is %s\n", opt('ifv4'), get_ipv4('ifv4') // 'NOT FOUND'; + printf "usev4=ifv4, ifv4=%s address is %s\n", opt('ifv4'), get_ipv4('ifv4') // 'NOT FOUND'; } } { local $opt{'usev4'} = 'webv4'; for my $web (sort keys %builtinweb) { local $opt{'webv4'} = $web; - printf "use=webv4, webv4=$web address is %s\n", get_ipv4('webv4') // 'NOT FOUND' + printf "usev4=webv4, webv4=$web address is %s\n", get_ipv4('webv4') // 'NOT FOUND' if ($web !~ "6") ## Don't bother if web site only supports IPv6; } - printf "use=webv4, webv4=%s address is %s\n", opt('webv4'), get_ipv4('webv4') // 'NOT FOUND' + printf "usev4=webv4, webv4=%s address is %s\n", opt('webv4'), get_ipv4('webv4') // 'NOT FOUND' if ! exists $builtinweb{opt('webv4')}; } if (opt('cmdv4')) { local $opt{'usev4'} = 'cmdv4'; - printf "use=cmdv4, cmdv4=%s address is %s\n", opt('cmdv4'), get_ipv4('cmdv4') // 'NOT FOUND'; + printf "usev4=cmdv4, cmdv4=%s address is %s\n", opt('cmdv4'), get_ipv4('cmdv4') // 'NOT FOUND'; } # Now force IPv6 printf "----- Test_possible_ip with 'get_ipv6' -----\n"; - printf "use=ipv6, ipv6=%s address is %s\n", opt('ipv6'), get_ipv6('ipv6') // 'NOT FOUND' + printf "usev6=ipv6, ipv6=%s address is %s\n", opt('ipv6'), get_ipv6('ipv6') // 'NOT FOUND' if defined opt('ipv6'); { @@ -2195,22 +2195,22 @@ sub test_possible_ip { warning("failed to get list of interfaces") if !@ifs; for my $if (@ifs) { local $opt{'ifv6'} = $if; - printf "use=ifv6, ifv6=%s address is %s\n", opt('ifv6'), get_ipv6('ifv6') // 'NOT FOUND'; + printf "usev6=ifv6, ifv6=%s address is %s\n", opt('ifv6'), get_ipv6('ifv6') // 'NOT FOUND'; } } { local $opt{'usev6'} = 'webv6'; for my $web (sort keys %builtinweb) { local $opt{'webv6'} = $web; - printf "use=webv6, webv6=$web address is %s\n", get_ipv6('webv6') // 'NOT FOUND' + printf "usev6=webv6, webv6=$web address is %s\n", get_ipv6('webv6') // 'NOT FOUND' if ($web !~ "4"); ## Don't bother if web site only supports IPv4 } - printf "use=webv6, webv6=%s address is %s\n", opt('webv6'), get_ipv6('webv6') // 'NOT FOUND' + printf "usev6=webv6, webv6=%s address is %s\n", opt('webv6'), get_ipv6('webv6') // 'NOT FOUND' if ! exists $builtinweb{opt('webv6')}; } if (opt('cmdv6')) { local $opt{'usev6'} = 'cmdv6'; - printf "use=cmdv6, cmdv6=%s address is %s\n", opt('cmdv6'), get_ipv6('cmdv6') // 'NOT FOUND'; + printf "usev6=cmdv6, cmdv6=%s address is %s\n", opt('cmdv6'), get_ipv6('cmdv6') // 'NOT FOUND'; } exit 0 unless opt('debug'); From 7ac6eda7cc5212f8c9608a4f343f38cdaca5c234 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 14 Jun 2024 03:51:23 -0400 Subject: [PATCH 05/12] Fix missing local `use*` override in `--query` --- ddclient.in | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ddclient.in b/ddclient.in index 760509e..ec768e2 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2101,9 +2101,10 @@ sub test_possible_ip { local $opt{'debug'} = 0; printf "----- Test_possible_ip with 'get_ip' -----\n"; - printf "use=ip, ip=%s address is %s\n", opt('ip'), get_ip('ip') // 'NOT FOUND' - if defined opt('ip'); - + if (defined(opt('ip'))) { + local $opt{'use'} = 'ip'; + printf "use=ip, ip=%s address is %s\n", opt('ip'), get_ip('ip') // 'NOT FOUND'; + } { local $opt{'use'} = 'if'; # Note: The `ip` command adds a `@eth0` suffix to the names of VLAN @@ -2147,10 +2148,12 @@ sub test_possible_ip { # Now force IPv4 printf "----- Test_possible_ip with 'get_ipv4' ------\n"; - printf "usev4=ipv4, ipv4=%s address is %s\n", opt('ipv4'), get_ipv4('ipv4') // 'NOT FOUND' - if defined opt('ipv4'); - + if (defined(opt('ipv4'))) { + local $opt{'usev4'} = 'ipv4'; + printf "usev4=ipv4, ipv4=%s address is %s\n", opt('ipv4'), get_ipv4('ipv4') // 'NOT FOUND'; + } { + local $opt{'usev4'} = 'ifv4'; # Note: The `ip` command adds a `@eth0` suffix to the names of VLAN # interfaces. That `@eth0` suffix is NOT part of the interface name. my @ifs = map({ /^[^\s:]*:\s*([^\s:@]+)/ ? $1 : () } @@ -2181,10 +2184,12 @@ sub test_possible_ip { # Now force IPv6 printf "----- Test_possible_ip with 'get_ipv6' -----\n"; - printf "usev6=ipv6, ipv6=%s address is %s\n", opt('ipv6'), get_ipv6('ipv6') // 'NOT FOUND' - if defined opt('ipv6'); - + if (defined(opt('ipv6'))) { + local $opt{'usev6'} = 'ipv6'; + printf "usev6=ipv6, ipv6=%s address is %s\n", opt('ipv6'), get_ipv6('ipv6') // 'NOT FOUND'; + } { + local $opt{'usev6'} = 'ifv6'; # Note: The `ip` command adds a `@eth0` suffix to the names of VLAN # interfaces. That `@eth0` suffix is NOT part of the interface name. my @ifs = map({ /^[^\s:]*:\s*([^\s:@]+)/ ? $1 : () } From dafde8becb72ee4ef1557e6f6f23da68b3095589 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 15 Jun 2024 19:12:45 -0400 Subject: [PATCH 06/12] Fix erroneous `backupmx` recap check for `dyndns1`, `dyndns2` --- ddclient.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index ec768e2..473d8e6 100755 --- a/ddclient.in +++ b/ddclient.in @@ -3931,7 +3931,7 @@ sub nic_dyndns2_force_update { info("forcing updating %s because 'mx' has changed to %s.", $host, $config{$host}{'mx'}); $update = 1; - } elsif ($config{$host}{'mx'} && (ynu($config{$host}{'backupmx'}, 1, 2, 3) ne ynu($config{$host}{'backupmx'}, 1, 2, 3))) { + } elsif ($config{$host}{'mx'} && (ynu($config{$host}{'backupmx'}, 1, 2, 3) ne ynu($recap{$host}{'backupmx'}, 1, 2, 3))) { info("forcing updating %s because 'backupmx' has changed to %s.", $host, ynu($config{$host}{'backupmx'}, "YES", "NO", "NO")); $update = 1; From b154d8ef98b48f93acdc83befb99003abd492b24 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 15 Jun 2024 20:46:48 -0400 Subject: [PATCH 07/12] Fix missing v4, v6 variants in recap update Fixes an oversight when IPv6 support was added. --- ddclient.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddclient.in b/ddclient.in index 473d8e6..38481a3 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1565,7 +1565,7 @@ sub write_recap { $recap{$h}{$v} = $config{$h}{$v}; } } else { - for my $v (qw(atime wtime status)) { + for my $v (qw(atime wtime status status-ipv4 status-ivp6)) { $recap{$h}{$v} = $config{$h}{$v}; } } @@ -1620,7 +1620,7 @@ sub read_recap { for my $h (keys(%recap)) { next if !exists($config->{$h}); - for (qw(atime mtime wtime ip status)) { + for (qw(atime mtime wtime ip ipv4 ipv6 status status-ipv4 status-ipv6)) { # TODO: Isn't $config equal to \%recap here? If so, this is a no-op. What was the # original intention behind this? To copy %recap values into %config? If so, is # it better to just delete this and live with the current behavior (which doesn't From 99dfd7f84d3ca6d7f4353687a6754a8488e51c3a Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 21 Jun 2024 21:43:25 -0400 Subject: [PATCH 08/12] Don't assume that `--use` is defined --- ddclient.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index 38481a3..e3827f8 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1323,7 +1323,7 @@ sub main { fatal("invalid argument '--use=%s'; possible values are:\n%s", $opt{'use'}, join("\n", ip_strategies_usage())) - unless exists $ip_strategies{lc opt('use')}; + if defined(opt('use')) && !$ip_strategies{lc(opt('use'))}; if (defined($opt{'usev6'})) { usage("invalid argument '--usev6=%s'; possible values are:\n%s", $opt{'usev6'}, join("\n", ipv6_strategies_usage())) From 32bf975bfae15d764f4e9eaa71f7c75b0336c094 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 21 Jun 2024 21:45:02 -0400 Subject: [PATCH 09/12] Fix call to wrong function name with bad `--usev6` --- ddclient.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index e3827f8..c3fdded 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1325,7 +1325,7 @@ sub main { $opt{'use'}, join("\n", ip_strategies_usage())) if defined(opt('use')) && !$ip_strategies{lc(opt('use'))}; if (defined($opt{'usev6'})) { - usage("invalid argument '--usev6=%s'; possible values are:\n%s", + fatal("invalid argument '--usev6=%s'; possible values are:\n%s", $opt{'usev6'}, join("\n", ipv6_strategies_usage())) unless exists $ipv6_strategies{lc opt('usev6')}; } From 61577d29ae4a04e23a55839c7a0e17853bc3dae4 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 15 Jun 2024 19:35:57 -0400 Subject: [PATCH 10/12] njalla: Fix configuration change during update If the user enabled `quietreply`, it should not become false after the first update. Users might not notice a problem because I think ddclient re-reads the config file before every check. --- ddclient.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index c3fdded..7f20bdc 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5247,7 +5247,7 @@ sub nic_njalla_update { # Read input params my $ipv4 = delete $config{$h}{'wantipv4'}; my $ipv6 = delete $config{$h}{'wantipv6'}; - my $quietreply = delete $config{$h}{'quietreply'}; + my $quietreply = $config{$h}{'quietreply'}; my $ip_output = ''; # Build url From 0cde2e3f96d51fda5def045c6f53aa7e442887fe Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 21 Jun 2024 00:04:50 -0400 Subject: [PATCH 11/12] infomaniak: Fix `mtime` update `mtime` should always be updated whenever the IP address is updated, otherwise ddclient will keep force updating over and over. --- ChangeLog.md | 2 ++ ddclient.in | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 6ac8d0c..6431684 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -81,6 +81,8 @@ repository history](https://github.com/ddclient/ddclient/commits/master). [#670](https://github.com/ddclient/ddclient/pull/670) * Fixed DNSExit provider when configured with a zone and non-identical hostname. [#673](https://github.com/ddclient/ddclient/issues/673) + * `infomaniak`: Fixed frequent forced updates after 25 days (`max-interval`). + [#691](https://github.com/ddclient/ddclient/issues/691) ## 2023-11-23 v3.11.2 diff --git a/ddclient.in b/ddclient.in index 7f20bdc..29fca39 100755 --- a/ddclient.in +++ b/ddclient.in @@ -8042,7 +8042,7 @@ sub nic_infomaniak_update { if (defined $updated && $updated) { info($msg); $config{$h}{"ipv$v"} = $ip; - $config{$h}{'mtime'} = $config{$h}{'mtime'} // $now; + $config{$h}{'mtime'} = $now; $config{$h}{"status-ipv$v"} = 'good'; next INFOMANIAK_IP_LOOP; } From 9d49a33ac620a99b76b5651fb46d2c8d3639e7c9 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 21 Jun 2024 01:15:51 -0400 Subject: [PATCH 12/12] regfishde: Fix IPv6 support --- ChangeLog.md | 2 ++ ddclient.in | 33 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 6431684..8f1eba9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -83,6 +83,8 @@ repository history](https://github.com/ddclient/ddclient/commits/master). hostname. [#673](https://github.com/ddclient/ddclient/issues/673) * `infomaniak`: Fixed frequent forced updates after 25 days (`max-interval`). [#691](https://github.com/ddclient/ddclient/issues/691) + * `regfishde`: Fixed IPv6 support. + [#691](https://github.com/ddclient/ddclient/issues/691) ## 2023-11-23 v3.11.2 diff --git a/ddclient.in b/ddclient.in index 29fca39..88419a6 100755 --- a/ddclient.in +++ b/ddclient.in @@ -7704,13 +7704,13 @@ sub nic_regfishde_update { ## update configured host for my $h (@_) { - my $ip = delete $config{$h}{'wantip'}; - my $ipv6 = delete $config{$h}{'wantip'}; - - info("regfish.de setting IP address to %s for %s", $ip, $h); - - my $ipv = ($ip eq ($ipv6 // '')) ? '6' : '4'; - my $url = "https://$config{$h}{'server'}/?fqdn=$h&ipv$ipv=$ip&forcehost=1&token=$config{$h}{'password'}"; + my $ipv4 = delete $config{$h}{'wantipv4'}; + my $ipv6 = delete $config{$h}{'wantipv6'}; + info("regfish.de setting IPv4 address to %s for %s", $ipv4, $h) if $ipv4; + info("regfish.de setting IPv6 address to %s for %s", $ipv6, $h) if $ipv6; + my $url = "https://$config{$h}{'server'}/?fqdn=$h&forcehost=1&token=$config{$h}{'password'}"; + $url .= "&ipv4=$ipv4" if $ipv4; + $url .= "&ipv6=$ipv6" if $ipv6; # Try to get URL my $reply = geturl(proxy => opt('proxy'), url => $url); @@ -7721,16 +7721,17 @@ sub nic_regfishde_update { last; } last if !header_ok($h, $reply); - - if ($reply =~ /success/) { - $config{$h}{'ip'} = $ip; - $config{$h}{'mtime'} = $now; - $config{$h}{'status'} = 'good'; - success("updating %s: good: IP address set to %s", $h, $ip); - } else { - $config{$h}{'status'} = 'failed'; - failed("updating %s: Server said: '$reply'", $h); + if ($reply !~ /success/) { + failed("updating %s: Server said: '%s'", $h, $reply); + next; } + $config{$h}{'ipv4'} = $ipv4 if $ipv4; + $config{$h}{'ipv6'} = $ipv6 if $ipv6; + $config{$h}{'status-ipv4'} = 'good' if $ipv4; + $config{$h}{'status-ipv6'} = 'good' if $ipv6; + $config{$h}{'mtime'} = $now; + success("updating %s: good: IPv4 address set to %s", $h, $ipv4) if $ipv4; + success("updating %s: good: IPv6 address set to %s", $h, $ipv6) if $ipv6; } }