From cfe9c969680a7a09ee60cf048f71b81d82bef1df Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Thu, 16 May 2019 21:50:35 +0100 Subject: Make logging and replay logging optional. --- blabouncer.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'blabouncer.c') diff --git a/blabouncer.c b/blabouncer.c index 8ed8d72..41e0a47 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -13,7 +13,6 @@ // - Configurable auto channels // - Comma separated channel list in JOINs/PARTs // - Only send some things to the requesting client (e.g. LIST replies) -// - Customise logging (disabling it, log file location) // - Alert when clients connect/authenticate/disconnect // - Perhaps rename arr_ssl and server_ssl since they may not even be OpenSSL sockets // - Is it possible to replay JOINs/PARTs accurately? @@ -106,6 +105,8 @@ struct settings { int clienttls; int servertls; char basedir[PATH_MAX]; + int logging; + int replaylogging; }; // Return index of requested client FD within arr_clients @@ -688,11 +689,15 @@ int processircmessage(SSL *server_ssl, int *clientsockfd, char *str, int source, sendtoallclients(clientsockfd, fdmax, arr_clients, str, sourcefd, arr_authed, arr_ssl, settings); - // Write to replay log - writereplayline(str, settings->basedir); + // Write to replay log if replay logging enabled + if (settings->replaylogging) { + writereplayline(str, settings->basedir); + } - // Write to normal log - logprivmsg(str, settings->ircnick, settings->basedir); + // Write to normal log if logging enabled + if (settings->logging) { + logprivmsg(str, settings->ircnick, settings->basedir); + } return 1; } @@ -875,11 +880,15 @@ int processircmessage(SSL *server_ssl, int *clientsockfd, char *str, int source, // Send to all except source client sendtoallclients(clientsockfd, fdmax, arr_clients, outgoingmsg, sourcefd, arr_authed, arr_ssl, settings); - // Write to replay log - writereplayline(outgoingmsg, settings->basedir); + // Write to replay log if replay logging enabled + if (settings->replaylogging) { + writereplayline(outgoingmsg, settings->basedir); + } - // Write to normal log - logprivmsg(outgoingmsg, settings->ircnick, settings->basedir); + // Write to normal log if logging enabled + if (settings->logging) { + logprivmsg(outgoingmsg, settings->ircnick, settings->basedir); + } return 1; } @@ -1464,6 +1473,12 @@ int main(int argc, char *argv[]) { } } + // Is logging enabled? + settings.logging = getconfint("logging", settings.conffile); + + // Is replay logging enabled? + settings.replaylogging = getconfint("replaylogging", settings.conffile); + // TODO: see if any of this can be shared (i.e. 1. avoid code duplication, and 2. see if variables can be shared between client/server sockets) // TODO: track fdmax - kind of doing this now with arr_clients and num_clients but might be pointlessly tracking both in some places (?) -- cgit v1.2.3