From 39d12c5d9de753b86ca6add5e500a7e78c8991ca Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Wed, 15 May 2019 22:01:33 +0100 Subject: Add some help output for unrecognised BLABOUNCER commands. --- blabouncer.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'blabouncer.c') diff --git a/blabouncer.c b/blabouncer.c index 3cf9877..9f6f5cf 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -894,9 +894,10 @@ int processircmessage(SSL *server_ssl, int *clientsockfd, char *str, int source, // Custom BLABOUNCER command received // Case insensitive comparisons here since clients won't be recognising and uppercasing these commands if (strncasecmp(tokens[0], "BLABOUNCER", strlen(tokens[0])) == 0) { + printf("Client BLABOUNCER found and it is: %s with length %zd!\n", tokens[1], strlen(tokens[1])); // REPLAY received, send the requested number of seconds of replay to the client if (strncasecmp(tokens[1], "REPLAY", strlen(tokens[1])) == 0) { - printf("Client REPLAY (custom blabouncer command) found and it is: %s with length %zd!\n", tokens[1], strlen(tokens[1])); + printf("Client BLABOUNCER REPLAY (custom blabouncer command) found and it is: %s with length %zd!\n", tokens[1], strlen(tokens[1])); int replayseconds; if ((replayseconds = strtol(tokens[2], NULL, 10)) == 0) { printf("Invalid number of replay seconds provided by REPLAY. Telling client.\n"); @@ -911,9 +912,16 @@ int processircmessage(SSL *server_ssl, int *clientsockfd, char *str, int source, doreplay(sourcefd, replayseconds, arr_clients, arr_authed, arr_ssl, settings); return 1; + // Unrecognised BLABOUNCER command received, send some help instructions + } else { + printf("Client BLABOUNCER unrecognised command found and it is: %s with length %zd! Sending a help message.\n", tokens[1], strlen(tokens[1])); + char outgoingmsg[MAXDATASIZE]; + snprintf(outgoingmsg, MAXDATASIZE, "Unrecognised BLABOUNCER command received. Valid commands are:"); + sendtoclient(sourcefd, outgoingmsg, arr_clients, arr_authed, arr_ssl, settings); + snprintf(outgoingmsg, MAXDATASIZE, "\"BLABOUNCER REPLAY [seconds]\" (Where [seconds] is the number of seconds of replay log to replay.)"); + sendtoclient(sourcefd, outgoingmsg, arr_clients, arr_authed, arr_ssl, settings); + return 1; } - - // If here then although BLABOUNCER command received, it wasn't recognised, so don't return } break; -- cgit v1.2.3