From 7fb542c8742fa1ad116521f223393177518671b5 Mon Sep 17 00:00:00 2001 From: John Hood Date: Thu, 30 Jul 2015 00:14:31 -0400 Subject: [PATCH] Change SSH_CONNECTION fallback to allow IPv6 --- src/frontend/mosh-server.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 76ed2ed..1f932b7 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -131,14 +131,14 @@ static string get_SSH_IP( void ) const char *SSH_CONNECTION = getenv( "SSH_CONNECTION" ); if ( !SSH_CONNECTION ) { /* Older sshds don't set this */ fprintf( stderr, "Warning: SSH_CONNECTION not found; binding to any interface.\n" ); - return string( "0.0.0.0" ); + return string( "" ); } istringstream ss( SSH_CONNECTION ); string dummy, local_interface_IP; ss >> dummy >> dummy >> local_interface_IP; if ( !ss ) { fprintf( stderr, "Warning: Could not parse SSH_CONNECTION; binding to any interface.\n" ); - return string( "0.0.0.0" ); + return string( "" ); } /* Strip IPv6 prefix. */ @@ -196,8 +196,10 @@ int main( int argc, char *argv[] ) break; case 's': desired_ip_str = get_SSH_IP(); - desired_ip = desired_ip_str.c_str(); - fatal_assert( desired_ip ); + if ( !desired_ip_str.empty() ) { + desired_ip = desired_ip_str.c_str(); + fatal_assert( desired_ip ); + } break; case 'c': try {