mosh perl wrapper: New option --bind-ip={ssh|IP}

Allow overriding the switch passed to mosh-server from -s to -i IP.

Signed-off-by: Philipp Haselwarter <philipp@haselwarter.org>
This commit is contained in:
Philipp Haselwarter
2013-04-16 18:37:40 +02:00
committed by Keith Winstein
parent 9314ea18fa
commit fc70612de6
2 changed files with 23 additions and 3 deletions
+9 -1
View File
@@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps .\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1) .\" other parameters are allowed: see man(7), man(1)
.TH MOSH 1 "October 2012" .TH MOSH 1 "April 2013"
.\" Please adjust this date whenever revising the manpage. .\" Please adjust this date whenever revising the manpage.
.\" .\"
.\" Some roff macros, for reference: .\" Some roff macros, for reference:
@@ -128,6 +128,14 @@ only port that is forwarded through a firewall to the
server. Otherwise, \fBmosh\fP will choose a port between 60000 and server. Otherwise, \fBmosh\fP will choose a port between 60000 and
61000. 61000.
.TP
.B \-\-bind\-ip={ssh|\fIIP\fP}
Bind the server to the ip of the ssh client or to IP by passing either the -s
switch (default) or -i IP to \fBmosh-server\fP. This is useful when the login
happens from an address different from the one used by the \fBmosh-client\fP.
For example, if ssh is served through \fBsslh\fP, \fBSSH_CONNECTION\fP might be
set to 127.0.0.1, but \fBmosh-server\fP can still be bound to 0.0.0.0.
.TP .TP
.B \-\-no\-init .B \-\-no\-init
Do not send the \fBsmcup\fP initialization string and \fBrmcup\fP Do not send the \fBsmcup\fP initialization string and \fBrmcup\fP
+14 -2
View File
@@ -44,6 +44,8 @@ my $server = 'mosh-server';
my $predict = undef; my $predict = undef;
my $bind_ip = undef;
my $port_request = undef; my $port_request = undef;
my $ssh = 'ssh'; my $ssh = 'ssh';
@@ -69,6 +71,9 @@ qq{Usage: $0 [options] [--] [user@]host [command...]
-p PORT[:PORT2] -p PORT[:PORT2]
--port=PORT[:PORT2] server-side UDP port or range --port=PORT[:PORT2] server-side UDP port or range
--bind-ip={ssh|IP} bind the server to the ssh client's ip or to IP
(example: "0.0.0.0")
(default: "ssh")
--ssh=COMMAND ssh command to run when setting up session --ssh=COMMAND ssh command to run when setting up session
(example: "ssh -p 2222") (example: "ssh -p 2222")
@@ -111,7 +116,8 @@ GetOptions( 'client=s' => \$client,
'init!' => \$term_init, 'init!' => \$term_init,
'help' => \$help, 'help' => \$help,
'version' => \$version, 'version' => \$version,
'fake-proxy!' => \my $fake_proxy ) or die $usage; 'fake-proxy!' => \my $fake_proxy,
'bind-ip=s' => \$bind_ip) or die $usage;
die $usage if ( defined $help ); die $usage if ( defined $help );
die $version_message if ( defined $version ); die $version_message if ( defined $version );
@@ -222,10 +228,16 @@ die "$0: fork: $!\n" unless ( defined $pid );
if ( $pid == 0 ) { # child if ( $pid == 0 ) { # child
open(STDERR, ">&STDOUT") or die; open(STDERR, ">&STDOUT") or die;
my @server = ( 'new', '-s' ); my @server = ( 'new' );
push @server, ( '-c', $colors ); push @server, ( '-c', $colors );
if ( not defined $bind_ip or $bind_ip =~ 'ssh' ) {
push @server , '-s';
} else {
push @server, ('-i', "$bind_ip");
}
if ( defined $port_request ) { if ( defined $port_request ) {
push @server, ( '-p', $port_request ); push @server, ( '-p', $port_request );
} }