From df085e02dc61fba84141cbae1a5bc9e9460ea76b Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 10 Nov 2016 04:37:50 -0500 Subject: [PATCH] Restore Perl 5.10 support On Perl < 5.14, we can use Socket::GetAddrInfo from CPAN to replace the missing getaddrinfo functionality of Socket. Socket::GetAddrInfo < 0.22 requires :newapi in the import list, but 0.22 forbids it and enables the new API by default. Signed-off-by: Anders Kaseorg --- scripts/mosh.pl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/mosh.pl b/scripts/mosh.pl index 37eb1ff..40a9309 100755 --- a/scripts/mosh.pl +++ b/scripts/mosh.pl @@ -30,18 +30,24 @@ # this exception statement from all source files in the program, then # also delete it here. -use 5.14.0; +use 5.10.0; use warnings; use strict; use Getopt::Long; use IO::Socket; use Text::ParseWords; -use Socket qw( getaddrinfo getnameinfo AI_CANONNAME AI_NUMERICHOST NI_NUMERICHOST - IPPROTO_IP IPPROTO_IPV6 IPPROTO_TCP IPPROTO_UDP ); +use Socket qw( IPPROTO_IP IPPROTO_IPV6 IPPROTO_TCP IPPROTO_UDP ); use Errno qw(EINTR); use POSIX qw(_exit); +BEGIN { + my @gai_reqs = qw( getaddrinfo getnameinfo AI_CANONNAME AI_NUMERICHOST NI_NUMERICHOST ); + eval { Socket->import( @gai_reqs ); 1; } + || eval { require Socket::GetAddrInfo; Socket::GetAddrInfo->import( ':newapi', @gai_reqs ); 1; } + || eval { Socket::GetAddrInfo->import( '0.22', @gai_reqs ); 1; } + || die "$0 error: requires Perl 5.14 or Socket::GetAddrInfo.\n"; +} my $have_ipv6 = eval { require IO::Socket::IP;