summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-16 21:50:35 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-16 21:50:35 +0100
commitcfe9c969680a7a09ee60cf048f71b81d82bef1df (patch)
treeb035bf87184f3168722acf97e0a043bf2d00f2f6 /blabouncer.c
parent61a369b85e51e0d54e1651e4ff8c11fe4815a0c0 (diff)
Make logging and replay logging optional.
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c33
1 files changed, 24 insertions, 9 deletions
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 (?)