Merge pull request #691 from rhansen/fixes

Fix `regfishde` IPv6 support, repeated `infomaniak` force updates, and other minor issues
This commit is contained in:
Richard Hansen 2024-06-25 03:00:20 -04:00 committed by GitHub
commit e0d9bcc36d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 55 additions and 45 deletions

View file

@ -81,6 +81,10 @@ repository history](https://github.com/ddclient/ddclient/commits/master).
[#670](https://github.com/ddclient/ddclient/pull/670) [#670](https://github.com/ddclient/ddclient/pull/670)
* Fixed DNSExit provider when configured with a zone and non-identical * Fixed DNSExit provider when configured with a zone and non-identical
hostname. [#673](https://github.com/ddclient/ddclient/issues/673) 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 ## 2023-11-23 v3.11.2

View file

@ -210,9 +210,9 @@ our %builtinweb = (
sub query_cisco { sub query_cisco {
my ($h, $asa, $v4) = @_; 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))); 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))); if ($v4 && !defined(opt('fwv4')) && defined(opt('fw', $h)));
my $if = ($v4 ? opt('ifv4', $h) : undef) // opt('if', $h); my $if = ($v4 ? opt('ifv4', $h) : undef) // opt('if', $h);
my $fw = ($v4 ? opt('fwv4', $h) : undef) // opt('fw', $h); my $fw = ($v4 ? opt('fwv4', $h) : undef) // opt('fw', $h);
@ -1323,9 +1323,9 @@ sub main {
fatal("invalid argument '--use=%s'; possible values are:\n%s", fatal("invalid argument '--use=%s'; possible values are:\n%s",
$opt{'use'}, join("\n", ip_strategies_usage())) $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'})) { 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())) $opt{'usev6'}, join("\n", ipv6_strategies_usage()))
unless exists $ipv6_strategies{lc opt('usev6')}; unless exists $ipv6_strategies{lc opt('usev6')};
} }
@ -1565,7 +1565,7 @@ sub write_recap {
$recap{$h}{$v} = $config{$h}{$v}; $recap{$h}{$v} = $config{$h}{$v};
} }
} else { } 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}; $recap{$h}{$v} = $config{$h}{$v};
} }
} }
@ -1620,7 +1620,7 @@ sub read_recap {
for my $h (keys(%recap)) { for my $h (keys(%recap)) {
next if !exists($config->{$h}); 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 # 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 # 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 # it better to just delete this and live with the current behavior (which doesn't
@ -2019,8 +2019,8 @@ sub init_config {
HOST: HOST:
for my $h (keys %config) { for my $h (keys %config) {
my $proto = opt('protocol', $h); my $proto = opt('protocol', $h);
load_sha1_support($proto) if (grep(/^$proto$/, ("freedns", "nfsn"))); load_sha1_support($proto) if (grep($_ eq $proto, ("freedns", "nfsn")));
load_json_support($proto) if (grep(/^$proto$/, ("1984", "cloudflare", "digitalocean", "gandi", "godaddy", "hetzner", "yandex", "nfsn", "njalla", "porkbun", "dnsexit2"))); load_json_support($proto) if (grep($_ eq $proto, ("1984", "cloudflare", "digitalocean", "gandi", "godaddy", "hetzner", "yandex", "nfsn", "njalla", "porkbun", "dnsexit2")));
if (!exists($protocols{$proto})) { if (!exists($protocols{$proto})) {
warning("skipping host: %s: unrecognized protocol '%s'", $h, $proto); warning("skipping host: %s: unrecognized protocol '%s'", $h, $proto);
@ -2101,9 +2101,10 @@ sub test_possible_ip {
local $opt{'debug'} = 0; local $opt{'debug'} = 0;
printf "----- Test_possible_ip with 'get_ip' -----\n"; 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'; local $opt{'use'} = 'if';
# Note: The `ip` command adds a `@eth0` suffix to the names of VLAN # Note: The `ip` command adds a `@eth0` suffix to the names of VLAN
@ -2127,7 +2128,7 @@ sub test_possible_ip {
} }
} }
local $opt{'use'} = 'fw'; 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')}; if !exists $builtinfw{opt('fw')};
} }
@ -2147,10 +2148,12 @@ sub test_possible_ip {
# Now force IPv4 # Now force IPv4
printf "----- Test_possible_ip with 'get_ipv4' ------\n"; printf "----- Test_possible_ip with 'get_ipv4' ------\n";
printf "use=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 # Note: The `ip` command adds a `@eth0` suffix to the names of VLAN
# interfaces. That `@eth0` suffix is NOT part of the interface name. # interfaces. That `@eth0` suffix is NOT part of the interface name.
my @ifs = map({ /^[^\s:]*:\s*([^\s:@]+)/ ? $1 : () } my @ifs = map({ /^[^\s:]*:\s*([^\s:@]+)/ ? $1 : () }
@ -2161,30 +2164,32 @@ sub test_possible_ip {
warning("failed to get list of interfaces") if !@ifs; warning("failed to get list of interfaces") if !@ifs;
for my $if (@ifs) { for my $if (@ifs) {
local $opt{'ifv4'} = $if; 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'; local $opt{'usev4'} = 'webv4';
for my $web (sort keys %builtinweb) { for my $web (sort keys %builtinweb) {
local $opt{'webv4'} = $web; 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; 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 ! exists $builtinweb{opt('webv4')};
} }
if (opt('cmdv4')) { if (opt('cmdv4')) {
local $opt{'usev4'} = '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 # Now force IPv6
printf "----- Test_possible_ip with 'get_ipv6' -----\n"; printf "----- Test_possible_ip with 'get_ipv6' -----\n";
printf "use=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 # Note: The `ip` command adds a `@eth0` suffix to the names of VLAN
# interfaces. That `@eth0` suffix is NOT part of the interface name. # interfaces. That `@eth0` suffix is NOT part of the interface name.
my @ifs = map({ /^[^\s:]*:\s*([^\s:@]+)/ ? $1 : () } my @ifs = map({ /^[^\s:]*:\s*([^\s:@]+)/ ? $1 : () }
@ -2195,22 +2200,22 @@ sub test_possible_ip {
warning("failed to get list of interfaces") if !@ifs; warning("failed to get list of interfaces") if !@ifs;
for my $if (@ifs) { for my $if (@ifs) {
local $opt{'ifv6'} = $if; 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'; local $opt{'usev6'} = 'webv6';
for my $web (sort keys %builtinweb) { for my $web (sort keys %builtinweb) {
local $opt{'webv6'} = $web; 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 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 ! exists $builtinweb{opt('webv6')};
} }
if (opt('cmdv6')) { if (opt('cmdv6')) {
local $opt{'usev6'} = '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'); exit 0 unless opt('debug');
@ -3926,7 +3931,7 @@ sub nic_dyndns2_force_update {
info("forcing updating %s because 'mx' has changed to %s.", $host, $config{$host}{'mx'}); info("forcing updating %s because 'mx' has changed to %s.", $host, $config{$host}{'mx'});
$update = 1; $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")); info("forcing updating %s because 'backupmx' has changed to %s.", $host, ynu($config{$host}{'backupmx'}, "YES", "NO", "NO"));
$update = 1; $update = 1;
@ -5242,7 +5247,7 @@ sub nic_njalla_update {
# Read input params # Read input params
my $ipv4 = delete $config{$h}{'wantipv4'}; my $ipv4 = delete $config{$h}{'wantipv4'};
my $ipv6 = delete $config{$h}{'wantipv6'}; my $ipv6 = delete $config{$h}{'wantipv6'};
my $quietreply = delete $config{$h}{'quietreply'}; my $quietreply = $config{$h}{'quietreply'};
my $ip_output = ''; my $ip_output = '';
# Build url # Build url
@ -7699,13 +7704,13 @@ sub nic_regfishde_update {
## update configured host ## update configured host
for my $h (@_) { for my $h (@_) {
my $ip = delete $config{$h}{'wantip'}; my $ipv4 = delete $config{$h}{'wantipv4'};
my $ipv6 = delete $config{$h}{'wantip'}; my $ipv6 = delete $config{$h}{'wantipv6'};
info("regfish.de setting IPv4 address to %s for %s", $ipv4, $h) if $ipv4;
info("regfish.de setting IP address to %s for %s", $ip, $h); 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'}";
my $ipv = ($ip eq ($ipv6 // '')) ? '6' : '4'; $url .= "&ipv4=$ipv4" if $ipv4;
my $url = "https://$config{$h}{'server'}/?fqdn=$h&ipv$ipv=$ip&forcehost=1&token=$config{$h}{'password'}"; $url .= "&ipv6=$ipv6" if $ipv6;
# Try to get URL # Try to get URL
my $reply = geturl(proxy => opt('proxy'), url => $url); my $reply = geturl(proxy => opt('proxy'), url => $url);
@ -7716,16 +7721,17 @@ sub nic_regfishde_update {
last; 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);
$config{$h}{'ip'} = $ip; next;
$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);
} }
$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;
} }
} }
@ -8037,7 +8043,7 @@ sub nic_infomaniak_update {
if (defined $updated && $updated) { if (defined $updated && $updated) {
info($msg); info($msg);
$config{$h}{"ipv$v"} = $ip; $config{$h}{"ipv$v"} = $ip;
$config{$h}{'mtime'} = $config{$h}{'mtime'} // $now; $config{$h}{'mtime'} = $now;
$config{$h}{"status-ipv$v"} = 'good'; $config{$h}{"status-ipv$v"} = 'good';
next INFOMANIAK_IP_LOOP; next INFOMANIAK_IP_LOOP;
} }