Mark ACCOUNT_REQUIRED error as permanent connection failure

There's no point in retrying to connect in this case.
This commit is contained in:
Simon Ser 2021-12-02 17:58:56 +01:00
parent fd9a935f3e
commit 1620344f0a

View File

@ -57,7 +57,14 @@ func (err registrationError) Reason() string {
func (err registrationError) Temporary() bool { func (err registrationError) Temporary() bool {
// Only return false if we're 100% sure that fixing the error requires a // Only return false if we're 100% sure that fixing the error requires a
// network configuration change // 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 { type upstreamChannel struct {
@ -1618,11 +1625,15 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
}) })
}) })
case "FAIL": case "FAIL":
var command string var command, code string
if err := parseMessageParams(msg, &command); err != nil { if err := parseMessageParams(msg, &command, &code); err != nil {
return err return err
} }
if !uc.registered && command == "*" && code == "ACCOUNT_REQUIRED" {
return registrationError{msg}
}
if dc, _ := uc.dequeueCommand(command); dc != nil && downstreamID == 0 { if dc, _ := uc.dequeueCommand(command); dc != nil && downstreamID == 0 {
downstreamID = dc.id downstreamID = dc.id
} }