diff options
author | Luke Bratch <luke@bratch.co.uk> | 2023-04-09 01:25:17 +0200 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2023-04-09 01:25:17 +0200 |
commit | ee74977dae90d8cb037a757f7561ceee27819784 (patch) | |
tree | e5991c75f2a09d01d8c460ea6f7e6a5e82a86fec | |
parent | 72d8b6d1a71a90ca8a765e0defb5159b4deea562 (diff) |
Don't write CTCP VERSION messages to replay log. CTCP VERSION replay/relay behaviour is now as follows:
Replaying:
PRIVMSG VERSION - requests - from other people - don't replay (only valid when originally sent).
PRIVMSG VERSION - requests - from us - don't replay (we shouldn't receive our own requests).
NOTICE VERSION - responses - from other people - don't replay (only valid when originally sent).
NOTICE VERSION - responses - from us - don't replay (we shouldn't receive our own responses).
Relaying (to non-requesting Blabouncer clients):
PRIVMSG VERSION - requests - from other people - do relay (responses are valid from all our clients).
PRIVMSG VERSION - requests - from us - don't relay (we shouldn't receive our own requests).
NOTICE VERSION - responses - from other people - do relay (can't know number of responses in advance, might get unsolicited messages).
NOTICE VERSION - responses - from us - don't relay (we shouldn't receive our own responses).
-rw-r--r-- | message.c | 35 |
1 files changed, 26 insertions, 9 deletions
@@ -437,8 +437,16 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int sendtoallclients(clients, str, sourcefd, settings); + int dontwritereplay = 0; + + // If it seems to be a CTCP VERSION request, don't write to replay log + if (counter >= 4 && strncmp(tokens[3], ":\1VERSION\1", strlen(tokens[3])) == 0) { + debugprint(DEBUG_FULL, "Server PRIVMSG looked like a CTCP VERSION request, will not write to replay log.\n"); + dontwritereplay = 1; + } + // Write to replay log if replay logging enabled - if (settings->replaylogging) { + if (settings->replaylogging && !dontwritereplay) { writereplayline(str, settings->basedir); } @@ -801,8 +809,16 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int sendtoallclients(clients, str, 0, settings); + int dontwritereplay = 0; + + // If it seems to be a CTCP VERSION response, don't write to replay log + if (counter >= 4 && strncmp(tokens[3], ":\1VERSION", strlen(tokens[3])) == 0) { + debugprint(DEBUG_FULL, "Server NOTICE looked like a CTCP VERSION response, will not write to replay log.\n"); + dontwritereplay = 1; + } + // Write to replay log if replay logging enabled - if (settings->replaylogging) { + if (settings->replaylogging && !dontwritereplay) { writereplayline(str, settings->basedir); } @@ -1253,24 +1269,25 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int return 0; } - // Write to replay log if replay logging enabled - if (settings->replaylogging) { - writereplayline(fullmsg, settings->basedir); - } - // Write to normal log if logging enabled if (settings->logging) { logline(fullmsg, ircdstate, settings->basedir, LOG_PRIVMSG); } // If it's a CTCP VERSION response then only send to the server (CTCP requests are delimited with \1) + // and don't write to replay log if (counter >= 3 && strncmp(tokens[2], ":\1VERSION", strlen(tokens[2])) == 0) { - debugprint(DEBUG_FULL, "Client NOTICE looked like a CTCP VERSION response, so just sending to the server.\n"); + debugprint(DEBUG_FULL, "Client NOTICE looked like a CTCP VERSION response, so just sending to the server (and not writing to replay log).\n"); sendtoserver(server_ssl, str, strlen(str), sourcefd, clients, settings); return 1; } - // If it wasn't a CTCP VERSION response, then let this fall through to the default unhandled action by not returning here + // If it wasn't a CTCP VERSION response, then write to replay log if replay logging enabled... + if (settings->replaylogging) { + writereplayline(fullmsg, settings->basedir); + } + + // ...and then let this fall through to the default unhandled action by not returning here } // Client PROTOCTL received |