aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorGravatar Anders Kaseorg <andersk@mit.edu>2016-11-10 04:37:50 -0500
committerGravatar Anders Kaseorg <andersk@mit.edu>2016-11-12 01:43:08 -0500
commitdf085e02dc61fba84141cbae1a5bc9e9460ea76b (patch)
treed4d3d028eb71cf6f8ada3999a5f1a9285836451e /scripts
parent04b03b41f6d901e4cfc99e237eeb69ee91ec2b75 (diff)
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 <andersk@mit.edu>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/mosh.pl12
1 files 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;