From f2a28f6e22bd41f1543fa89e175fc09ea863fee5 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 4 Dec 2021 19:29:39 +0100 Subject: [PATCH] Avoid forwarding MONITOR requests if upstream doesn't support it Clients aren't supposed to do this, but in case they do, let's send them an error. --- downstream.go | 3 +++ upstream.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/downstream.go b/downstream.go index 7d0e5c8..be2faf8 100644 --- a/downstream.go +++ b/downstream.go @@ -2473,6 +2473,9 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc. if uc == nil { return newUnknownCommandError(msg.Command) } + if _, ok := uc.isupport["MONITOR"]; !ok { + return newUnknownCommandError(msg.Command) + } var subcommand string if err := parseMessageParams(msg, &subcommand); err != nil { diff --git a/upstream.go b/upstream.go index 218cd4d..c4d50e0 100644 --- a/upstream.go +++ b/upstream.go @@ -2075,6 +2075,10 @@ func (uc *upstreamConn) updateChannelAutoDetach(name string) { } func (uc *upstreamConn) updateMonitor() { + if _, ok := uc.isupport["MONITOR"]; !ok { + return + } + add := make(map[string]struct{}) var addList []string seen := make(map[string]struct{})