Merge pull request #254 from rhansen/geturl
Eliminate unnecessary hashref
This commit is contained in:
commit
2e1bb5165a
3 changed files with 64 additions and 65 deletions
124
ddclient.in
124
ddclient.in
|
@ -1539,12 +1539,12 @@ sub test_possible_ip {
|
||||||
sub test_geturl {
|
sub test_geturl {
|
||||||
my $url = shift;
|
my $url = shift;
|
||||||
|
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
login => opt('login'),
|
login => opt('login'),
|
||||||
password => opt('password'),
|
password => opt('password'),
|
||||||
});
|
);
|
||||||
print "URL $url\n";
|
print "URL $url\n";
|
||||||
print $reply // "<undefined>\n";
|
print $reply // "<undefined>\n";
|
||||||
exit;
|
exit;
|
||||||
|
@ -2004,15 +2004,15 @@ EOM
|
||||||
## geturl
|
## geturl
|
||||||
######################################################################
|
######################################################################
|
||||||
sub geturl {
|
sub geturl {
|
||||||
my ($params) = @_;
|
my %params = @_;
|
||||||
my $proxy = $params->{proxy};
|
my $proxy = $params{proxy};
|
||||||
my $url = $params->{url};
|
my $url = $params{url};
|
||||||
my $login = $params->{login};
|
my $login = $params{login};
|
||||||
my $password = $params->{password};
|
my $password = $params{password};
|
||||||
my $ipversion = $params->{ipversion} // '';
|
my $ipversion = $params{ipversion} // '';
|
||||||
my $headers = $params->{headers} // '';
|
my $headers = $params{headers} // '';
|
||||||
my $method = $params->{method} // 'GET';
|
my $method = $params{method} // 'GET';
|
||||||
my $data = $params->{data} // '';
|
my $data = $params{data} // '';
|
||||||
my ($peer, $server, $port, $default_port, $use_ssl);
|
my ($peer, $server, $port, $default_port, $use_ssl);
|
||||||
my ($sd, $request, $reply);
|
my ($sd, $request, $reply);
|
||||||
|
|
||||||
|
@ -2025,7 +2025,7 @@ sub geturl {
|
||||||
$server =~ s%[?/].*%%;
|
$server =~ s%[?/].*%%;
|
||||||
$url =~ s%^[^?/]*/?%%;
|
$url =~ s%^[^?/]*/?%%;
|
||||||
|
|
||||||
if ($force_ssl || ($globals{'ssl'} && !($params->{ignore_ssl_option} // 0))) {
|
if ($force_ssl || ($globals{'ssl'} && !($params{ignore_ssl_option} // 0))) {
|
||||||
$use_ssl = 1;
|
$use_ssl = 1;
|
||||||
$default_port = '443';
|
$default_port = '443';
|
||||||
} else {
|
} else {
|
||||||
|
@ -2094,9 +2094,9 @@ sub geturl {
|
||||||
load_ipv6_support;
|
load_ipv6_support;
|
||||||
$socket_class = 'IO::Socket::INET6';
|
$socket_class = 'IO::Socket::INET6';
|
||||||
}
|
}
|
||||||
if (defined($params->{_testonly_socket_class})) {
|
if (defined($params{_testonly_socket_class})) {
|
||||||
$socket_args{original_socket_class} = $socket_class;
|
$socket_args{original_socket_class} = $socket_class;
|
||||||
$socket_class = $params->{_testonly_socket_class};
|
$socket_class = $params{_testonly_socket_class};
|
||||||
}
|
}
|
||||||
if ($ipversion eq '4') {
|
if ($ipversion eq '4') {
|
||||||
$socket_args{Domain} = PF_INET;
|
$socket_args{Domain} = PF_INET;
|
||||||
|
@ -2211,7 +2211,7 @@ sub get_ip {
|
||||||
$arg = $url;
|
$arg = $url;
|
||||||
|
|
||||||
if ($url) {
|
if ($url) {
|
||||||
$reply = geturl({ proxy => opt('proxy', $h), url => $url }) // '';
|
$reply = geturl(proxy => opt('proxy', $h), url => $url) // '';
|
||||||
}
|
}
|
||||||
|
|
||||||
} elsif (($use eq 'cisco')) {
|
} elsif (($use eq 'cisco')) {
|
||||||
|
@ -2228,12 +2228,12 @@ sub get_ip {
|
||||||
$queryif =~ s/([\?&= ])/sprintf("%%%02x", ord($1))/ge;
|
$queryif =~ s/([\?&= ])/sprintf("%%%02x", ord($1))/ge;
|
||||||
|
|
||||||
$url = "http://" . opt('fw', $h) . "/level/1/exec/show/ip/interface/brief/${queryif}/CR";
|
$url = "http://" . opt('fw', $h) . "/level/1/exec/show/ip/interface/brief/${queryif}/CR";
|
||||||
$reply = geturl({
|
$reply = geturl(
|
||||||
url => $url,
|
url => $url,
|
||||||
login => opt('fw-login', $h),
|
login => opt('fw-login', $h),
|
||||||
password => opt('fw-password', $h),
|
password => opt('fw-password', $h),
|
||||||
ignore_ssl_option => 1,
|
ignore_ssl_option => 1,
|
||||||
}) // '';
|
) // '';
|
||||||
$arg = $url;
|
$arg = $url;
|
||||||
|
|
||||||
} elsif (($use eq 'cisco-asa')) {
|
} elsif (($use eq 'cisco-asa')) {
|
||||||
|
@ -2250,12 +2250,12 @@ sub get_ip {
|
||||||
$queryif =~ s/([\?&= ])/sprintf("%%%02x", ord($1))/ge;
|
$queryif =~ s/([\?&= ])/sprintf("%%%02x", ord($1))/ge;
|
||||||
|
|
||||||
$url = "https://" . opt('fw', $h) . "/exec/show%20interface%20${queryif}";
|
$url = "https://" . opt('fw', $h) . "/exec/show%20interface%20${queryif}";
|
||||||
$reply = geturl({
|
$reply = geturl(
|
||||||
url => $url,
|
url => $url,
|
||||||
login => opt('fw-login', $h),
|
login => opt('fw-login', $h),
|
||||||
password => opt('fw-password', $h),
|
password => opt('fw-password', $h),
|
||||||
ignore_ssl_option => 1,
|
ignore_ssl_option => 1,
|
||||||
}) // '';
|
) // '';
|
||||||
$arg = $url;
|
$arg = $url;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -2269,12 +2269,12 @@ sub get_ip {
|
||||||
$arg = $url;
|
$arg = $url;
|
||||||
|
|
||||||
if ($url) {
|
if ($url) {
|
||||||
$reply = geturl({
|
$reply = geturl(
|
||||||
url => $url,
|
url => $url,
|
||||||
login => opt('fw-login', $h),
|
login => opt('fw-login', $h),
|
||||||
password => opt('fw-password', $h),
|
password => opt('fw-password', $h),
|
||||||
ignore_ssl_option => 1,
|
ignore_ssl_option => 1,
|
||||||
}) // '';
|
) // '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!defined $reply) {
|
if (!defined $reply) {
|
||||||
|
@ -2681,12 +2681,12 @@ sub nic_dyndns1_update {
|
||||||
$url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO');
|
$url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO');
|
||||||
}
|
}
|
||||||
|
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
login => $config{$h}{'login'},
|
login => $config{$h}{'login'},
|
||||||
password => $config{$h}{'password'},
|
password => $config{$h}{'password'},
|
||||||
}) // '';
|
) // '';
|
||||||
if ($reply eq '') {
|
if ($reply eq '') {
|
||||||
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -2849,12 +2849,12 @@ sub nic_dyndns2_update {
|
||||||
$url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO');
|
$url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO');
|
||||||
}
|
}
|
||||||
|
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
login => $config{$h}{'login'},
|
login => $config{$h}{'login'},
|
||||||
password => $config{$h}{'password'},
|
password => $config{$h}{'password'},
|
||||||
}) // '';
|
) // '';
|
||||||
if ($reply eq '') {
|
if ($reply eq '') {
|
||||||
failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -2959,12 +2959,12 @@ sub nic_noip_update {
|
||||||
$url .= "&myip=";
|
$url .= "&myip=";
|
||||||
$url .= $ip if $ip;
|
$url .= $ip if $ip;
|
||||||
|
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
login => $config{$h}{'login'},
|
login => $config{$h}{'login'},
|
||||||
password => $config{$h}{'password'},
|
password => $config{$h}{'password'},
|
||||||
}) // '';
|
) // '';
|
||||||
if ($reply eq '') {
|
if ($reply eq '') {
|
||||||
failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -3099,12 +3099,12 @@ sub nic_dslreports1_update {
|
||||||
$url .= "&myip=";
|
$url .= "&myip=";
|
||||||
$url .= $ip if $ip;
|
$url .= $ip if $ip;
|
||||||
|
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
login => $config{$h}{'login'},
|
login => $config{$h}{'login'},
|
||||||
password => $config{$h}{'password'},
|
password => $config{$h}{'password'},
|
||||||
}) // '';
|
) // '';
|
||||||
if ($reply eq '') {
|
if ($reply eq '') {
|
||||||
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -3200,12 +3200,12 @@ sub nic_zoneedit1_update {
|
||||||
$url .= "&dnsto=$ip" if $ip;
|
$url .= "&dnsto=$ip" if $ip;
|
||||||
$url .= "&zone=$config{$h}{'zone'}" if defined $config{$h}{'zone'};
|
$url .= "&zone=$config{$h}{'zone'}" if defined $config{$h}{'zone'};
|
||||||
|
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
login => $config{$h}{'login'},
|
login => $config{$h}{'login'},
|
||||||
password => $config{$h}{'password'},
|
password => $config{$h}{'password'},
|
||||||
}) // '';
|
) // '';
|
||||||
if ($reply eq '') {
|
if ($reply eq '') {
|
||||||
failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -3355,12 +3355,12 @@ sub nic_easydns_update {
|
||||||
$url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO');
|
$url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO');
|
||||||
}
|
}
|
||||||
|
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
login => $config{$h}{'login'},
|
login => $config{$h}{'login'},
|
||||||
password => $config{$h}{'password'},
|
password => $config{$h}{'password'},
|
||||||
}) // '';
|
) // '';
|
||||||
if ($reply eq '') {
|
if ($reply eq '') {
|
||||||
failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $hosts, $config{$h}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -3474,7 +3474,7 @@ sub nic_namecheap_update {
|
||||||
$url .= "&ip=";
|
$url .= "&ip=";
|
||||||
$url .= $ip if $ip;
|
$url .= $ip if $ip;
|
||||||
|
|
||||||
my $reply = geturl({ proxy => opt('proxy'), url => $url }) // '';
|
my $reply = geturl(proxy => opt('proxy'), url => $url) // '';
|
||||||
if ($reply eq '') {
|
if ($reply eq '') {
|
||||||
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -3605,13 +3605,13 @@ sub nic_nfsn_make_request {
|
||||||
$header .= "Content-Type: application/x-www-form-urlencoded\n";
|
$header .= "Content-Type: application/x-www-form-urlencoded\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return geturl({
|
return geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
headers => $header,
|
headers => $header,
|
||||||
method => $method,
|
method => $method,
|
||||||
data => $body,
|
data => $body,
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -3782,7 +3782,7 @@ sub nic_sitelutions_update {
|
||||||
$url .= "&ip=";
|
$url .= "&ip=";
|
||||||
$url .= $ip if $ip;
|
$url .= $ip if $ip;
|
||||||
|
|
||||||
my $reply = geturl({ proxy => opt('proxy'), url => $url });
|
my $reply = geturl(proxy => opt('proxy'), url => $url);
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -3867,7 +3867,7 @@ sub nic_freedns_update {
|
||||||
my $url_tmpl = "http://$config{$_[0]}{'server'}/api/?action=getdyndns&v=2&sha=<credentials>";
|
my $url_tmpl = "http://$config{$_[0]}{'server'}/api/?action=getdyndns&v=2&sha=<credentials>";
|
||||||
my $creds = sha1_hex("$config{$_[0]}{'login'}|$config{$_[0]}{'password'}");
|
my $creds = sha1_hex("$config{$_[0]}{'login'}|$config{$_[0]}{'password'}");
|
||||||
(my $url = $url_tmpl) =~ s/<credentials>/$creds/;
|
(my $url = $url_tmpl) =~ s/<credentials>/$creds/;
|
||||||
my $reply = geturl({ proxy => opt('proxy'), url => $url });
|
my $reply = geturl(proxy => opt('proxy'), url => $url);
|
||||||
my $record_list_error = '';
|
my $record_list_error = '';
|
||||||
if ($reply && header_ok($_[0], $reply)) {
|
if ($reply && header_ok($_[0], $reply)) {
|
||||||
$reply =~ s/^.*?\n\n//s; # Strip the headers.
|
$reply =~ s/^.*?\n\n//s; # Strip the headers.
|
||||||
|
@ -3917,7 +3917,7 @@ sub nic_freedns_update {
|
||||||
} else {
|
} else {
|
||||||
my $url = $rec->[2] . "&address=" . $ip;
|
my $url = $rec->[2] . "&address=" . $ip;
|
||||||
debug("Update: %s", $url);
|
debug("Update: %s", $url);
|
||||||
my $reply = geturl({proxy => opt('proxy'), url => $url });
|
my $reply = geturl(proxy => opt('proxy'), url => $url);
|
||||||
if (!defined($reply) || !$reply || !header_ok($h, $reply)) {
|
if (!defined($reply) || !$reply || !header_ok($h, $reply)) {
|
||||||
$config{$h}{'status'} = 'failed';
|
$config{$h}{'status'} = 'failed';
|
||||||
failed("updating %s: Could not connect to %s.", $h, $url);
|
failed("updating %s: Could not connect to %s.", $h, $url);
|
||||||
|
@ -3992,12 +3992,12 @@ sub nic_changeip_update {
|
||||||
$url .= "&ip=";
|
$url .= "&ip=";
|
||||||
$url .= $ip if $ip;
|
$url .= $ip if $ip;
|
||||||
|
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
login => $config{$h}{'login'},
|
login => $config{$h}{'login'},
|
||||||
password => $config{$h}{'password'},
|
password => $config{$h}{'password'},
|
||||||
});
|
);
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -4079,12 +4079,12 @@ sub nic_googledomains_update {
|
||||||
$url .= "&myip=";
|
$url .= "&myip=";
|
||||||
$url .= $ip if $ip;
|
$url .= $ip if $ip;
|
||||||
|
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
login => $config{$host}{'login'},
|
login => $config{$host}{'login'},
|
||||||
password => $config{$host}{'password'},
|
password => $config{$host}{'password'},
|
||||||
});
|
);
|
||||||
unless ($reply) {
|
unless ($reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $host, $config{$host}{'server'});
|
failed("updating %s: Could not connect to %s.", $host, $config{$host}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -4293,7 +4293,7 @@ sub nic_cloudflare_update {
|
||||||
my $url = "https://$config{$key}{'server'}/zones?";
|
my $url = "https://$config{$key}{'server'}/zones?";
|
||||||
$url .= "name=".$config{$key}{'zone'};
|
$url .= "name=".$config{$key}{'zone'};
|
||||||
|
|
||||||
my $reply = geturl({ proxy => opt('proxy'), url => $url, headers => $headers });
|
my $reply = geturl(proxy => opt('proxy'), url => $url, headers => $headers);
|
||||||
unless ($reply) {
|
unless ($reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $domain, $config{$key}{'server'});
|
failed("updating %s: Could not connect to %s.", $domain, $config{$key}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -4324,7 +4324,7 @@ sub nic_cloudflare_update {
|
||||||
$url .= "type=A&name=$domain";
|
$url .= "type=A&name=$domain";
|
||||||
}
|
}
|
||||||
|
|
||||||
$reply = geturl({ proxy => opt('proxy'), url => $url, headers => $headers });
|
$reply = geturl(proxy => opt('proxy'), url => $url, headers => $headers);
|
||||||
unless ($reply) {
|
unless ($reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $domain, $config{$key}{'server'});
|
failed("updating %s: Could not connect to %s.", $domain, $config{$key}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -4350,13 +4350,13 @@ sub nic_cloudflare_update {
|
||||||
# Set domain
|
# Set domain
|
||||||
$url = "https://$config{$key}{'server'}/zones/$zone_id/dns_records/$dns_rec_id";
|
$url = "https://$config{$key}{'server'}/zones/$zone_id/dns_records/$dns_rec_id";
|
||||||
my $data = "{\"content\":\"$ip\"}";
|
my $data = "{\"content\":\"$ip\"}";
|
||||||
$reply = geturl({
|
$reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
headers => $headers,
|
headers => $headers,
|
||||||
method => "PATCH",
|
method => "PATCH",
|
||||||
data => $data,
|
data => $data,
|
||||||
});
|
);
|
||||||
unless ($reply) {
|
unless ($reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'});
|
failed("updating %s: Could not connect to %s.", $domain, $config{$domain}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -4440,7 +4440,7 @@ sub nic_yandex_update {
|
||||||
my $url = "https://$config{$host}{'server'}/api2/admin/dns/list?";
|
my $url = "https://$config{$host}{'server'}/api2/admin/dns/list?";
|
||||||
$url .= "domain=";
|
$url .= "domain=";
|
||||||
$url .= $config{$key}{'login'};
|
$url .= $config{$key}{'login'};
|
||||||
my $reply = geturl({ proxy => opt('proxy'), url => $url, headers => $headers });
|
my $reply = geturl(proxy => opt('proxy'), url => $url, headers => $headers);
|
||||||
unless ($reply) {
|
unless ($reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $host, $config{$key}{'server'});
|
failed("updating %s: Could not connect to %s.", $host, $config{$key}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -4471,13 +4471,13 @@ sub nic_yandex_update {
|
||||||
$data .= "&content=";
|
$data .= "&content=";
|
||||||
$data .= $ip if $ip;
|
$data .= $ip if $ip;
|
||||||
|
|
||||||
$reply = geturl({
|
$reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
headers => $headers,
|
headers => $headers,
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
data => $data,
|
data => $data,
|
||||||
});
|
);
|
||||||
unless ($reply) {
|
unless ($reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $host, $config{$host}{'server'});
|
failed("updating %s: Could not connect to %s.", $host, $config{$host}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -4555,7 +4555,7 @@ sub nic_duckdns_update {
|
||||||
|
|
||||||
|
|
||||||
# Try to get URL
|
# Try to get URL
|
||||||
my $reply = geturl({ proxy => opt('proxy'), url => $url });
|
my $reply = geturl(proxy => opt('proxy'), url => $url);
|
||||||
|
|
||||||
# No response, declare as failed
|
# No response, declare as failed
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
|
@ -4626,7 +4626,7 @@ sub nic_freemyip_update {
|
||||||
$url .= $h;
|
$url .= $h;
|
||||||
|
|
||||||
# Try to get URL
|
# Try to get URL
|
||||||
my $reply = geturl({ proxy => opt('proxy'), url => $url });
|
my $reply = geturl(proxy => opt('proxy'), url => $url);
|
||||||
|
|
||||||
# No response, declare as failed
|
# No response, declare as failed
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
|
@ -4752,12 +4752,12 @@ sub nic_woima_update {
|
||||||
$url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO');
|
$url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO');
|
||||||
}
|
}
|
||||||
|
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
login => $config{$h}{'login'},
|
login => $config{$h}{'login'},
|
||||||
password => $config{$h}{'password'},
|
password => $config{$h}{'password'},
|
||||||
});
|
);
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
||||||
next;
|
next;
|
||||||
|
@ -4873,7 +4873,7 @@ sub nic_dondominio_update {
|
||||||
|
|
||||||
|
|
||||||
# Try to get URL
|
# Try to get URL
|
||||||
my $reply = geturl({ proxy => opt('proxy'), url => $url });
|
my $reply = geturl(proxy => opt('proxy'), url => $url);
|
||||||
|
|
||||||
# No response, declare as failed
|
# No response, declare as failed
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
|
@ -4959,7 +4959,7 @@ sub nic_dnsmadeeasy_update {
|
||||||
$url .= "&id=$h";
|
$url .= "&id=$h";
|
||||||
|
|
||||||
# Try to get URL
|
# Try to get URL
|
||||||
my $reply = geturl({ proxy => opt('proxy'), url => $url });
|
my $reply = geturl(proxy => opt('proxy'), url => $url);
|
||||||
|
|
||||||
# No response, declare as failed
|
# No response, declare as failed
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
|
@ -5030,12 +5030,12 @@ sub nic_ovh_update {
|
||||||
$url .= "&myip=";
|
$url .= "&myip=";
|
||||||
$url .= $ip if $ip;
|
$url .= $ip if $ip;
|
||||||
|
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
login => $config{$h}{'login'},
|
login => $config{$h}{'login'},
|
||||||
password => $config{$h}{'password'},
|
password => $config{$h}{'password'},
|
||||||
});
|
);
|
||||||
|
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
||||||
|
@ -5099,11 +5099,11 @@ sub nic_cloudns_update {
|
||||||
# IP is set in the header X-Forwarded-For you need to add &proxy=1 at the end of the
|
# IP is set in the header X-Forwarded-For you need to add &proxy=1 at the end of the
|
||||||
# DynamicURL." We abuse this to pass the desired IP address to ClouDNS, which might not be
|
# DynamicURL." We abuse this to pass the desired IP address to ClouDNS, which might not be
|
||||||
# the same as the client IP address seen by ClouDNS.
|
# the same as the client IP address seen by ClouDNS.
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $dynurl . '&proxy=1',
|
url => $dynurl . '&proxy=1',
|
||||||
headers => "X-Forwarded-For: $ip\n",
|
headers => "X-Forwarded-For: $ip\n",
|
||||||
});
|
);
|
||||||
if (($reply // '') eq '' || !header_ok($hosts, $reply)) {
|
if (($reply // '') eq '' || !header_ok($hosts, $reply)) {
|
||||||
$config{$_}{'status'} = 'failed' for @hosts;
|
$config{$_}{'status'} = 'failed' for @hosts;
|
||||||
failed("updating %s: failed to visit DynURL", $hosts);
|
failed("updating %s: failed to visit DynURL", $hosts);
|
||||||
|
@ -5163,12 +5163,12 @@ sub nic_dinahosting_update {
|
||||||
$url .= "&domain=$domain";
|
$url .= "&domain=$domain";
|
||||||
$url .= "&command=Domain_Zone_UpdateType" . is_ipv6($ip) ? 'AAAA' : 'A';
|
$url .= "&command=Domain_Zone_UpdateType" . is_ipv6($ip) ? 'AAAA' : 'A';
|
||||||
$url .= "&ip=$ip";
|
$url .= "&ip=$ip";
|
||||||
my $reply = geturl({
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
login => $config{$h}{'login'},
|
login => $config{$h}{'login'},
|
||||||
password => $config{$h}{'password'},
|
password => $config{$h}{'password'},
|
||||||
url => $url,
|
url => $url,
|
||||||
});
|
);
|
||||||
$config{$h}{'status'} = 'failed'; # assume failure until otherwise determined
|
$config{$h}{'status'} = 'failed'; # assume failure until otherwise determined
|
||||||
if (!$reply) {
|
if (!$reply) {
|
||||||
failed("updating %s: failed to visit URL %s", $h, $url);
|
failed("updating %s: failed to visit URL %s", $h, $url);
|
||||||
|
|
|
@ -84,7 +84,7 @@ for my $tc (@test_cases) {
|
||||||
my $name = sprintf("IPv%s client to %s (-%sipv6)",
|
my $name = sprintf("IPv%s client to %s (-%sipv6)",
|
||||||
$tc->{client_ipv} || '*', $uri, $tc->{ipv6_opt} ? '' : 'no');
|
$tc->{client_ipv} || '*', $uri, $tc->{ipv6_opt} ? '' : 'no');
|
||||||
$ddclient::globals{'ipv6'} = $tc->{ipv6_opt};
|
$ddclient::globals{'ipv6'} = $tc->{ipv6_opt};
|
||||||
my $got = ddclient::geturl({ url => $uri, ipversion => $tc->{client_ipv} });
|
my $got = ddclient::geturl(url => $uri, ipversion => $tc->{client_ipv});
|
||||||
isnt($got // '', '', $name);
|
isnt($got // '', '', $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,8 +228,7 @@ for my $tc (@test_cases) {
|
||||||
$ddclient::globals{'ssl'} = $tc->{opt_ssl} // 0;
|
$ddclient::globals{'ssl'} = $tc->{opt_ssl} // 0;
|
||||||
$ddclient::globals{'ssl_ca_dir'} = $tc->{opt_ssl_ca_dir};
|
$ddclient::globals{'ssl_ca_dir'} = $tc->{opt_ssl_ca_dir};
|
||||||
$ddclient::globals{'ssl_ca_file'} = $tc->{opt_ssl_ca_file};
|
$ddclient::globals{'ssl_ca_file'} = $tc->{opt_ssl_ca_file};
|
||||||
my $resp_str = ddclient::geturl({ _testonly_socket_class => 'InterceptSocket',
|
my $resp_str = ddclient::geturl(_testonly_socket_class => 'InterceptSocket', %{$tc->{params}});
|
||||||
%{$tc->{params}} });
|
|
||||||
TODO: {
|
TODO: {
|
||||||
local $TODO = $tc->{todo};
|
local $TODO = $tc->{todo};
|
||||||
subtest $tc->{name} => sub {
|
subtest $tc->{name} => sub {
|
||||||
|
|
Loading…
Reference in a new issue