summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-11 19:03:57 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-11 19:03:57 +0100
commit0559bff00a6be2054194632c3543bf62af1fb56f (patch)
treef007a35d1d7af9a7fa1166831b982c84111baad7 /blabouncer.c
parentc46d01b5afd2da4779efb2700469037eca6122be (diff)
Add the ability to replay messages from a replay log file. (No replay log file writing yet.)
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c27
1 files changed, 26 insertions, 1 deletions
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;
}