Skip to content

Commit

Permalink
Friendlier error message when server does not support UDP port range.
Browse files Browse the repository at this point in the history
  • Loading branch information
keithw committed Oct 29, 2012
1 parent 93507a7 commit 07b2942
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/mosh
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ if ( defined $port_request ) {
}
}
} else {
die "$0: Server-side port ($port_request) not valid.\n";
die "$0: Server-side port or range ($port_request) is not valid.\n";
}
}

Expand Down Expand Up @@ -245,8 +245,9 @@ if ( $pid == 0 ) { # child
my $quoted_self = shell_quote( $0 );
exec "$ssh " . shell_quote( '-S', 'none', '-o', "ProxyCommand=$quoted_self --fake-proxy -- %h %p", '-t', $userhost, '--', "$server " . shell_quote( @server ) );
die "Cannot exec ssh: $!\n";
} else { # server
} else { # parent
my ( $ip, $port, $key );
my $bad_udp_port_warning = 0;
close $pty;
LINE: while ( <$pty_slave> ) {
chomp;
Expand All @@ -262,6 +263,9 @@ if ( $pid == 0 ) { # child
die "Bad MOSH CONNECT string: $_\n";
}
} else {
if ( $port_request =~ m{:} and m{Bad UDP port} ) {
$bad_udp_port_warning = 1;
}
print "$_\n";
}
}
Expand All @@ -272,6 +276,9 @@ if ( $pid == 0 ) { # child
}

if ( not defined $key or not defined $port ) {
if ( $bad_udp_port_warning ) {
die "$0: Server does not support UDP port range option.\n";
}
die "$0: Did not find mosh server startup message.\n";
}

Expand Down

0 comments on commit 07b2942

Please sign in to comment.