From 0559bff00a6be2054194632c3543bf62af1fb56f Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sat, 11 May 2019 19:03:57 +0100 Subject: Add the ability to replay messages from a replay log file. (No replay log file writing yet.) --- blabouncer.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'blabouncer.c') diff --git a/blabouncer.c b/blabouncer.c index ba9dca0..2e1f414 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -8,7 +8,9 @@ // - Add blabouncer MOTD (375, 372, 376) // - "01:53:47 -!- ServerMode/#test [b] by irc.tghost.co.uk" on existing clients when new client connects // - Keep track of changing user nicks/modes -// - Relay log can just be "log/resend everything that ever hit sendto[all]client[s]()" +// - Relay log can just be "log/resend everything that ever hit sendto[all]client[s]()" (or maybe just PRIVMSGs? + NOTICEs and friends?) +// - Implement TLS +// - Implement password/login // // Example WHOIS reply: // BOUNCER-SERVER RECEIVED: :irc.tghost.co.uk 307 blabounce l_bratch :is identified for this nick @@ -32,6 +34,7 @@ #include "functions.h" #include "sockets.h" #include "config.h" +#include "replay.h" #define SOURCE_SERVER 0 #define SOURCE_CLIENT 1 @@ -645,6 +648,28 @@ int processircmessage(int *serversockfd, int *clientsockfd, char *str, int sourc sendtoclient(sourcefd, outgoingmsg); } + // Send the client however many relay lines have been requested + int relaysecs = confrelayseconds(); + + // Figure out how many lines to relay + int numlines = relaylines(relaysecs); + printf("Replay log lines: '%d'.\n", numlines); + + if (numlines < 0) { + printf("Error getting number of replay lines.\n"); + exit(1); + } + + // Relay those lines! + for (int i = 0; i < numlines; i++) { + if (!readrelayline(relaysecs, i, outgoingmsg)) { + printf("Error requesting relay line.\n"); + exit(1); + } + printf("Sending relay line: '%s'.\n", outgoingmsg); + sendtoclient(sourcefd, outgoingmsg); + } + return 1; } -- cgit v1.2.3