Merge pull request #480 from michal-josef-spacek/fix_inet6
Rewrite deprecated use of IO::Socket::INET6 to new solution with IO::Socket::IP
This commit is contained in:
commit
2536a5e37a
5 changed files with 6 additions and 34 deletions
|
@ -55,7 +55,6 @@ through github.com. Please check out http://ddclient.net
|
|||
* Perl v5.10.1 or later
|
||||
* `IO::Socket::SSL` perl library for ssl-support
|
||||
* `JSON::PP` perl library for JSON support
|
||||
* `IO::Socket::INET6` perl library for ipv6-support
|
||||
* Linux, macOS, or any other Unix-ish system
|
||||
* An implementation of `make` (such as [GNU
|
||||
Make](https://www.gnu.org/software/make/))
|
||||
|
|
|
@ -43,7 +43,7 @@ m4_foreach_w([_m], [
|
|||
File::Path
|
||||
File::Temp
|
||||
Getopt::Long
|
||||
IO::Socket::INET
|
||||
IO::Socket::IP
|
||||
Socket
|
||||
Sys::Hostname
|
||||
version=0.77
|
||||
|
@ -71,8 +71,6 @@ m4_foreach_w([_m], [
|
|||
HTTP::Message::PSGI
|
||||
HTTP::Request
|
||||
HTTP::Response
|
||||
IO::Socket::INET6
|
||||
IO::Socket::IP
|
||||
IO::Socket::SSL
|
||||
Scalar::Util
|
||||
Test::MockModule
|
||||
|
|
25
ddclient.in
25
ddclient.in
|
@ -26,7 +26,7 @@ use File::Basename;
|
|||
use File::Path qw(make_path);
|
||||
use File::Temp;
|
||||
use Getopt::Long;
|
||||
use IO::Socket::INET;
|
||||
use IO::Socket::IP;
|
||||
use Socket qw(AF_INET AF_INET6 PF_INET PF_INET6);
|
||||
use Sys::Hostname;
|
||||
|
||||
|
@ -2447,23 +2447,6 @@ EOM
|
|||
{ no warnings; $IO::Socket::SSL::DEBUG = 0; }
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## load_ipv6_support
|
||||
######################################################################
|
||||
sub load_ipv6_support {
|
||||
my $ipv6_loaded = eval { require IO::Socket::INET6 };
|
||||
unless ($ipv6_loaded) {
|
||||
fatal("%s", <<"EOM");
|
||||
Error loading the Perl module IO::Socket::INET6 needed for ipv6 connect.
|
||||
On Debian, the package libio-socket-inet6-perl must be installed.
|
||||
On Red Hat, the package perl-IO-Socket-INET6 must be installed.
|
||||
On Alpine, the package perl-io-socket-inet6 must be installed.
|
||||
EOM
|
||||
}
|
||||
import IO::Socket::INET6;
|
||||
{ no warnings; $IO::Socket::INET6::DEBUG = 0; }
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## load_sha1_support
|
||||
######################################################################
|
||||
|
@ -2582,10 +2565,9 @@ sub fetch_via_socket_io {
|
|||
PeerAddr => $peer,
|
||||
PeerPort => $port,
|
||||
Proto => 'tcp',
|
||||
MultiHomed => 1,
|
||||
Timeout => opt('timeout'),
|
||||
);
|
||||
my $socket_class = 'IO::Socket::INET';
|
||||
my $socket_class = 'IO::Socket::IP';
|
||||
if ($use_ssl) {
|
||||
# IO::Socket::SSL will load IPv6 support if available on the system.
|
||||
load_ssl_support;
|
||||
|
@ -2595,9 +2577,6 @@ sub fetch_via_socket_io {
|
|||
$socket_args{SSL_verify_mode} = ($params{ssl_validate} // 1)
|
||||
? IO::Socket::SSL->SSL_VERIFY_PEER
|
||||
: IO::Socket::SSL->SSL_VERIFY_NONE;
|
||||
} elsif ($globals{'ipv6'} || $ipversion eq '6') {
|
||||
load_ipv6_support;
|
||||
$socket_class = 'IO::Socket::INET6';
|
||||
}
|
||||
if (defined($params{_testonly_socket_class})) {
|
||||
$socket_args{original_socket_class} = $socket_class;
|
||||
|
|
|
@ -3,7 +3,6 @@ eval { require ddclient::Test::Fake::HTTPD; } or plan(skip_all => $@);
|
|||
SKIP: { eval { require Test::Warnings; } or skip($@, 1); }
|
||||
eval { require 'ddclient'; } or BAIL_OUT($@);
|
||||
my $has_http_daemon_ssl = eval { require HTTP::Daemon::SSL; };
|
||||
my $has_io_socket_inet6 = eval { require IO::Socket::INET6; };
|
||||
my $ipv6_supported = eval {
|
||||
require IO::Socket::IP;
|
||||
my $ipv6_socket = IO::Socket::IP->new(
|
||||
|
@ -56,13 +55,13 @@ my %httpd = (
|
|||
);
|
||||
|
||||
my @test_cases = (
|
||||
# Fetch via IO::Socket::INET
|
||||
# Fetch via IO::Socket::IP
|
||||
{ipv6_opt => 0, server_ipv => '4', client_ipv => ''},
|
||||
{ipv6_opt => 0, server_ipv => '4', client_ipv => '4'},
|
||||
# IPv* client to a non-SSL IPv6 server is not expected to work unless opt('ipv6') is true
|
||||
{ipv6_opt => 0, server_ipv => '6', client_ipv => '6'},
|
||||
|
||||
# Fetch via IO::Socket::INET6
|
||||
# Fetch via IO::Socket::IP
|
||||
{ipv6_opt => 1, server_ipv => '4', client_ipv => ''},
|
||||
{ipv6_opt => 1, server_ipv => '4', client_ipv => '4'},
|
||||
{ipv6_opt => 1, server_ipv => '6', client_ipv => ''},
|
||||
|
@ -92,8 +91,6 @@ for my $tc (@test_cases) {
|
|||
$tc->{ssl} //= 0;
|
||||
$tc->{curl} //= 0;
|
||||
SKIP: {
|
||||
skip("IO::Socket::INET6 not available", 1)
|
||||
if ($tc->{ipv6_opt} || $tc->{client_ipv} eq '6') && !$tc->{curl} && !$has_io_socket_inet6;
|
||||
skip("IPv6 not supported on this system", 1)
|
||||
if $tc->{server_ipv} eq '6' && !$ipv6_supported;
|
||||
skip("HTTP::Daemon too old for IPv6 support", 1)
|
||||
|
|
|
@ -44,7 +44,7 @@ my $args;
|
|||
# * opt_ssl: Value to return from opt('ssl'). Defaults to 0.
|
||||
# * opt_ssl_ca_dir: Value to return from opt('ssl_ca_dir'). Defaults to undef.
|
||||
# * opt_ssl_ca_file: Value to return from opt('ssl_ca_file'). Defaults to undef.
|
||||
# * want_args: Args that should be passed to the socket constructor minus MultiHomed, Proto,
|
||||
# * want_args: Args that should be passed to the socket constructor minus Proto,
|
||||
# Timeout, and original_socket_class.
|
||||
# * want_req_method: The HTTP method geturl is expected to use. Defaults to 'GET'.
|
||||
# * want_req_uri: URI that geturl is expected to request.
|
||||
|
@ -244,7 +244,6 @@ for my $tc (@test_cases) {
|
|||
local $TODO = $tc->{todo};
|
||||
subtest $tc->{name} => sub {
|
||||
my %want_args = (
|
||||
MultiHomed => 1,
|
||||
Proto => 'tcp',
|
||||
Timeout => ddclient::opt('timeout'),
|
||||
original_socket_class => 'IO::Socket::SSL',
|
||||
|
|
Loading…
Reference in a new issue