diff --git a/shell/include/sterm.h b/shell/include/sterm.h index 49e31c8..70e3676 100644 --- a/shell/include/sterm.h +++ b/shell/include/sterm.h @@ -31,13 +31,20 @@ typedef enum { TERM_BRIGHT_WHITE } TERM_COLOR; +#define PRINTTAG(color) shellT_printf("\r%s[~]%s ", shellT_getForeColor(color), shellT_getForeColor(TERM_BRIGHT_WHITE)) + #define PRINTINFO(...) do { \ - shellT_printf("\r%s[~]%s ", shellT_getForeColor(TERM_BRIGHT_YELLOW), shellT_getForeColor(TERM_BRIGHT_WHITE)); \ + PRINTTAG(TERM_BRIGHT_YELLOW); \ shellT_printf(__VA_ARGS__); \ } while(0); #define PRINTSUCC(...) do { \ - shellT_printf("\r%s[~]%s ", shellT_getForeColor(TERM_BRIGHT_GREEN), shellT_getForeColor(TERM_BRIGHT_WHITE)); \ + PRINTTAG(TERM_BRIGHT_GREEN); \ + shellT_printf(__VA_ARGS__); \ +} while(0); + +#define PRINTERROR(...) do { \ + PRINTTAG(TERM_BRIGHT_RED); \ shellT_printf(__VA_ARGS__); \ } while(0); diff --git a/shell/src/main.c b/shell/src/main.c index 888df00..1a359dc 100644 --- a/shell/src/main.c +++ b/shell/src/main.c @@ -38,5 +38,6 @@ int main(int argv, char *argc[]) { } shellC_cleanup(&client); + PRINTERROR("Connection closed\n"); return 0; } \ No newline at end of file diff --git a/shell/src/scmd.c b/shell/src/scmd.c index c69f3f1..c9c7ea4 100644 --- a/shell/src/scmd.c +++ b/shell/src/scmd.c @@ -34,14 +34,20 @@ int shellS_readInt(char *str) { void helpCMD(tShell_client *client, int args, char *argc[]); +void quitCMD(tShell_client *client, int args, char *argc[]) { + PRINTINFO("Killing socket...\n"); + laikaS_kill(&client->peer->sock); +} + void listPeers(tShell_client *client, int args, char *argc[]) { int i; shellT_printf("\n"); for (i = 0; i < client->peerTblCount; i++) { if (client->peerTbl[i]) { - shellT_printf("\n%04d ", i); + shellT_printf("%04d ", i); shellP_printInfo(client->peerTbl[i]); + shellT_printf("\n"); } } shellT_printf("\n"); @@ -84,7 +90,7 @@ void openShell(tShell_client *client, int args, char *argc[]) { shellT_resetTerm(); shellT_conioTerm(); - PRINTSUCC("Shell closed!\n\n"); + PRINTSUCC("Shell closed!\n"); } /* =============================================[[ Command Table ]]============================================== */ @@ -93,6 +99,7 @@ void openShell(tShell_client *client, int args, char *argc[]) { tShell_cmdDef shellS_cmds[] = { CREATECMD("help", "Lists avaliable commands", helpCMD), + CREATECMD("quit", "Disconnects from CNC, closing panel", quitCMD), CREATECMD("list", "Lists all connected peers to CNC", listPeers), CREATECMD("shell", "Opens a shell on peer", openShell), }; @@ -163,6 +170,7 @@ void shellS_runCmd(tShell_client *client, char *cmd) { } /* run command */ + shellT_printf("\n"); if (setjmp(cmdE_err) == 0) { cmdDef->callback(client, args, argc); }