summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-29 23:01:40 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-29 23:01:40 +0100
commitef93f4d61f03faa0edd60f11c7790ad3b67b44d4 (patch)
tree89eceef73515b78fbc2111bc7197730211d537b2 /blabouncer.c
parent013e8d87e979b121b1589ca9609e9b721e8f3a81 (diff)
Include NOTICEs in the replay log and normal logs. Particularly useful for relaying NickServ IDENTIFY password warnings to clients shortly after connecting.
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/blabouncer.c b/blabouncer.c
index e5f1723..8a718df 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -1479,6 +1479,32 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
// We didn't handle it
debugprint("Unhandled server CAP response.\n");
}
+
+ // Server NOTICE received? Handle and log if it's from a user, otherwise let pass through to default handler.
+ if (strncmp(tokens[1], "NOTICE", strlen(tokens[1])) == 0) {
+ debugprint("Server NOTICE found and it is: %s with length %zd! Analysing...\n", tokens[1], strlen(tokens[1]));
+ // If the first token is a nick!user@host then it's probably from a user
+ if (strstr(tokens[0], "!") != NULL && strstr(tokens[0], "@") != NULL) {
+ debugprint("Server NOTICE appears to be from a user, sending to all clients and logging.\n");
+
+ sendtoallclients(clients, str, 0, settings);
+
+ // 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, settings->ircnick, settings->basedir, LOG_PRIVMSG);
+ }
+
+ free(strcopyPtr);
+ return 1;
+ } else {
+ debugprint("Server NOTICE does not appear to be from a user, passing through.\n");
+ }
+ }
}
// Don't return if we got here because this means we didn't process something above
@@ -1877,6 +1903,25 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
// Client NOTICE received
if (strncasecmp(tokens[0], "NOTICE", strlen(tokens[0])) == 0) {
+
+ // Rebuild to full NOTICE string including our nick!user@host for logging
+ char fullmsg[MAXDATASIZE];
+
+ if (!snprintf(fullmsg, MAXDATASIZE, "%s %s", ircdstrings->nickuserhost, str)) {
+ fprintf(stderr, "Error while preparing NOTICE string for logging.\n");
+ exit(1);
+ }
+
+ // 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, settings->ircnick, settings->basedir, LOG_PRIVMSG);
+ }
+
// 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) {
debugprint("Client NOTICE looked like a CTCP VERSION response, so just sending to the server.\n");