From 16c68b21b515069e5c7760bdfd9fbbfa14ef555f Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Mon, 23 Nov 2020 17:09:31 +0100 Subject: [PATCH] Prevent downstreams from changing their nick to service's This commit prevents downstream from sending those commands: - NICK BouncerServ - NICK BouncerServ/ The later is necessary because soju would otherwise save the nick change and, in the event that the downstream connects in single-upstream mode to , it will end up with the nickname "BouncerServ". --- downstream.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/downstream.go b/downstream.go index 2515ae2..d861f87 100644 --- a/downstream.go +++ b/downstream.go @@ -1068,11 +1068,12 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error { Params: []string{dc.nick, "You may not reregister"}, }} case "NICK": - var nick string - if err := parseMessageParams(msg, &nick); err != nil { + var rawNick string + if err := parseMessageParams(msg, &rawNick); err != nil { return err } + nick := rawNick var upstream *upstreamConn if dc.upstream() == nil { uc, unmarshaledNick, err := dc.unmarshalEntity(nick) @@ -1088,6 +1089,12 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error { Params: []string{dc.nick, nick, "contains illegal characters"}, }} } + if nick == serviceNick { + return ircError{&irc.Message{ + Command: irc.ERR_NICKNAMEINUSE, + Params: []string{dc.nick, rawNick, "Nickname reserved for bouncer service"}, + }} + } var err error dc.forEachNetwork(func(n *network) {