summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-15 22:01:33 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-15 22:01:33 +0100
commit39d12c5d9de753b86ca6add5e500a7e78c8991ca (patch)
tree6433f5cf03c28f62b282c6375515df299e21962b
parent0bb22808b466fa049de0b13d2cb3b34facc42446 (diff)
Add some help output for unrecognised BLABOUNCER commands.
-rw-r--r--blabouncer.c14
1 files changed, 11 insertions, 3 deletions
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;