From 424ba496e6affc6d9421b1ce7147b34bf5c7913b Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Mon, 16 Sep 2019 20:21:06 +0100 Subject: Log user/channel mode setting in the replay and normal logs. --- message.c | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'message.c') diff --git a/message.c b/message.c index e7139bc..95ffb3a 100644 --- a/message.c +++ b/message.c @@ -521,31 +521,38 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int debugprint(DEBUG_FULL, "Server MODE found and it is: %s with length %zd! Next token is '%s'. Analysing...\n", tokens[1], strlen(tokens[1]), tokens[2]); - // 4 tokens could be either our initial mode or a channel mode (or something else - TODO - what else?) - if (counter == 4) { - // Might be our initial mode (e.g. ":nick MODE nick :+iwz") - char comparison[MAXDATASIZE]; - snprintf(comparison, MAXDATASIZE, ":%s MODE %s :", ircdstate->ircnick, ircdstate->ircnick); - if (strncmp(str, comparison, strlen(comparison)) == 0) { - // Looks like it! - debugprint(DEBUG_FULL, "Our initial MODE found (%s), storing for later.\n", tokens[3]); - // Store in ircdstate for when clients connect and relay to current clients. - strcpy(ircdstate->mode, tokens[3]); - - // Relay to all current clients anyway - TODO - Necessary? - sendtoallclients(clients, str, sourcefd, settings); + // Might be our initial mode (e.g. ":nick MODE nick :+iwz") + char comparison[MAXDATASIZE]; + snprintf(comparison, MAXDATASIZE, ":%s MODE %s :", ircdstate->ircnick, ircdstate->ircnick); + if (strncmp(str, comparison, strlen(comparison)) == 0) { + // Looks like it! + debugprint(DEBUG_FULL, "Our initial MODE found (%s), storing for later.\n", tokens[3]); + // Store in ircdstate for when clients connect and relay to current clients. + strcpy(ircdstate->mode, tokens[3]); + + // Relay to all current clients anyway - TODO - Necessary? + sendtoallclients(clients, str, sourcefd, settings); - return 1; - } + return 1; + } - // Might be a channel mode (e.g. ":nick!user@host MODE #channel +s") - if (tokens[2][0] == '#') { - // Looks like it! Tell all clients. - debugprint(DEBUG_FULL, "Channel MODE found (%s %s), telling all clients.\n", tokens[2], tokens[3]); - sendtoallclients(clients, str, sourcefd, settings); + // Might be a channel mode (e.g. ":nick!user@host MODE #channel +s") + if (tokens[2][0] == '#') { + // Looks like it! Tell all clients. + debugprint(DEBUG_FULL, "Channel MODE found (%s %s), telling all clients.\n", tokens[2], tokens[3]); + sendtoallclients(clients, str, sourcefd, settings); - return 1; + // Write to replay log if replay logging enabled + if (settings->replaylogging) { + writereplayline(str, settings->basedir); + } + + // Write to normal log if logging enabled + if (settings->logging) { + logline(str, ircdstate, settings->basedir, LOG_MODE); } + + return 1; } // Relay to all current clients if not processed by the above -- cgit v1.2.3