From bb65b64e39c4de35952befef513e29c7f24ec76f Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 29 Jul 2024 00:42:03 -0400 Subject: [PATCH 1/3] infomaniak: Whitespace fixes --- ddclient.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ddclient.in b/ddclient.in index 6658bae..7f48f98 100755 --- a/ddclient.in +++ b/ddclient.in @@ -7331,9 +7331,9 @@ sub nic_infomaniak_update { # IP changed => good # No domain name => Validation failed my %statuses = ( - 'good' => (1, sprintf("IP set to %s for %s", $ip, $h)), - 'nochg' => (1, sprintf("IP already set to %s for %s", $ip, $h)), - 'nohost' => (0, sprintf("Bad domain name %s or bad IP %s", $h, $ip)), + 'good' => (1, sprintf("IP set to %s for %s", $ip, $h)), + 'nochg' => (1, sprintf("IP already set to %s for %s", $ip, $h)), + 'nohost' => (0, sprintf("Bad domain name %s or bad IP %s", $h, $ip)), 'badauth' => (0, sprintf("Bad authentication for %s", $h)), ); my $reply = geturl( From 3f0fd0f37b6a54ffac3223d3ab9c8214f27a67a0 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 29 Jul 2024 00:44:36 -0400 Subject: [PATCH 2/3] infomaniak: Use variable interpolation instead of `sprintf` for readability. --- ddclient.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ddclient.in b/ddclient.in index 7f48f98..017d808 100755 --- a/ddclient.in +++ b/ddclient.in @@ -7320,7 +7320,7 @@ sub nic_infomaniak_update { for my $v (4, 6) { my $ip = delete $config{$h}{"wantipv$v"}; if (!defined $ip) { - debug("ipv%d not wanted, skipping", $v); + debug("IPv$v not wanted, skipping"); next; } info("setting IP address to %s for %s", $ip, $h); @@ -7331,10 +7331,10 @@ sub nic_infomaniak_update { # IP changed => good # No domain name => Validation failed my %statuses = ( - 'good' => (1, sprintf("IP set to %s for %s", $ip, $h)), - 'nochg' => (1, sprintf("IP already set to %s for %s", $ip, $h)), - 'nohost' => (0, sprintf("Bad domain name %s or bad IP %s", $h, $ip)), - 'badauth' => (0, sprintf("Bad authentication for %s", $h)), + 'good' => (1, "IP set to $ip for $h"), + 'nochg' => (1, "IP already set to $ip for $h"), + 'nohost' => (0, "Bad domain name $h or bad IP $ip"), + 'badauth' => (0, "Bad authentication for $h"), ); my $reply = geturl( proxy => opt('proxy'), @@ -7346,7 +7346,7 @@ sub nic_infomaniak_update { (my $body = $reply) =~ s/^.*?\n\n//s; my ($status) = split(/ /, $body, 2); my ($ok, $msg) = - $statuses{$status} // (0, sprintf("Unknown reply from Infomaniak: %s", $body)); + $statuses{$status} // (0, "Unknown reply from Infomaniak: $body"); if (!$ok) { failed($msg); next; From d380e17aba93a94f12da55907379b4bc3f931021 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 29 Jul 2024 00:56:55 -0400 Subject: [PATCH 3/3] infomaniak: Fix response status processing Previously, `nochg` responses were treated as failures and the logged message for all responses was incorrect (either `undef` or "Unknown reply from Infomaniak"). Background: Hash values are always scalars, so lists of values can only be stored in hashes in arrayref form. The following is legal but does not do what one might expect: my %h = ( a => (1, 2), b => (3, 4), ); The `=>` operator is just a variant of the comma operator, and lists in list context are flattened, so the above is equivalent to: my %h = ('a', 1, 2, 'b', 3, 4); which is equivalent to: my %h = ( a => 1, 2 => 'b', 3 => 4, ); which is obviously not what was intended. --- ChangeLog.md | 2 ++ ddclient.in | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index f7b0f67..e7f8358 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -126,6 +126,8 @@ repository history](https://github.com/ddclient/ddclient/commits/master). [#691](https://github.com/ddclient/ddclient/pull/691) * `infomaniak`: Fixed incorrect parsing of server response. [#692](https://github.com/ddclient/ddclient/pull/692) + * `infomaniak`: Fixed incorrect handling of `nochg` responses. + [#723](https://github.com/ddclient/ddclient/pull/723) * `regfishde`: Fixed IPv6 support. [#691](https://github.com/ddclient/ddclient/pull/691) * `easydns`: IPv4 and IPv6 addresses are now updated separately to be diff --git a/ddclient.in b/ddclient.in index 017d808..5e5fa16 100755 --- a/ddclient.in +++ b/ddclient.in @@ -7331,10 +7331,10 @@ sub nic_infomaniak_update { # IP changed => good # No domain name => Validation failed my %statuses = ( - 'good' => (1, "IP set to $ip for $h"), - 'nochg' => (1, "IP already set to $ip for $h"), - 'nohost' => (0, "Bad domain name $h or bad IP $ip"), - 'badauth' => (0, "Bad authentication for $h"), + 'good' => [1, "IP set to $ip for $h"], + 'nochg' => [1, "IP already set to $ip for $h"], + 'nohost' => [0, "Bad domain name $h or bad IP $ip"], + 'badauth' => [0, "Bad authentication for $h"], ); my $reply = geturl( proxy => opt('proxy'), @@ -7346,7 +7346,7 @@ sub nic_infomaniak_update { (my $body = $reply) =~ s/^.*?\n\n//s; my ($status) = split(/ /, $body, 2); my ($ok, $msg) = - $statuses{$status} // (0, "Unknown reply from Infomaniak: $body"); + @{$statuses{$status} // [0, "Unknown reply from Infomaniak: $body"]}; if (!$ok) { failed($msg); next;