- Timestamp:
- Dec 2, 2021, 4:33:11 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/upstream.go
r732 r736 40 40 } 41 41 42 type registrationError string 42 type registrationError struct { 43 *irc.Message 44 } 43 45 44 46 func (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 50 func (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 57 func (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 46 61 } 47 62 … … 1652 1667 case irc.ERR_PASSWDMISMATCH, irc.ERR_ERRONEUSNICKNAME, irc.ERR_NICKNAMEINUSE, irc.ERR_NICKCOLLISION, irc.ERR_UNAVAILRESOURCE, irc.ERR_NOPERMFORHOST, irc.ERR_YOUREBANNEDCREEP: 1653 1668 if !uc.registered { 1654 text := msg.Params[len(msg.Params)-1] 1655 return registrationError(text) 1669 return registrationError{msg} 1656 1670 } 1657 1671 fallthrough -
trunk/user.go
r735 r736 222 222 if err := uc.runUntilRegistered(); err != nil { 223 223 text := err.Error() 224 temp := true 224 225 if regErr, ok := err.(registrationError); ok { 225 text = string(regErr) 226 text = regErr.Reason() 227 temp = regErr.Temporary() 226 228 } 227 229 uc.logger.Printf("failed to register: %v", text) … … 230 232 net.user.srv.metrics.upstreams.Add(-1) 231 233 net.user.srv.metrics.upstreamConnectErrorsTotal.Inc() 234 if !temp { 235 return 236 } 232 237 continue 233 238 }
Note:
See TracChangeset
for help on using the changeset viewer.