6
6
#include " PsuedoTerminalConsole.hpp"
7
7
#include " TelemetryService.hpp"
8
8
#include " TerminalClient.hpp"
9
+ #include " TunnelUtils.hpp"
9
10
#include " WinsockContext.hpp"
10
11
11
12
using namespace et ;
@@ -22,6 +23,12 @@ bool ping(SocketEndpoint socketEndpoint,
22
23
return true ;
23
24
}
24
25
26
+ void handleParseException (std::exception & e, cxxopts::Options& options) {
27
+ CLOG (INFO, " stdout" ) << " Exception: " << e.what () << " \n " << endl;
28
+ CLOG (INFO, " stdout" ) << options.help ({}) << endl;
29
+ exit (1 );
30
+ }
31
+
25
32
int main (int argc, char ** argv) {
26
33
WinsockContext context;
27
34
string tmpDir = GetTempDirectory ();
@@ -340,17 +347,21 @@ int main(int argc, char** argv) {
340
347
}
341
348
TelemetryService::get ()->logToDatadog (" Session Started" , el::Level::Info,
342
349
__FILE__, __LINE__);
343
- TerminalClient terminalClient (
344
- clientSocket, clientPipeSocket, socketEndpoint, id, passkey, console,
345
- is_jumphost, result.count (" t" ) ? result[" t" ].as <string>() : " " ,
346
- result.count (" r" ) ? result[" r" ].as <string>() : " " , forwardAgent,
347
- sshSocket, keepaliveDuration);
350
+ string tunnel_arg =
351
+ result.count (" tunnel" ) ? result[" tunnel" ].as <string>() : " " ;
352
+ string r_tunnel_arg = result.count (" reversetunnel" )
353
+ ? result[" reversetunnel" ].as <string>()
354
+ : " " ;
355
+ TerminalClient terminalClient (clientSocket, clientPipeSocket,
356
+ socketEndpoint, id, passkey, console,
357
+ is_jumphost, tunnel_arg, r_tunnel_arg,
358
+ forwardAgent, sshSocket, keepaliveDuration);
348
359
terminalClient.run (result.count (" command" ) ? result[" command" ].as <string>()
349
360
: " " );
361
+ } catch (TunnelParseException& tpe) {
362
+ handleParseException (tpe, options);
350
363
} catch (cxxopts::OptionException& oe) {
351
- CLOG (INFO, " stdout" ) << " Exception: " << oe.what () << " \n " << endl;
352
- CLOG (INFO, " stdout" ) << options.help ({}) << endl;
353
- exit (1 );
364
+ handleParseException (oe, options);
354
365
}
355
366
356
367
#ifdef WIN32
0 commit comments