summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-10-24 01:18:51 -0400
committerJune McEnroe <june@causal.agency>2019-10-24 01:18:51 -0400
commitf0db35a714ccd898b5fbae30a16c6fdfb567ad32 (patch)
tree2fcc0622335b0b5eaf7d3a6a903a1769b717bc3a /client.c
parentIgnore further CAP END (diff)
downloadpounce-f0db35a714ccd898b5fbae30a16c6fdfb567ad32.tar.gz
pounce-f0db35a714ccd898b5fbae30a16c6fdfb567ad32.zip
Intercept all CAP commands from clients
Diffstat (limited to '')
-rw-r--r--client.c8
1 files changed, 7 insertions, 1 deletions
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 {