From aae0fb9f22b643166f68afa008904a46ca98c4a2 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 7 Dec 2021 09:40:02 +0100 Subject: [PATCH] Improve error message when downstream doesn't authenticate --- downstream.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/downstream.go b/downstream.go index 5a219c6..3f7d8cd 100644 --- a/downstream.go +++ b/downstream.go @@ -1236,11 +1236,25 @@ func (dc *downstreamConn) register(ctx context.Context) error { password := dc.password dc.password = "" if dc.user == nil { + if password == "" { + if dc.caps["sasl"] { + return ircError{&irc.Message{ + Command: "FAIL", + Params: []string{"*", "ACCOUNT_REQUIRED", "Authentication required"}, + }} + } else { + return ircError{&irc.Message{ + Command: irc.ERR_PASSWDMISMATCH, + Params: []string{dc.nick, "Authentication required"}, + }} + } + } + if err := dc.authenticate(ctx, dc.rawUsername, password); err != nil { dc.logger.Printf("PASS authentication error for user %q: %v", dc.rawUsername, err) return ircError{&irc.Message{ Command: irc.ERR_PASSWDMISMATCH, - Params: []string{"*", authErrorReason(err)}, + Params: []string{dc.nick, authErrorReason(err)}, }} } }