Changeset 736 in code for trunk/upstream.go


Ignore:
Timestamp:
Dec 2, 2021, 4:33:11 PM (4 years ago)
Author:
contact
Message:

Don't retry connecting on permanent failure

Closes: https://todo.sr.ht/~emersion/soju/164

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upstream.go

    r732 r736  
    4040}
    4141
    42 type registrationError string
     42type registrationError struct {
     43        *irc.Message
     44}
    4345
    4446func (err registrationError) Error() string {
    45         return fmt.Sprintf("registration error: %v", string(err))
     47        return fmt.Sprintf("registration error (%v): %v", err.Command, err.Reason())
     48}
     49
     50func (err registrationError) Reason() string {
     51        if len(err.Params) > 0 {
     52                return err.Params[len(err.Params)-1]
     53        }
     54        return err.Command
     55}
     56
     57func (err registrationError) Temporary() bool {
     58        // Only return false if we're 100% sure that fixing the error requires a
     59        // network configuration change
     60        return err.Command != irc.ERR_PASSWDMISMATCH && err.Command != irc.ERR_ERRONEUSNICKNAME
    4661}
    4762
     
    16521667        case irc.ERR_PASSWDMISMATCH, irc.ERR_ERRONEUSNICKNAME, irc.ERR_NICKNAMEINUSE, irc.ERR_NICKCOLLISION, irc.ERR_UNAVAILRESOURCE, irc.ERR_NOPERMFORHOST, irc.ERR_YOUREBANNEDCREEP:
    16531668                if !uc.registered {
    1654                         text := msg.Params[len(msg.Params)-1]
    1655                         return registrationError(text)
     1669                        return registrationError{msg}
    16561670                }
    16571671                fallthrough
Note: See TracChangeset for help on using the changeset viewer.