From 9eeb2fbffa9f63e2a2f1121009d3e1bba7839ec6 Mon Sep 17 00:00:00 2001 From: John Hood Date: Thu, 28 May 2015 22:47:34 -0400 Subject: [PATCH] mosh.pl: Add a better error message for IPV6 & Socket::IP. --- scripts/mosh.pl | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/mosh.pl b/scripts/mosh.pl index 8c19138..41c31b0 100755 --- a/scripts/mosh.pl +++ b/scripts/mosh.pl @@ -172,12 +172,23 @@ if ( not defined $bind_ip or $bind_ip =~ m{^ssh$}i ) { if ( defined $fake_proxy ) { use Errno qw(EINTR); - BEGIN { - eval { require IO::Socket::IP; IO::Socket::IP->import('-register'); 1 } or - eval { require IO::Socket::INET6 }; - } + my $have_ipv6 = eval { + require IO::Socket::IP; + IO::Socket::IP->import('-register'); + 1; + } || eval { + require IO::Socket::INET6; + 1; + }; use POSIX qw(_exit); + # Report failure if IPv6 needed and not available. + if (lc($family) eq "inet6") { + if (!$have_ipv6) { + die "$0: IPv6 sockets not available in this Perl install\n"; + } + } + my ( $host, $port ) = @ARGV; # Resolve hostname and connect