From 90fcfc730331e66c2927ecc61bc36be0e51c8eff Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Mon, 27 May 2019 14:09:58 +0100 Subject: Handle CTCP VERSION requests and responses. --- TODO | 2 -- blabouncer.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 6987c7e..badc398 100644 --- a/TODO +++ b/TODO @@ -13,6 +13,4 @@ Allow log replay time to be specified with days:hours:minutes:seconds. Might need to #include in blabouncer.c to make some operating systems and/or compilers happy. -Test CTCP. - Reconnect server if we get disconnected for some reason. diff --git a/blabouncer.c b/blabouncer.c index 886d8b8..07bee1a 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -1543,6 +1543,13 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli // Send original request straight to server sendtoserver(server_ssl, str, strlen(str), sourcefd, clients, settings); + // If it seems to be a CTCP VERSION request, just send to the server (CTCP requests are delimited with \1) + if (counter == 3 && strncmp(tokens[2], ":\1VERSION\1", strlen(tokens[2])) == 0) { + printf("Client PRIVMSG looked like a CTCP VERSION request, so not sending to other clients.\n"); + free(strcopyPtr); + return 1; + } + // Rebuild to full PRIVMSG string and relay to all other clients char outgoingmsg[MAXDATASIZE]; // String to send to client @@ -1660,6 +1667,19 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli return 1; } + // Client NOTICE received + if (strncasecmp(tokens[0], "NOTICE", strlen(tokens[0])) == 0) { + // If it's a CTCP VERSION response then only send to the server (CTCP requests are delimited with \1) + if (counter >= 3 && strncmp(tokens[2], ":\1VERSION", strlen(tokens[2])) == 0) { + printf("Client NOTICE looked like a CTCP VERSION response, so just sending to the server.\n"); + sendtoserver(server_ssl, str, strlen(str), sourcefd, clients, settings); + free(strcopyPtr); + return 1; + } + + // If it wasn't a CTCP VERSION response, then let this fall through to the default unhandled action by not returning here + } + // 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) { -- cgit v1.2.3