Client takes key on standard input (to keep out of argument list)
This commit is contained in:
+3
-2
@@ -163,9 +163,10 @@ void serve( int host_fd, const char *desired_ip )
|
|||||||
Network::UserStream blank;
|
Network::UserStream blank;
|
||||||
Network::Transport< Terminal::Complete, Network::UserStream > network( terminal, blank, desired_ip );
|
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 */
|
/* prepare to poll for events */
|
||||||
struct pollfd pollfds[ 3 ];
|
struct pollfd pollfds[ 3 ];
|
||||||
|
|||||||
@@ -1,33 +1,41 @@
|
|||||||
#include "stmclient.hpp"
|
#include "stmclient.hpp"
|
||||||
|
#include "crypto.hpp"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
/* Get arguments */
|
/* Get arguments */
|
||||||
char *ip, *key;
|
char *ip;
|
||||||
int port;
|
int port;
|
||||||
|
|
||||||
if ( argc != 4 ) {
|
if ( argc != 3 ) {
|
||||||
fprintf( stderr, "Usage: %s IP PORT KEY\n", argv[ 0 ] );
|
fprintf( stderr, "Usage: %s IP PORT\n", argv[ 0 ] );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
ip = argv[ 1 ];
|
ip = argv[ 1 ];
|
||||||
port = atoi( argv[ 2 ] );
|
port = myatoi( argv[ 2 ] );
|
||||||
key = argv[ 3 ];
|
|
||||||
|
|
||||||
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, "" ) ) {
|
if ( NULL == setlocale( LC_ALL, "" ) ) {
|
||||||
perror( "setlocale" );
|
perror( "setlocale" );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STMClient client( ip, port, key.c_str() );
|
||||||
|
|
||||||
client.init();
|
client.init();
|
||||||
|
|
||||||
client.main();
|
client.main();
|
||||||
|
|
||||||
client.shutdown();
|
client.shutdown();
|
||||||
|
|
||||||
printf( "\n[mosh is exiting.]\n" );
|
printf( "\n[mosh is exiting.]\n" );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user