From 2b3782a507f669501aaaa0965a7da994f3373d27 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 10 Jun 2021 11:24:10 +0200 Subject: [PATCH] Make user MODE commands fail in multi-upstream mode References: https://todo.sr.ht/~emersion/soju/20 --- downstream.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/downstream.go b/downstream.go index 09dc4f5..7d4ab5b 100644 --- a/downstream.go +++ b/downstream.go @@ -1601,12 +1601,18 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error { if casemapASCII(name) == dc.nickCM { if modeStr != "" { - dc.forEachUpstream(func(uc *upstreamConn) { + if uc := dc.upstream(); uc != nil { uc.SendMessageLabeled(dc.id, &irc.Message{ Command: "MODE", Params: []string{uc.nick, modeStr}, }) - }) + } else { + dc.SendMessage(&irc.Message{ + Prefix: dc.srv.prefix(), + Command: irc.ERR_UMODEUNKNOWNFLAG, + Params: []string{dc.nick, "Cannot change user mode in multi-upstream mode"}, + }) + } } else { var userMode string if uc := dc.upstream(); uc != nil {