From 423b67d02582275a08b53fd7a9eceb9bc25fd81b Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 10 Jun 2021 15:05:15 -0400 Subject: Stop accumulating ISUPPORT tokens once MOTD starts This avoids duplicating tokens when a client sends VERSION and the server responds with its 005s again. --- state.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/state.c b/state.c index 6b26589..85d921a 100644 --- a/state.c +++ b/state.c @@ -205,6 +205,7 @@ static void handleReplyMyInfo(struct Message *msg) { } static struct { + bool done; char **tokens; size_t cap, len; } support; @@ -222,12 +223,18 @@ static void supportAdd(const char *token) { static void handleReplyISupport(struct Message *msg) { require(msg, false, 1); + if (support.done) return; for (size_t i = 1; i < ParamCap; ++i) { if (!msg->params[i] || strchr(msg->params[i], ' ')) break; supportAdd(msg->params[i]); } } +static void handleReplyMOTDStart(struct Message *msg) { + (void)msg; + support.done = true; +} + struct Channel { char *name; char *topic; @@ -339,6 +346,8 @@ static const struct { { "004", handleReplyMyInfo }, { "005", handleReplyISupport }, { "332", handleReplyTopic }, + { "375", handleReplyMOTDStart }, + { "422", handleReplyMOTDStart }, { "433", handleErrorNicknameInUse }, { "437", handleErrorNicknameInUse }, { "900", handleReplyLoggedIn }, -- cgit 1.4.1