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.
This commit is contained in:
Simon Ser 2021-12-04 19:29:39 +01:00
parent b2957c05d5
commit f2a28f6e22
2 changed files with 7 additions and 0 deletions

View File

@ -2473,6 +2473,9 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
if uc == nil { if uc == nil {
return newUnknownCommandError(msg.Command) return newUnknownCommandError(msg.Command)
} }
if _, ok := uc.isupport["MONITOR"]; !ok {
return newUnknownCommandError(msg.Command)
}
var subcommand string var subcommand string
if err := parseMessageParams(msg, &subcommand); err != nil { if err := parseMessageParams(msg, &subcommand); err != nil {

View File

@ -2075,6 +2075,10 @@ func (uc *upstreamConn) updateChannelAutoDetach(name string) {
} }
func (uc *upstreamConn) updateMonitor() { func (uc *upstreamConn) updateMonitor() {
if _, ok := uc.isupport["MONITOR"]; !ok {
return
}
add := make(map[string]struct{}) add := make(map[string]struct{})
var addList []string var addList []string
seen := make(map[string]struct{}) seen := make(map[string]struct{})