From 1620344f0a853bc8c959ae8ad526e2ddafbf7818 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 2 Dec 2021 17:58:56 +0100 Subject: [PATCH] Mark ACCOUNT_REQUIRED error as permanent connection failure There's no point in retrying to connect in this case. --- upstream.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/upstream.go b/upstream.go index 8548f9d..db42827 100644 --- a/upstream.go +++ b/upstream.go @@ -57,7 +57,14 @@ func (err registrationError) Reason() string { func (err registrationError) Temporary() bool { // Only return false if we're 100% sure that fixing the error requires a // network configuration change - return err.Command != irc.ERR_PASSWDMISMATCH && err.Command != irc.ERR_ERRONEUSNICKNAME + switch err.Command { + case irc.ERR_PASSWDMISMATCH, irc.ERR_ERRONEUSNICKNAME: + return false + case "FAIL": + return err.Params[1] != "ACCOUNT_REQUIRED" + default: + return true + } } type upstreamChannel struct { @@ -1618,11 +1625,15 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error { }) }) case "FAIL": - var command string - if err := parseMessageParams(msg, &command); err != nil { + var command, code string + if err := parseMessageParams(msg, &command, &code); err != nil { return err } + if !uc.registered && command == "*" && code == "ACCOUNT_REQUIRED" { + return registrationError{msg} + } + if dc, _ := uc.dequeueCommand(command); dc != nil && downstreamID == 0 { downstreamID = dc.id }