Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

scripts/mosh: Add -6 option to connect with IPv6

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Loading branch information...
commit a4c58298121fee987c46e91d165130bc5cdd6ce3 1 parent aeee659
@andersk andersk authored
Showing with 25 additions and 3 deletions.
  1. +13 −0 man/mosh.1
  2. +12 −3 scripts/mosh
View
13 man/mosh.1
@@ -121,6 +121,19 @@ Synonym for \-\-predict=always
Synonym for \-\-predict=never
.TP
+.B --family=\fIFAMILY\fP
+Force the use of a particular address family, which defaults to `inet'
+(IPv4), and can also be `inet6' (IPv6; requires IO::Socket::IP).
+
+.TP
+.B -4
+Synonym for \-\-family=inet
+
+.TP
+.B -6
+Synonym for \-\-family=inet6
+
+.TP
.B \-p \fIPORT\fP[:\fIPORT2\fP], \-\-port=\fIPORT\fP[:\fIPORT2\fP]
Use a particular server-side UDP port or port range,
for example, if this is the
View
15 scripts/mosh
@@ -46,6 +46,7 @@ my $predict = undef;
my $bind_ip = undef;
+my $family = 'inet';
my $port_request = undef;
my $ssh = 'ssh';
@@ -69,6 +70,8 @@ qq{Usage: $0 [options] [--] [user@]host [command...]
-n --predict=never never use local echo
--predict=experimental aggressively echo even when incorrect
+-4 --family=inet use IPv4 only [default]
+-6 --family=inet6 use IPv6 only
-p PORT[:PORT2]
--port=PORT[:PORT2] server-side UDP port or range
--bind-server={ssh|any|IP} ask the server to reply from an IP address
@@ -110,6 +113,9 @@ GetOptions( 'client=s' => \$client,
'port=s' => \$port_request,
'a' => sub { $predict = 'always' },
'n' => sub { $predict = 'never' },
+ 'family=s' => \$family,
+ '4' => sub { $family = 'inet' },
+ '6' => sub { $family = 'inet6' },
'p=s' => \$port_request,
'ssh=s' => \$ssh,
'init!' => \$term_init,
@@ -168,13 +174,16 @@ 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'); }; }
use POSIX qw(_exit);
my ( $host, $port ) = @ARGV;
# Resolve hostname and connect
- my $sock = IO::Socket->new( Domain => AF_INET,
- Family => AF_INET,
+ my $afstr = 'AF_' . uc( $family );
+ my $af = eval { IO::Socket->$afstr } or die "$0: Invalid family $family\n";
+ my $sock = IO::Socket->new( Domain => $af,
+ Family => $af,
PeerHost => $host,
PeerPort => $port,
Proto => "tcp" )
@@ -254,7 +263,7 @@ if ( $pid == 0 ) { # child
push @server, '--', @command;
}
- my $quoted_self = shell_quote( $0 );
+ my $quoted_self = shell_quote( $0, "--family=$family" );
exec "$ssh " . shell_quote( '-S', 'none', '-o', "ProxyCommand=$quoted_self --fake-proxy -- %h %p", '-n', '-tt', $userhost, '--', "$server " . shell_quote( @server ) );
die "Cannot exec ssh: $!\n";
} else { # parent
Please sign in to comment.
Something went wrong with that request. Please try again.