From c747f2737a2f350a022e4059552a01a8e9f6eaed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Josef=20=C5=A0pa=C4=8Dek?= Date: Thu, 8 Dec 2022 13:58:21 +0100 Subject: [PATCH 1/2] Rewrite deprecated use of IO::Socket::INET6 to new solution Module IO::Socket::INET6 is deprecated. There is common IO::Socket::IP module, which is working with ipv4 and ipv6 in same way. There is backward compatibility with IO::Socket::INET6 --- README.md | 1 - configure.ac | 4 +--- ddclient.in | 24 ++---------------------- t/geturl_connectivity.pl.in | 7 ++----- 4 files changed, 5 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 926dce3..0cf65c5 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,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/)) diff --git a/configure.ac b/configure.ac index 6c58b8f..05e3f7c 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/ddclient.in b/ddclient.in index 3df624d..f0b0f3a 100755 --- a/ddclient.in +++ b/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; @@ -2362,23 +2362,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 ###################################################################### @@ -2500,7 +2483,7 @@ sub fetch_via_socket_io { 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; @@ -2510,9 +2493,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; diff --git a/t/geturl_connectivity.pl.in b/t/geturl_connectivity.pl.in index 2e825d0..5127b30 100644 --- a/t/geturl_connectivity.pl.in +++ b/t/geturl_connectivity.pl.in @@ -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) From c4ff6c12bd7dc1f9a0a3def6f60ba0c89222f32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Josef=20=C5=A0pa=C4=8Dek?= Date: Thu, 8 Dec 2022 14:04:33 +0100 Subject: [PATCH 2/2] Remove setting of MultiHomed, which is default in IO::Socket::IP From doc in IO::Socket::IP in "IO::Socket::INET" INCOMPATIBILITES section: ----- The behaviour enabled by "MultiHomed" is in fact implemented by "IO::Socket::IP" as it is required to correctly support searching for a useable address from the results of the getaddrinfo(3) call. The constructor will ignore the value of this argument, except if it is defined but false. An exception is thrown in this case, because that would request it disable the getaddrinfo(3) search behaviour in the first place. ----- --- ddclient.in | 1 - t/geturl_ssl.pl | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/ddclient.in b/ddclient.in index f0b0f3a..e0c3a16 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2480,7 +2480,6 @@ sub fetch_via_socket_io { PeerAddr => $peer, PeerPort => $port, Proto => 'tcp', - MultiHomed => 1, Timeout => opt('timeout'), ); my $socket_class = 'IO::Socket::IP'; diff --git a/t/geturl_ssl.pl b/t/geturl_ssl.pl index c070def..2b45f0b 100644 --- a/t/geturl_ssl.pl +++ b/t/geturl_ssl.pl @@ -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',