Client takes key on standard input (to keep out of argument list)

This commit is contained in:
Keith Winstein
2012-02-02 17:42:47 -05:00
parent 740226e66a
commit 7db8270431
2 changed files with 18 additions and 9 deletions
+3 -2
View File
@@ -163,9 +163,10 @@ void serve( int host_fd, const char *desired_ip )
Network::UserStream blank;
Network::Transport< Terminal::Complete, Network::UserStream > network( terminal, blank, desired_ip );
network.set_verbose();
/* network.set_verbose(); */
printf( "key= %s port= %d\n", network.get_key().c_str(), network.port() );
printf( "CONNECT %d %s\n", network.port(), network.get_key().c_str() );
fflush( stdout );
/* prepare to poll for events */
struct pollfd pollfds[ 3 ];
+15 -7
View File
@@ -1,33 +1,41 @@
#include "stmclient.hpp"
#include "crypto.hpp"
#include <iostream>
int main( int argc, char *argv[] )
{
/* Get arguments */
char *ip, *key;
char *ip;
int port;
if ( argc != 4 ) {
fprintf( stderr, "Usage: %s IP PORT KEY\n", argv[ 0 ] );
if ( argc != 3 ) {
fprintf( stderr, "Usage: %s IP PORT\n", argv[ 0 ] );
exit( 1 );
}
ip = argv[ 1 ];
port = atoi( argv[ 2 ] );
key = argv[ 3 ];
port = myatoi( argv[ 2 ] );
STMClient client( ip, port, key );
/* Read key from standard input */
cout << "Key: ";
string key;
cin >> key;
/* Adopt implementation locale */
/* Adopt native locale */
if ( NULL == setlocale( LC_ALL, "" ) ) {
perror( "setlocale" );
exit( 1 );
}
STMClient client( ip, port, key.c_str() );
client.init();
client.main();
client.shutdown();
printf( "\n[mosh is exiting.]\n" );
return 0;