From d9468b983f0349e79ff13d79bfe3794449e0f706 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 21 Mar 2022 14:45:14 +0100 Subject: [PATCH] downstream: move multi-upstream name handling to loadNetwork --- downstream.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/downstream.go b/downstream.go index 34aa898..ec0bbfc 100644 --- a/downstream.go +++ b/downstream.go @@ -1311,6 +1311,18 @@ func (dc *downstreamConn) register(ctx context.Context) error { } func (dc *downstreamConn) loadNetwork(ctx context.Context) error { + if dc.networkName == "*" { + if !dc.srv.Config().MultiUpstream { + return ircError{&irc.Message{ + Command: irc.ERR_PASSWDMISMATCH, + Params: []string{dc.nick, fmt.Sprintf("Multi-upstream mode is disabled on this server")}, + }} + } + dc.networkName = "" + dc.isMultiUpstream = true + return nil + } + if dc.networkName == "" { return nil } @@ -1372,17 +1384,6 @@ func (dc *downstreamConn) welcome(ctx context.Context) error { remoteAddr := dc.conn.RemoteAddr().String() dc.logger = &prefixLogger{dc.srv.Logger, fmt.Sprintf("user %q: downstream %q: ", dc.user.Username, remoteAddr)} - if dc.networkName == "*" { - if !dc.srv.Config().MultiUpstream { - return ircError{&irc.Message{ - Command: irc.ERR_PASSWDMISMATCH, - Params: []string{dc.nick, fmt.Sprintf("Multi-upstream mode is disabled on this server")}, - }} - } - dc.networkName = "" - dc.isMultiUpstream = true - } - // TODO: doing this might take some time. We should do it in dc.register // instead, but we'll potentially be adding a new network and this must be // done in the user goroutine.