2018-02-03 13:03:36 +01:00
|
|
|
// Copyright (c) 2012-2014 Jeremy Latt
|
|
|
|
// Copyright (c) 2014-2015 Edmund Huber
|
|
|
|
// Copyright (c) 2016-2017 Daniel Oaks <daniel@danieloaks.net>
|
|
|
|
// released under the MIT license
|
|
|
|
|
|
|
|
package irc
|
|
|
|
|
2019-05-20 08:56:49 +02:00
|
|
|
import (
|
|
|
|
"errors"
|
2020-05-06 11:53:45 +02:00
|
|
|
"fmt"
|
2020-06-12 21:51:48 +02:00
|
|
|
"time"
|
2020-05-06 11:53:45 +02:00
|
|
|
|
2019-05-20 08:56:49 +02:00
|
|
|
"github.com/oragono/oragono/irc/utils"
|
|
|
|
)
|
2018-02-03 13:03:36 +01:00
|
|
|
|
|
|
|
// Runtime Errors
|
|
|
|
var (
|
2019-02-06 01:03:42 +01:00
|
|
|
errAccountAlreadyRegistered = errors.New(`Account already exists`)
|
2020-03-20 17:34:46 +01:00
|
|
|
errAccountAlreadyUnregistered = errors.New(`That account name was registered previously and can't be reused`)
|
2019-02-06 01:03:42 +01:00
|
|
|
errAccountAlreadyVerified = errors.New(`Account is already verified`)
|
2018-04-01 09:12:41 +02:00
|
|
|
errAccountCantDropPrimaryNick = errors.New("Can't unreserve primary nickname")
|
2018-02-20 10:20:30 +01:00
|
|
|
errAccountCreation = errors.New("Account could not be created")
|
|
|
|
errAccountDoesNotExist = errors.New("Account does not exist")
|
2018-04-01 09:12:41 +02:00
|
|
|
errAccountInvalidCredentials = errors.New("Invalid account credentials")
|
2019-02-06 01:03:42 +01:00
|
|
|
errAccountBadPassphrase = errors.New(`Passphrase contains forbidden characters or is otherwise invalid`)
|
2018-04-01 09:12:41 +02:00
|
|
|
errAccountNickReservationFailed = errors.New("Could not (un)reserve nick")
|
2018-03-02 23:04:24 +01:00
|
|
|
errAccountNotLoggedIn = errors.New("You're not logged into an account")
|
2020-03-27 22:52:37 +01:00
|
|
|
errAccountAlreadyLoggedIn = errors.New("You're already logged into an account")
|
2018-04-01 09:12:41 +02:00
|
|
|
errAccountTooManyNicks = errors.New("Account has too many reserved nicks")
|
2019-05-19 10:27:44 +02:00
|
|
|
errAccountUnverified = errors.New(`Account is not yet verified`)
|
2018-02-20 10:20:30 +01:00
|
|
|
errAccountVerificationFailed = errors.New("Account verification failed")
|
|
|
|
errAccountVerificationInvalidCode = errors.New("Invalid account verification code")
|
2019-05-19 10:27:44 +02:00
|
|
|
errAccountUpdateFailed = errors.New(`Error while updating your account information`)
|
2019-02-06 01:03:42 +01:00
|
|
|
errAccountMustHoldNick = errors.New(`You must hold that nickname in order to register it`)
|
2019-12-25 21:06:26 +01:00
|
|
|
errAuthzidAuthcidMismatch = errors.New(`authcid and authzid must be the same`)
|
2018-02-20 10:20:30 +01:00
|
|
|
errCallbackFailed = errors.New("Account verification could not be sent")
|
2019-02-06 01:03:42 +01:00
|
|
|
errCertfpAlreadyExists = errors.New(`An account already exists for your certificate fingerprint`)
|
2019-03-12 00:24:45 +01:00
|
|
|
errChannelNotOwnedByAccount = errors.New("Channel not owned by the specified account")
|
2019-12-17 01:50:15 +01:00
|
|
|
errChannelTransferNotOffered = errors.New(`You weren't offered ownership of that channel`)
|
2018-02-20 10:20:30 +01:00
|
|
|
errChannelAlreadyRegistered = errors.New("Channel is already registered")
|
2020-02-19 01:38:42 +01:00
|
|
|
errChannelNotRegistered = errors.New("Channel is not registered")
|
2019-03-11 12:03:51 +01:00
|
|
|
errChannelNameInUse = errors.New(`Channel name in use`)
|
|
|
|
errInvalidChannelName = errors.New(`Invalid channel name`)
|
2018-02-20 10:20:30 +01:00
|
|
|
errMonitorLimitExceeded = errors.New("Monitor limit exceeded")
|
|
|
|
errNickMissing = errors.New("nick missing")
|
2019-05-24 19:09:56 +02:00
|
|
|
errNicknameInvalid = errors.New("invalid nickname")
|
2018-02-20 10:20:30 +01:00
|
|
|
errNicknameInUse = errors.New("nickname in use")
|
2020-04-23 07:38:12 +02:00
|
|
|
errInsecureReattach = errors.New("insecure reattach")
|
2018-02-20 10:20:30 +01:00
|
|
|
errNicknameReserved = errors.New("nickname is reserved")
|
2020-03-17 04:37:52 +01:00
|
|
|
errNickAccountMismatch = errors.New(`Your nickname must match your account name; try logging out and logging back in with SASL`)
|
2018-02-20 10:20:30 +01:00
|
|
|
errNoExistingBan = errors.New("Ban does not exist")
|
2019-03-11 12:03:51 +01:00
|
|
|
errNoSuchChannel = errors.New(`No such channel`)
|
2019-12-17 19:21:26 +01:00
|
|
|
errChannelPurged = errors.New(`This channel was purged by the server operators and cannot be used`)
|
|
|
|
errConfusableIdentifier = errors.New("This identifier is confusable with one already in use")
|
2018-05-25 06:38:20 +02:00
|
|
|
errInsufficientPrivs = errors.New("Insufficient privileges")
|
2018-11-26 11:23:27 +01:00
|
|
|
errInvalidUsername = errors.New("Invalid username")
|
2019-02-15 01:51:55 +01:00
|
|
|
errFeatureDisabled = errors.New(`That feature is disabled`)
|
2019-05-13 07:54:50 +02:00
|
|
|
errBanned = errors.New("IP or nickmask banned")
|
2019-05-20 08:56:49 +02:00
|
|
|
errInvalidParams = utils.ErrInvalidParams
|
2019-05-22 05:55:04 +02:00
|
|
|
errNoVhost = errors.New(`You do not have an approved vhost`)
|
2019-12-29 17:59:49 +01:00
|
|
|
errLimitExceeded = errors.New("Limit exceeded")
|
|
|
|
errNoop = errors.New("Action was a no-op")
|
|
|
|
errCASFailed = errors.New("Compare-and-swap update of database value failed")
|
|
|
|
errEmptyCredentials = errors.New("No more credentials are approved")
|
2020-02-11 12:35:17 +01:00
|
|
|
errCredsExternallyManaged = errors.New("Credentials are externally managed and cannot be changed here")
|
2020-03-27 15:40:19 +01:00
|
|
|
errInvalidMultilineBatch = errors.New("Invalid multiline batch")
|
2020-06-04 07:18:24 +02:00
|
|
|
errTimedOut = errors.New("Operation timed out")
|
2020-06-22 20:54:43 +02:00
|
|
|
errInvalidUtf8 = errors.New("Message rejected for invalid utf8")
|
2020-07-01 01:24:56 +02:00
|
|
|
errClientDestroyed = errors.New("Client was already destroyed")
|
|
|
|
errTooManyChannels = errors.New("You have joined too many channels")
|
|
|
|
errWrongChannelKey = errors.New("Cannot join password-protected channel without the password")
|
|
|
|
errInviteOnly = errors.New("Cannot join invite-only channel without an invite")
|
|
|
|
errRegisteredOnly = errors.New("Cannot join registered-only channel without an account")
|
2018-02-03 13:03:36 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// Socket Errors
|
|
|
|
var (
|
|
|
|
errNoPeerCerts = errors.New("Client did not provide a certificate")
|
|
|
|
errNotTLS = errors.New("Not a TLS connection")
|
2018-03-18 02:32:12 +01:00
|
|
|
errReadQ = errors.New("ReadQ Exceeded")
|
2018-02-03 13:03:36 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// String Errors
|
|
|
|
var (
|
|
|
|
errCouldNotStabilize = errors.New("Could not stabilize string while casefolding")
|
|
|
|
errStringIsEmpty = errors.New("String is empty")
|
|
|
|
errInvalidCharacter = errors.New("Invalid character")
|
|
|
|
)
|
|
|
|
|
2020-05-06 11:53:45 +02:00
|
|
|
type CertKeyError struct {
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ck *CertKeyError) Error() string {
|
|
|
|
return fmt.Sprintf("Invalid TLS cert/key pair: %v", ck.Err)
|
|
|
|
}
|
|
|
|
|
2020-06-12 21:51:48 +02:00
|
|
|
type ThrottleError struct {
|
|
|
|
time.Duration
|
|
|
|
}
|
|
|
|
|
|
|
|
func (te *ThrottleError) Error() string {
|
|
|
|
return fmt.Sprintf(`Please wait at least %v and try again`, te.Duration)
|
|
|
|
}
|
|
|
|
|
2018-02-03 13:03:36 +01:00
|
|
|
// Config Errors
|
|
|
|
var (
|
|
|
|
ErrDatastorePathMissing = errors.New("Datastore path missing")
|
|
|
|
ErrLimitsAreInsane = errors.New("Limits aren't setup properly, check them and make them sane")
|
|
|
|
ErrLoggerExcludeEmpty = errors.New("Encountered logging type '-' with no type to exclude")
|
|
|
|
ErrLoggerFilenameMissing = errors.New("Logging configuration specifies 'file' method but 'filename' is empty")
|
|
|
|
ErrLoggerHasNoTypes = errors.New("Logger has no types to log")
|
|
|
|
ErrNetworkNameMissing = errors.New("Network name missing")
|
|
|
|
ErrNoFingerprintOrPassword = errors.New("Fingerprint or password needs to be specified")
|
|
|
|
ErrNoListenersDefined = errors.New("Server listening addresses missing")
|
|
|
|
ErrOperClassDependencies = errors.New("OperClasses contains a looping dependency, or a class extends from a class that doesn't exist")
|
|
|
|
ErrServerNameMissing = errors.New("Server name missing")
|
|
|
|
ErrServerNameNotHostname = errors.New("Server name must match the format of a hostname")
|
|
|
|
)
|