infomaniak: Fix geturl call
* Pass login and password via `login` and `password` options to avoid issues with escaping special characters. * Don't attempt twice -- if the first attempt fails, the second will almost certainly fail as well. (The two attempted URLs were equivalent, differing only in how the login and password were passed.)
This commit is contained in:
parent
ac9f937c88
commit
a5dedeed3c
1 changed files with 21 additions and 31 deletions
52
ddclient.in
52
ddclient.in
|
@ -7990,7 +7990,6 @@ EoEXAMPLE
|
|||
sub nic_infomaniak_update {
|
||||
debug("\nnic_infomaniak_update -------------------");
|
||||
for my $h (@_) {
|
||||
INFOMANIAK_IP_LOOP:
|
||||
for my $v (4, 6) {
|
||||
my $ip = delete $config{$h}{"wantipv$v"};
|
||||
if (!defined $ip) {
|
||||
|
@ -8010,37 +8009,28 @@ sub nic_infomaniak_update {
|
|||
'nohost' => (0, sprintf("Bad domain name %s or bad IP %s", $h, $ip)),
|
||||
'badauth' => (0, sprintf("Bad authentication for %s", $h)),
|
||||
);
|
||||
my $url1 = "https://$config{$h}{'login'}:$config{$h}{'password'}";
|
||||
$url1 .= "\@infomaniak.com/nic/update";
|
||||
$url1 .= "?hostname=$h";
|
||||
$url1 .= "&myip=$ip";
|
||||
my $url2 = "https://infomaniak.com/nic/update";
|
||||
$url2 .= "?hostname=$h";
|
||||
$url2 .= "&myip=$ip";
|
||||
$url2 .= "&username=$config{$h}{'login'}";
|
||||
$url2 .= "&password=$config{$h}{'password'}";
|
||||
for my $url ($url1, $url2) {
|
||||
info("trying update with %s", $url);
|
||||
my $reply = geturl(proxy => opt('proxy'), url => $url);
|
||||
if (!$reply) {
|
||||
info("could not update %s using url %s, trying next one", $h, $url);
|
||||
next;
|
||||
}
|
||||
my ($status) = split / /, $reply, 1;
|
||||
my ($updated, $msg) =
|
||||
$statuses{$status} // (0, sprintf("Unknown reply from Infomaniak: %s", $reply));
|
||||
if ($updated) {
|
||||
info($msg);
|
||||
$config{$h}{"ipv$v"} = $ip;
|
||||
$config{$h}{'mtime'} = $now;
|
||||
$config{$h}{"status-ipv$v"} = 'good';
|
||||
next INFOMANIAK_IP_LOOP;
|
||||
} else {
|
||||
warning($msg);
|
||||
}
|
||||
my $reply = geturl(
|
||||
proxy => opt('proxy'),
|
||||
url => "https://infomaniak.com/nic/update?hostname=$h&myip=$ip",
|
||||
login => $config{$h}{'login'},
|
||||
password => $config{$h}{'password'},
|
||||
);
|
||||
if (!$reply) {
|
||||
failed("could not update %s", $h);
|
||||
next;
|
||||
}
|
||||
my ($status) = split / /, $reply, 1;
|
||||
my ($updated, $msg) =
|
||||
$statuses{$status} // (0, sprintf("Unknown reply from Infomaniak: %s", $reply));
|
||||
if ($updated) {
|
||||
success($msg);
|
||||
$config{$h}{"ipv$v"} = $ip;
|
||||
$config{$h}{'mtime'} = $now;
|
||||
$config{$h}{"status-ipv$v"} = 'good';
|
||||
next;
|
||||
} else {
|
||||
failed($msg);
|
||||
}
|
||||
$config{$h}{"status-ipv$v"} = 'failed';
|
||||
failed("updating %s: could not update IP on Infomaniak", $h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue