From a0706572740221e06874d243bed87e49714aad79 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Wed, 17 Jul 2024 23:05:34 +0100 Subject: Don't write any CTCP responses to the replay log file, and encourage bug reporting if the replay log file cannot be read. --- message.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'message.c') diff --git a/message.c b/message.c index 8284268..6f4c9dd 100644 --- a/message.c +++ b/message.c @@ -149,7 +149,7 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int if (clients[i].fd) { char alertmsg[MAXDATASIZE]; if (!doautoreplay(clients[i].fd, clients, settings, ircdstate, channels)) { - snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :Unable to read replay log file!", ircdstate->ircnick); + snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :Unable to read replay log file, please report this if you are expecting it to work!", ircdstate->ircnick); sendtoclient(sourcefd, alertmsg, clients, settings, 0); } snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :Reconnection complete.", ircdstate->ircnick); @@ -848,9 +848,10 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int 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"); + // If it seems to be a CTCP response, don't write to replay log + // to avoid logging and replay weirdness of potentially automated NOTICEs. + if (counter >= 4 && strncmp(tokens[3], ":\1", strlen(":\1")) == 0) { + debugprint(DEBUG_FULL, "Server NOTICE looked like a CTCP response, will not write to replay log.\n"); dontwritereplay = 1; } @@ -1125,7 +1126,7 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int // Catch the client up using whichever replaymode is set if (!doautoreplay(sourcefd, clients, settings, ircdstate, channels)) { - snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Unable to read replay log file!", ircdstate->ircnick); + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Unable to read replay log file, please report this if you are expecting it to work!", ircdstate->ircnick); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); } @@ -1317,15 +1318,15 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int 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 (and not writing to replay log).\n"); + // If it seems to be a CTCP response, just send to the server and don't write to replay log + // to avoid logging and replay weirdness of potentially automated NOTICEs. + if (counter >= 3 && strncmp(tokens[2], ":\1", strlen(":\1")) == 0) { + debugprint(DEBUG_FULL, "Client NOTICE looked like a CTCP 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 write to replay log if replay logging enabled... + // If it wasn't a CTCP response, then write to replay log if replay logging enabled... if (settings->replaylogging) { writereplayline(fullmsg, settings->basedir); } @@ -1432,7 +1433,7 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int debugprint(DEBUG_FULL, "Replaying '%s' which is '%d' seconds.\n", tokens[2], replayseconds); if (!doreplaytime(sourcefd, replayseconds, clients, settings, ircdstate, channels)) { - snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Unable to read replay log file!", ircdstate->ircnick); + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Unable to read replay log file, please report this if you are expecting it to work!", ircdstate->ircnick); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); } free(timestrcopyPtr); @@ -1510,7 +1511,7 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int return 1; } if (!doreplaytime(sourcefd, time(NULL) - codetime, clients, settings, ircdstate, channels)) { - snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Unable to read replay log file!", ircdstate->ircnick); + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Unable to read replay log file, please report this if you are expecting it to work!", ircdstate->ircnick); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); return 1; } -- cgit v1.2.3