summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blabouncer.c33
-rw-r--r--blabouncer.conf8
-rw-r--r--config.c10
3 files changed, 41 insertions, 10 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 (?)
diff --git a/blabouncer.conf b/blabouncer.conf
index cf9591b..b834c8e 100644
--- a/blabouncer.conf
+++ b/blabouncer.conf
@@ -41,3 +41,11 @@ keyfile = "key.pem"
# Base directory (defaults to $HOME/.blabouncer/)
# Things such as the logs directory will be placed below this
#basedir = "/home/foo/.blabouncer/"
+
+# Enable logging ("1" for yes or "0" for no)
+# Logs go to basedir/logs/ with one file per channel/nick
+logging = "1"
+
+# Enable replay logging ("1" for yes or "0" for no)
+# Replay log goes to basedir/replay.log
+replaylogging = "1"
diff --git a/config.c b/config.c
index a5d9c2f..60bac19 100644
--- a/config.c
+++ b/config.c
@@ -201,7 +201,15 @@ int createconfigfile(char *filename) {
"\n"
"# Base directory (defaults to $HOME/.blabouncer/)\n"
"# Things such as the logs directory will be placed below this\n"
- "#basedir = \"/home/foo/.blabouncer/\"\n";
+ "#basedir = \"/home/foo/.blabouncer/\"\n"
+ "\n"
+ "# Enable logging (\"1\" for yes or \"0\" for no)\n"
+ "# Logs go to basedir/logs/ with one file per channel/nick\n"
+ "logging = \"1\"\n"
+ "\n"
+ "# Enable replay logging (\"1\" for yes or \"0\" for no)\n"
+ "# Replay log goes to basedir/replay.log\n"
+ "replaylogging = \"1\"\n";
// Write complete string to file
if ((fprintf(fp, string)) < 0) {