From 33bb47c623d1c605a5a131ef882feb6df42570b7 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sun, 31 Mar 2024 22:23:59 +0100 Subject: Don't bother trying to do removenickfromchannel() after a PART or a KICK if we just did removechannel() because the PARTing/KICKed nick was ours. --- TODO | 9 --------- message.c | 30 +++++++++++++----------------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/TODO b/TODO index c0000c8..506f977 100644 --- a/TODO +++ b/TODO @@ -35,15 +35,6 @@ Debug log ("checking client socket out of ") gets busy after fdmax ge Combine custom BLABOUNCER commands with stdin commands (or ditch stdin?). -KICK not handled (temporary work in kick-support-20230409.diff) -KICK: -Sun Apr 9 03:35:31 2023: BOUNCER-SERVER RECEIVED: ':bbnick!bbuser@2a06:5844:e:551:0:0:0:1d KICK #bla12 bbounce2 :bbnick -Sun Apr 9 03:35:31 2023: Server KICK: nick is NOT ours ('bbnick' vs 'bbounce2'). -PART: -Sun Apr 9 04:16:09 2023: BOUNCER-SERVER RECEIVED: ':bbounce2!l_bratch@2a06:5844:e:551:0:0:0:1d PART #bla12 :Leaving -Sun Apr 9 04:16:09 2023: Server PART: nick is ours ('bbounce2' vs 'bbounce2'). -^^Reminder, joining channels (and getting the nick list) seems to be broken right now (TG reminder). - Crash when requesting 30 hour replay. Users in channel not being populated observed once - 27/07/2023 #pipewire on irc.oftc.net. (and again 14/09/2023) diff --git a/message.c b/message.c index 9d85f63..07292be 100644 --- a/message.c +++ b/message.c @@ -240,16 +240,14 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int // Just get the nick for comparison extractnickfromprefix(prefixcopy, 1); if ((strlen(prefixcopy) == strlen(ircdstate->ircnick)) && (strncmp(prefixcopy, ircdstate->ircnick, strlen(tokens[0])) == 0)) { - debugprint(DEBUG_FULL, "Server PART: nick is ours ('%s' vs '%s').\n", prefixcopy, ircdstate->ircnick); + debugprint(DEBUG_FULL, "Server PART: nick is ours ('%s' vs '%s'), removing channel.\n", prefixcopy, ircdstate->ircnick); removechannel(channels, ircdstate->maxchannelcount, tokens[2]); } else { - debugprint(DEBUG_FULL, "Server PART: nick is NOT ours ('%s' vs '%s').\n", prefixcopy, ircdstate->ircnick); - } - - // Remove the PARTing nick from our local channel struct - // TODO - don't bother with this if we did removechannel() above? - if (!removenickfromchannel(tokens[0], tokens[2], channels, ircdstate->maxchannelcount)) { - debugprint(DEBUG_CRIT, "Failed to remove nick from channel struct.\n"); + debugprint(DEBUG_FULL, "Server PART: nick is NOT ours ('%s' vs '%s'), removing nick from channel.\n", prefixcopy, ircdstate->ircnick); + // Remove the PARTing nick from our local channel struct + if (!removenickfromchannel(tokens[0], tokens[2], channels, ircdstate->maxchannelcount)) { + debugprint(DEBUG_CRIT, "Failed to remove nick from channel struct.\n"); + } } // And then send to all clients @@ -276,17 +274,15 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int // If the user being KICKed is us, then we must have left a channel, so remove it from our local channel array. // (If it's not us, then it's another user being KICKed from a channel, so just pass straight through to letting all our clients know.) if ((strlen(tokens[3]) == strlen(ircdstate->ircnick)) && (strncmp(tokens[3], ircdstate->ircnick, strlen(tokens[3])) == 0)) { - debugprint(DEBUG_FULL, "Server KICK: nick is ours ('%s' vs '%s').\n", tokens[3], ircdstate->ircnick); + debugprint(DEBUG_FULL, "Server KICK: nick is ours ('%s' vs '%s'), removing channel.\n", tokens[3], ircdstate->ircnick); removechannel(channels, ircdstate->maxchannelcount, tokens[2]); } else { - debugprint(DEBUG_FULL, "Server KICK: nick is NOT ours ('%s' vs '%s').\n", tokens[3], ircdstate->ircnick); - } - - // Remove the KICKed nick from our local channel struct - // TODO - removenickfromchannel() first argument expects ":nick!user@host" but we're passing "nick" here - // TODO - don't bother with this if we did removechannel() above? - if (!removenickfromchannel(tokens[3], tokens[2], channels, ircdstate->maxchannelcount)) { - debugprint(DEBUG_CRIT, "Server KICK: Failed to remove nick from channel struct.\n"); + debugprint(DEBUG_FULL, "Server KICK: nick is NOT ours ('%s' vs '%s'), removing nick from channel.\n", tokens[3], ircdstate->ircnick); + // Remove the KICKed nick from our local channel struct + // TODO - removenickfromchannel() first argument expects ":nick!user@host" but we're passing "nick" here + if (!removenickfromchannel(tokens[3], tokens[2], channels, ircdstate->maxchannelcount)) { + debugprint(DEBUG_CRIT, "Server KICK: Failed to remove nick from channel struct.\n"); + } } // And then send to all clients -- cgit v1.2.3