Connection: Store the port number as a string

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2013-08-17 05:31:06 -04:00
parent 9187e307c6
commit c1f96b37a1
9 changed files with 22 additions and 23 deletions
+1 -4
View File
@@ -117,7 +117,6 @@ int main( int argc, char *argv[] )
}
char *ip, *desired_port;
int port;
if ( argc - optind != 2 ) {
usage( argv[ 0 ] );
@@ -142,8 +141,6 @@ int main( int argc, char *argv[] )
exit( 1 );
}
port = myatoi( desired_port );
/* Read key from environment */
char *env_key = getenv( "MOSH_KEY" );
if ( env_key == NULL ) {
@@ -170,7 +167,7 @@ int main( int argc, char *argv[] )
set_native_locale();
try {
STMClient client( ip, port, key, predict_mode );
STMClient client( ip, desired_port, key, predict_mode );
client.init();
try {
+1 -1
View File
@@ -354,7 +354,7 @@ int run_server( const char *desired_ip, const char *desired_port,
network->set_verbose();
}
printf( "\nMOSH CONNECT %d %s\n", network->port(), network->get_key().c_str() );
printf( "\nMOSH CONNECT %s %s\n", network->port().c_str(), network->get_key().c_str() );
fflush( stdout );
/* don't let signals kill us */
+4 -4
View File
@@ -188,7 +188,7 @@ void STMClient::init( void )
escape_key_help = L"Commands: Ctrl-Z suspends, \".\" quits, " + escape_pass_name + L" gives literal " + escape_key_name;
}
wchar_t tmp[ 128 ];
swprintf( tmp, 128, L"Nothing received from server on UDP port %d.", port );
swprintf( tmp, 128, L"Nothing received from server on UDP port %s.", port.c_str() );
connecting_notification = wstring( tmp );
}
@@ -209,8 +209,8 @@ void STMClient::shutdown( void )
}
if ( still_connecting() ) {
fprintf( stderr, "\nmosh did not make a successful connection to %s:%d.\n", ip.c_str(), port );
fprintf( stderr, "Please verify that UDP port %d is not firewalled and can reach the server.\n\n", port );
fprintf( stderr, "\nmosh did not make a successful connection to %s:%s.\n", ip.c_str(), port.c_str() );
fprintf( stderr, "Please verify that UDP port %s is not firewalled and can reach the server.\n\n", port.c_str() );
fprintf( stderr, "(By default, mosh uses a UDP port between 60000 and 61000. The -p option\nselects a specific UDP port number.)\n" );
} else if ( network ) {
if ( !clean_shutdown ) {
@@ -247,7 +247,7 @@ void STMClient::main_init( void )
Network::UserStream blank;
Terminal::Complete local_terminal( window_size.ws_col, window_size.ws_row );
network = new Network::Transport< Network::UserStream, Terminal::Complete >( blank, local_terminal,
key.c_str(), ip.c_str(), port );
key.c_str(), ip.c_str(), port.c_str() );
network->set_send_delay( 1 ); /* minimal delay on outgoing keystrokes */
+2 -2
View File
@@ -45,7 +45,7 @@
class STMClient {
private:
std::string ip;
int port;
std::string port;
std::string key;
int escape_key;
@@ -83,7 +83,7 @@ private:
void resume( void ); /* restore state after SIGCONT */
public:
STMClient( const char *s_ip, int s_port, const char *s_key, const char *predict_mode )
STMClient( const char *s_ip, const char *s_port, const char *s_key, const char *predict_mode )
: ip( s_ip ), port( s_port ), key( s_key ),
escape_key( 0x1E ), escape_pass_key( '^' ), escape_pass_key2( '^' ),
escape_requires_lf( false ), escape_key_help( L"?" ),