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] 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)