From bad8154da8227087d2211c823d462d8d844706d6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 8 Dec 2021 18:23:46 +0100 Subject: [PATCH] Don't forward duplicate JOIN commands Closes: https://todo.sr.ht/~emersion/soju/171 --- downstream.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/downstream.go b/downstream.go index 5bbfcb7..ca60b06 100644 --- a/downstream.go +++ b/downstream.go @@ -1771,14 +1771,20 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc. continue } - params := []string{upstreamName} - if key != "" { - params = append(params, key) + // Most servers ignore duplicate JOIN messages. We ignore them here + // because some clients automatically send JOIN messages in bulk + // when reconnecting to the bouncer. We don't want to flood the + // upstream connection with these. + if !uc.channels.Has(upstreamName) { + params := []string{upstreamName} + if key != "" { + params = append(params, key) + } + uc.SendMessageLabeled(ctx, dc.id, &irc.Message{ + Command: "JOIN", + Params: params, + }) } - uc.SendMessageLabeled(ctx, dc.id, &irc.Message{ - Command: "JOIN", - Params: params, - }) ch := uc.network.channels.Value(upstreamName) if ch != nil {