aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorGravatar Keith Winstein <keithw@mit.edu>2013-04-28 15:33:36 -0400
committerGravatar Keith Winstein <keithw@mit.edu>2013-04-28 15:33:36 -0400
commit4792992afa78d606fff35346bcce5a819fc72b69 (patch)
tree4a34326b783a6702b2ed318f2646820307338eaf /scripts
parentfc70612de6d1390c943b7a470699e73dced5f110 (diff)
Rename --bind-ip to --bind-server, add =ANY option, add error checking.
Closes #415.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/mosh26
1 files changed, 17 insertions, 9 deletions
diff --git a/scripts/mosh b/scripts/mosh
index 36b5c9c..4e8b796 100755
--- a/scripts/mosh
+++ b/scripts/mosh
@@ -71,9 +71,8 @@ qq{Usage: $0 [options] [--] [user@]host [command...]
-p PORT[:PORT2]
--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")
+ --bind-server={ssh|any|IP} ask the server to reply from an IP address
+ (default: "ssh")
--ssh=COMMAND ssh command to run when setting up session
(example: "ssh -p 2222")
@@ -117,7 +116,7 @@ GetOptions( 'client=s' => \$client,
'help' => \$help,
'version' => \$version,
'fake-proxy!' => \my $fake_proxy,
- 'bind-ip=s' => \$bind_ip) or die $usage;
+ 'bind-server=s' => \$bind_ip) or die $usage;
die $usage if ( defined $help );
die $version_message if ( defined $version );
@@ -154,6 +153,19 @@ if ( defined $port_request ) {
delete $ENV{ 'MOSH_PREDICTION_DISPLAY' };
+my @bind_arguments;
+if ( not defined $bind_ip or $bind_ip =~ m{^ssh$}i ) {
+ push @bind_arguments, '-s';
+} elsif ( $bind_ip =~ m{^any$}i ) {
+ # do nothing
+} elsif ( $bind_ip =~ m{^[0-9\.]+$} ) {
+ push @bind_arguments, ('-i', "$bind_ip");
+} else {
+ print STDERR qq{$0: Unknown server binding option: $bind_ip\n};
+
+ die $usage;
+}
+
if ( defined $fake_proxy ) {
use Errno qw(EINTR);
use IO::Socket::INET;
@@ -232,11 +244,7 @@ if ( $pid == 0 ) { # child
push @server, ( '-c', $colors );
- if ( not defined $bind_ip or $bind_ip =~ 'ssh' ) {
- push @server , '-s';
- } else {
- push @server, ('-i', "$bind_ip");
- }
+ push @server, @bind_arguments;
if ( defined $port_request ) {
push @server, ( '-p', $port_request );