From 4375415b9228c0537d1d18b1f1ba263d286f7f3a Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Thu, 10 Feb 2022 21:21:07 +0000 Subject: Relay server PINGs to all clients in case they rely on PINGs to stay alive. --- TODO | 7 +++++++ message.c | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/TODO b/TODO index 4240d87..201eaf6 100644 --- a/TODO +++ b/TODO @@ -24,4 +24,11 @@ Do connectcommands happen on reconnect? Are "no such nick/channel" messages as shown in clients correct compared to non-(bla)bouncer clients? +Support ban list when requesting /mode #channel +b (commands 367 and 368 at least) - ensure max ban list length is supported. example: +:irc.tghost.co.uk 367 l_bratch #foo *!foo@bar.bz l_bratch 1642588731 +:irc.tghost.co.uk 367 l_bratch #foo *!*bbuser@*.bratch.co.uk l_bratch 1642588681 +:irc.tghost.co.uk 368 l_bratch #foo :End of Channel Ban List +Or if there are no bans then just 368: +:irc.tghost.co.uk 368 l_bratch #foo :End of Channel Ban List + Crash when requesting 30 hour replay. diff --git a/message.c b/message.c index 5f0c2fe..9c07a83 100644 --- a/message.c +++ b/message.c @@ -39,6 +39,14 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int // sourcefd = 0 as this is a trusted response sendtoserver(server_ssl, outgoingmsg, strlen(outgoingmsg), 0, clients, settings); + // Also relay the request to all clients in case they were expecting PINGs to keep themselves alive + if (!snprintf(outgoingmsg, MAXDATASIZE, "PING %s", tokens[1])) { // TODO - Make sure tokens[1] actually has a token + fprintf(stderr, "Error while preparing PING relay!\n"); + debugprint(DEBUG_CRIT, "Error while preparing PING relay!\n"); + outgoingmsg[0] = '\0'; + } + sendtoallclients(clients, outgoingmsg, EXCEPT_NONE, settings); + // We processed something so return true return 1; } @@ -1091,6 +1099,13 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int return 1; } + // Client PONG received? This is almost certainly in response to a relayed server PING from us. + // We can ignore it since we don't actively PING clients, instead relying on the server's PING frequency. + if (strncasecmp(tokens[0], "PONG", strlen(tokens[0])) == 0) { + debugprint(DEBUG_FULL, "Client PONG found and it is: %s with length %zd! Ignoring since we don't track client PONGs.\n", tokens[0], strlen(tokens[0])); + return 1; + } + // TODO - Ignoring CAP for now so as not to confuse other clients, but we should probably query the server then relay the response to the client if (strncasecmp(tokens[0], "CAP", strlen(tokens[0])) == 0) { debugprint(DEBUG_FULL, "Client CAP found and it is: %s with length %zd! Ignoring completely for now - TODO - do something useful!\n", tokens[0], strlen(tokens[0])); -- cgit v1.2.3