fix(curl, doc): enable HTTP 30x redirections in curl requests. Fixes Issue #589
- curl: enable a configurable number of redirections (-redirects=<max>) to follow when making HTTP(S) requests. - docs: update Infomaniak example to prefer 'dyndns2' instead of obsolete protocol. Signed-off-by: Marco Emilio "sphakka" Poleggi <7766137+sphakka@users.noreply.github.com>
This commit is contained in:
parent
203fe47aa1
commit
dc84a74c7e
2 changed files with 36 additions and 5 deletions
|
@ -370,3 +370,12 @@ ssl=yes # use ssl-support. Works with
|
||||||
# login=ddns_username,
|
# login=ddns_username,
|
||||||
# password=ddns_password
|
# password=ddns_password
|
||||||
# example.com
|
# example.com
|
||||||
|
#
|
||||||
|
# N.B. the infomaniak protocol is obsolete. Please use dyndns2 instead:
|
||||||
|
#
|
||||||
|
# protocol=dyndns2,
|
||||||
|
# use=web, web=infomaniak.com/ip.php/
|
||||||
|
# login=ddns_username,
|
||||||
|
# password=ddns_password
|
||||||
|
# redirect=2
|
||||||
|
# example.com
|
||||||
|
|
22
ddclient.in
22
ddclient.in
|
@ -472,6 +472,7 @@ my %variables = (
|
||||||
'postscript' => setv(T_POSTS, 0, 0, '', undef),
|
'postscript' => setv(T_POSTS, 0, 0, '', undef),
|
||||||
'ssl_ca_dir' => setv(T_FILE, 0, 0, undef, undef),
|
'ssl_ca_dir' => setv(T_FILE, 0, 0, undef, undef),
|
||||||
'ssl_ca_file' => setv(T_FILE, 0, 0, undef, undef),
|
'ssl_ca_file' => setv(T_FILE, 0, 0, undef, undef),
|
||||||
|
'redirect' => setv(T_NUMBER,0, 0, 0, undef)
|
||||||
},
|
},
|
||||||
'service-common-defaults' => {
|
'service-common-defaults' => {
|
||||||
'server' => setv(T_FQDNP, 1, 0, 'members.dyndns.org', undef),
|
'server' => setv(T_FQDNP, 1, 0, 'members.dyndns.org', undef),
|
||||||
|
@ -1095,6 +1096,7 @@ my @opt = (
|
||||||
["if-skip", "=s", ""], ## deprecated
|
["if-skip", "=s", ""], ## deprecated
|
||||||
["test", "!", ""], ## hidden
|
["test", "!", ""], ## hidden
|
||||||
["geturl", "=s", ""], ## hidden
|
["geturl", "=s", ""], ## hidden
|
||||||
|
["redirect", "=i", "-redirect <max> : enable and follow at most <max> HTTP 30x redirections"],
|
||||||
"",
|
"",
|
||||||
nic_examples(),
|
nic_examples(),
|
||||||
"$program version $version, ",
|
"$program version $version, ",
|
||||||
|
@ -2590,6 +2592,7 @@ sub geturl {
|
||||||
my $use_ssl = 0;
|
my $use_ssl = 0;
|
||||||
my $protocol;
|
my $protocol;
|
||||||
my $timeout = opt('timeout');
|
my $timeout = opt('timeout');
|
||||||
|
my $redirect = opt('redirect');
|
||||||
my @curlopt = ();
|
my @curlopt = ();
|
||||||
my @header_lines = ();
|
my @header_lines = ();
|
||||||
|
|
||||||
|
@ -2648,6 +2651,12 @@ sub geturl {
|
||||||
# Add in the data if any was provided (for POST/PATCH)
|
# Add in the data if any was provided (for POST/PATCH)
|
||||||
push(@curlopt, "data=\"".escape_curl_param(${data}).'"') if ($data);
|
push(@curlopt, "data=\"".escape_curl_param(${data}).'"') if ($data);
|
||||||
|
|
||||||
|
# Handle 30x redirections
|
||||||
|
if ($redirect) {
|
||||||
|
push(@curlopt, "location");
|
||||||
|
push(@curlopt, "max-redirs=$redirect");
|
||||||
|
}
|
||||||
|
|
||||||
# don't include ${url} as that might expose login credentials
|
# don't include ${url} as that might expose login credentials
|
||||||
$0 = sprintf("%s - Curl system cmd sending to %s", $program, "${protocol}://${server}");
|
$0 = sprintf("%s - Curl system cmd sending to %s", $program, "${protocol}://${server}");
|
||||||
verbose("SENDING:", "Curl system cmd to %s", "${protocol}://${server}");
|
verbose("SENDING:", "Curl system cmd to %s", "${protocol}://${server}");
|
||||||
|
@ -7814,6 +7823,8 @@ sub nic_infomaniak_examples {
|
||||||
|
|
||||||
o 'infomaniak'
|
o 'infomaniak'
|
||||||
|
|
||||||
|
**Note** The 'infomaniak' protocol is obsolete [*].
|
||||||
|
|
||||||
The 'infomaniak' protocol is used by DNS services offered by www.infomaniak.com.
|
The 'infomaniak' protocol is used by DNS services offered by www.infomaniak.com.
|
||||||
|
|
||||||
Configuration variables applicable to the 'infomaniak' protocol are:
|
Configuration variables applicable to the 'infomaniak' protocol are:
|
||||||
|
@ -7830,6 +7841,17 @@ Example ${program}.conf file entries:
|
||||||
|
|
||||||
For more information about how to create a dynamic DNS, see https://faq.infomaniak.com/2357.
|
For more information about how to create a dynamic DNS, see https://faq.infomaniak.com/2357.
|
||||||
|
|
||||||
|
[*] Infomaniak DynDNS services (both IP discovery and update) can be used with the standard
|
||||||
|
'dyndns2' protocol. See <https://faq.infomaniak.com/40>. Notice that a minimum number of HTTP
|
||||||
|
redirections (usally 2) might be needed.
|
||||||
|
|
||||||
|
Example ${program}.conf file entries:
|
||||||
|
protocol=dyndns2, \\
|
||||||
|
use=web, web=infomaniak.com/ip.php/ \\
|
||||||
|
login=my-username, \\
|
||||||
|
password=my-password \\
|
||||||
|
redirect=2
|
||||||
|
my.address.com
|
||||||
EoEXAMPLE
|
EoEXAMPLE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue