From f0db35a714ccd898b5fbae30a16c6fdfb567ad32 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Thu, 24 Oct 2019 01:18:51 -0400 Subject: Intercept all CAP commands from clients --- client.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client.c b/client.c index 18aef87..68daff6 100644 --- a/client.c +++ b/client.c @@ -184,6 +184,12 @@ static void clientParse(struct Client *client, char *line) { } } +static bool intercept(const char *line, size_t len) { + if (len >= 4 && !memcmp(line, "CAP ", 4)) return true; + // TODO: Intercept PRIVMSG to send to other clients. + return false; +} + void clientRecv(struct Client *client) { ssize_t read = tls_read( client->tls, @@ -205,7 +211,7 @@ void clientRecv(struct Client *client) { if (verbose) { fprintf(stderr, "\x1B[33m%.*s\x1B[m\n", (int)(crlf - line), line); } - if (client->need) { + if (client->need || intercept(line, crlf - line)) { crlf[0] = '\0'; clientParse(client, line); } else { -- cgit 1.4.1