From 61906329ccbe96c25c75533f819dea269492f5a7 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sun, 16 Jun 2019 23:16:18 +0100 Subject: Implement two new auto replay modes: - replaymode = "noclients": All messages since the bouncer last had no clients connected - replaymode = "lastchange": All messages since the last client connect or disconnect --- blabouncer.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'blabouncer.c') diff --git a/blabouncer.c b/blabouncer.c index 3b0a538..95521f1 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -133,6 +133,7 @@ int connecttoircserver(SSL_CTX **serverctx, SSL **server_ssl, int *serversockfd, ircdstate->lastmessagetime = time(NULL); ircdstate->timeoutcheck = 0; // ircdstate.reconnecting is not set here as we want to track reconnections separately + // ircdstate.clientchangetime and ircdstate.clientsnonetime not set here as they are set at startup and only changed when clients connect/disconnect // Populate nick and username from our configuration file for now, real IRCd may change them later (TODO - Is this true of username?) strcpy(ircdstate->ircnick, settings->ircnick); @@ -412,9 +413,11 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) { SSL_CTX *serverctx = NULL; SSL *server_ssl = NULL; // Need to create this either way as referenced later - // Set reconnection things to null/zero for now (not used unless reconnecting to server) + // Set reconnection and other things to null/zero for now (not used unless reconnecting to server) ircdstate.oldnick[0] = '\0'; ircdstate.reconnecting = 0; + ircdstate.clientchangetime = time(NULL); + ircdstate.clientsnonetime = time(NULL); if (!connecttoircserver(&serverctx, &server_ssl, serversockfd, &ircdstate, settings, clients)) { fprintf(stderr, "Failed to connect to IRC server, exiting.\n"); debugprint(DEBUG_CRIT, "Failed to connect to IRC server, exiting.\n"); @@ -877,8 +880,9 @@ int main(int argc, char *argv[]) { printf("main(): error getting 'replaymode' from configuration file.\n"); exit(1); } else { - if (strcmp(settings.replaymode, "none") && strcmp(settings.replaymode, "time") && strcmp(settings.replaymode, "lastspoke")) { - printf("main(): replaymode in configuration file must be one of \"none\", \"time\", or \"lastspoke\".\n"); + if (strcmp(settings.replaymode, "none") && strcmp(settings.replaymode, "time") && strcmp(settings.replaymode, "lastspoke") && + strcmp(settings.replaymode, "noclients") && strcmp(settings.replaymode, "lastchange")) { + printf("main(): replaymode in configuration file must be one of \"none\", \"time\", \"lastspoke\", \"noclients\", or \"lastchange\".\n"); exit(1); } } -- cgit v1.2.3