irc

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2019 License: MIT Imports: 58 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IncludeInitial uint = 1 << iota
	IncludeTopic
	IncludeModes
	IncludeLists
)

these are bit flags indicating what part of the channel status is "dirty" and needs to be read from memory and written to the db

View Source
const (
	// IdentTimeoutSeconds is how many seconds before our ident (username) check times out.
	IdentTimeoutSeconds  = 1.5
	IRCv3TimestampFormat = "2006-01-02T15:04:05.000Z"
)
View Source
const (
	// RegisterTimeout is how long clients have to register before we disconnect them
	RegisterTimeout = time.Minute
	// DefaultIdleTimeout is how long without traffic before we send the client a PING
	DefaultIdleTimeout = time.Minute + 30*time.Second
	// For Tor clients, we send a PING at least every 30 seconds, as a workaround for this bug
	// (single-onion circuits will close unless the client sends data once every 60 seconds):
	// https://bugs.torproject.org/29665
	TorIdleTimeout = time.Second * 30
	// This is how long a client gets without sending any message, including the PONG to our
	// PING, before we disconnect them:
	DefaultTotalTimeout = 2*time.Minute + 30*time.Second
	// Resumeable clients (clients who have negotiated caps.Resume) get longer:
	ResumeableTotalTimeout = 3*time.Minute + 30*time.Second
)
View Source
const (
	RPL_WELCOME                   = "001"
	RPL_YOURHOST                  = "002"
	RPL_CREATED                   = "003"
	RPL_MYINFO                    = "004"
	RPL_ISUPPORT                  = "005"
	RPL_SNOMASKIS                 = "008"
	RPL_BOUNCE                    = "010"
	RPL_TRACELINK                 = "200"
	RPL_TRACECONNECTING           = "201"
	RPL_TRACEHANDSHAKE            = "202"
	RPL_TRACEUNKNOWN              = "203"
	RPL_TRACEOPERATOR             = "204"
	RPL_TRACEUSER                 = "205"
	RPL_TRACESERVER               = "206"
	RPL_TRACESERVICE              = "207"
	RPL_TRACENEWTYPE              = "208"
	RPL_TRACECLASS                = "209"
	RPL_TRACERECONNECT            = "210"
	RPL_STATSLINKINFO             = "211"
	RPL_STATSCOMMANDS             = "212"
	RPL_ENDOFSTATS                = "219"
	RPL_UMODEIS                   = "221"
	RPL_SERVLIST                  = "234"
	RPL_SERVLISTEND               = "235"
	RPL_STATSUPTIME               = "242"
	RPL_STATSOLINE                = "243"
	RPL_LUSERCLIENT               = "251"
	RPL_LUSEROP                   = "252"
	RPL_LUSERUNKNOWN              = "253"
	RPL_LUSERCHANNELS             = "254"
	RPL_LUSERME                   = "255"
	RPL_ADMINME                   = "256"
	RPL_ADMINLOC1                 = "257"
	RPL_ADMINLOC2                 = "258"
	RPL_ADMINEMAIL                = "259"
	RPL_TRACELOG                  = "261"
	RPL_TRACEEND                  = "262"
	RPL_TRYAGAIN                  = "263"
	RPL_WHOISCERTFP               = "276"
	RPL_AWAY                      = "301"
	RPL_USERHOST                  = "302"
	RPL_ISON                      = "303"
	RPL_UNAWAY                    = "305"
	RPL_NOWAWAY                   = "306"
	RPL_WHOISUSER                 = "311"
	RPL_WHOISSERVER               = "312"
	RPL_WHOISOPERATOR             = "313"
	RPL_WHOWASUSER                = "314"
	RPL_ENDOFWHO                  = "315"
	RPL_WHOISIDLE                 = "317"
	RPL_ENDOFWHOIS                = "318"
	RPL_WHOISCHANNELS             = "319"
	RPL_LIST                      = "322"
	RPL_LISTEND                   = "323"
	RPL_CHANNELMODEIS             = "324"
	RPL_UNIQOPIS                  = "325"
	RPL_CHANNELCREATED            = "329"
	RPL_WHOISACCOUNT              = "330"
	RPL_NOTOPIC                   = "331"
	RPL_TOPIC                     = "332"
	RPL_TOPICTIME                 = "333"
	RPL_WHOISBOT                  = "335"
	RPL_WHOISACTUALLY             = "338"
	RPL_INVITING                  = "341"
	RPL_SUMMONING                 = "342"
	RPL_INVITELIST                = "346"
	RPL_ENDOFINVITELIST           = "347"
	RPL_EXCEPTLIST                = "348"
	RPL_ENDOFEXCEPTLIST           = "349"
	RPL_VERSION                   = "351"
	RPL_WHOREPLY                  = "352"
	RPL_NAMREPLY                  = "353"
	RPL_LINKS                     = "364"
	RPL_ENDOFLINKS                = "365"
	RPL_ENDOFNAMES                = "366"
	RPL_BANLIST                   = "367"
	RPL_ENDOFBANLIST              = "368"
	RPL_ENDOFWHOWAS               = "369"
	RPL_INFO                      = "371"
	RPL_MOTD                      = "372"
	RPL_ENDOFINFO                 = "374"
	RPL_MOTDSTART                 = "375"
	RPL_ENDOFMOTD                 = "376"
	RPL_YOUREOPER                 = "381"
	RPL_REHASHING                 = "382"
	RPL_YOURESERVICE              = "383"
	RPL_TIME                      = "391"
	RPL_USERSSTART                = "392"
	RPL_USERS                     = "393"
	RPL_ENDOFUSERS                = "394"
	RPL_NOUSERS                   = "395"
	ERR_UNKNOWNERROR              = "400"
	ERR_NOSUCHNICK                = "401"
	ERR_NOSUCHSERVER              = "402"
	ERR_NOSUCHCHANNEL             = "403"
	ERR_CANNOTSENDTOCHAN          = "404"
	ERR_TOOMANYCHANNELS           = "405"
	ERR_WASNOSUCHNICK             = "406"
	ERR_TOOMANYTARGETS            = "407"
	ERR_NOSUCHSERVICE             = "408"
	ERR_NOORIGIN                  = "409"
	ERR_INVALIDCAPCMD             = "410"
	ERR_NORECIPIENT               = "411"
	ERR_NOTEXTTOSEND              = "412"
	ERR_NOTOPLEVEL                = "413"
	ERR_WILDTOPLEVEL              = "414"
	ERR_BADMASK                   = "415"
	ERR_INPUTTOOLONG              = "417"
	ERR_UNKNOWNCOMMAND            = "421"
	ERR_NOMOTD                    = "422"
	ERR_NOADMININFO               = "423"
	ERR_FILEERROR                 = "424"
	ERR_NONICKNAMEGIVEN           = "431"
	ERR_ERRONEUSNICKNAME          = "432"
	ERR_NICKNAMEINUSE             = "433"
	ERR_NICKCOLLISION             = "436"
	ERR_UNAVAILRESOURCE           = "437"
	ERR_REG_UNAVAILABLE           = "440"
	ERR_USERNOTINCHANNEL          = "441"
	ERR_NOTONCHANNEL              = "442"
	ERR_USERONCHANNEL             = "443"
	ERR_NOLOGIN                   = "444"
	ERR_SUMMONDISABLED            = "445"
	ERR_USERSDISABLED             = "446"
	ERR_NOTREGISTERED             = "451"
	ERR_NEEDMOREPARAMS            = "461"
	ERR_ALREADYREGISTRED          = "462"
	ERR_NOPERMFORHOST             = "463"
	ERR_PASSWDMISMATCH            = "464"
	ERR_YOUREBANNEDCREEP          = "465"
	ERR_YOUWILLBEBANNED           = "466"
	ERR_KEYSET                    = "467"
	ERR_INVALIDUSERNAME           = "468"
	ERR_CHANNELISFULL             = "471"
	ERR_UNKNOWNMODE               = "472"
	ERR_INVITEONLYCHAN            = "473"
	ERR_BANNEDFROMCHAN            = "474"
	ERR_BADCHANNELKEY             = "475"
	ERR_BADCHANMASK               = "476"
	ERR_NOCHANMODES               = "477"
	ERR_BANLISTFULL               = "478"
	ERR_NOPRIVILEGES              = "481"
	ERR_CHANOPRIVSNEEDED          = "482"
	ERR_CANTKILLSERVER            = "483"
	ERR_RESTRICTED                = "484"
	ERR_UNIQOPPRIVSNEEDED         = "485"
	ERR_NOOPERHOST                = "491"
	ERR_UMODEUNKNOWNFLAG          = "501"
	ERR_USERSDONTMATCH            = "502"
	ERR_HELPNOTFOUND              = "524"
	ERR_CANNOTSENDRP              = "573"
	RPL_WHOISSECURE               = "671"
	RPL_YOURLANGUAGESARE          = "687"
	ERR_CHANNAMEINUSE             = "692"
	ERR_CANNOTRENAME              = "693"
	RPL_HELPSTART                 = "704"
	RPL_HELPTXT                   = "705"
	RPL_ENDOFHELP                 = "706"
	ERR_NOPRIVS                   = "723"
	RPL_MONONLINE                 = "730"
	RPL_MONOFFLINE                = "731"
	RPL_MONLIST                   = "732"
	RPL_ENDOFMONLIST              = "733"
	ERR_MONLISTFULL               = "734"
	RPL_LOGGEDIN                  = "900"
	RPL_LOGGEDOUT                 = "901"
	ERR_NICKLOCKED                = "902"
	RPL_SASLSUCCESS               = "903"
	ERR_SASLFAIL                  = "904"
	ERR_SASLTOOLONG               = "905"
	ERR_SASLABORTED               = "906"
	ERR_SASLALREADY               = "907"
	RPL_SASLMECHS                 = "908"
	RPL_REG_SUCCESS               = "920"
	RPL_VERIFY_SUCCESS            = "923"
	RPL_REG_VERIFICATION_REQUIRED = "927"
	ERR_TOOMANYLANGUAGES          = "981"
	ERR_NOLANGUAGE                = "982"

	ERR_CANNOT_RESUME = "300"
)
View Source
const (
	IncludeAllChannelAttrs = ^uint(0)
)

this is an OR of all possible flags

View Source
const (
	// this is a tradeoff between exploiting CPU-level parallelism (higher values better)
	// and not thrashing the allocator (lower values better). really this is all just
	// guesswork. oragono *can* make use of cores beyond this limit --- just not for
	// the protected operations.
	MaxServerSemaphoreCapacity = 32
)
View Source
const (
	// SemVer is the semantic version of Oragono.
	SemVer = "1.1.1"
)

Variables

View Source
var (
	// Commit is the current git commit.
	Commit = ""

	// Ver is the full version of Oragono, used in responses to clients.
	Ver = fmt.Sprintf("oragono-%s", SemVer)
)
View Source
var (
	ErrDatastorePathMissing    = errors.New("Datastore path missing")
	ErrInvalidCertKeyPair      = errors.New("tls cert+key: invalid pair")
	ErrLimitsAreInsane         = errors.New("Limits aren't setup properly, check them and make them sane")
	ErrLineLengthsTooSmall     = errors.New("Line lengths must be 512 or greater (check the linelen section under server->limits)")
	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")
)

Config Errors

View Source
var (

	// SupportedCapabilities are the caps we advertise.
	// MaxLine, SASL and STS may be unset during server startup / rehash.
	SupportedCapabilities = caps.NewCompleteSet()

	// CapValues are the actual values we advertise to v3.2 clients.
	// actual values are set during server startup.
	CapValues = caps.NewValues()
)
View Source
var Commands map[string]Command

Commands holds all commands executable by a client connected to us.

View Source
var (
	// DefaultChannelModes are enabled on brand new channels when they're created.
	// this can be overridden in the `channels` config, with the `default-modes` key
	DefaultChannelModes = modes.Modes{
		modes.NoOutside, modes.OpOnlyTopic,
	}
)
View Source
var (
	// EnabledSaslMechanisms contains the SASL mechanisms that exist and that we support.
	// This can be moved to some other data structure/place if we need to load/unload mechs later.
	EnabledSaslMechanisms = map[string]func(*Server, *Client, string, []byte, *ResponseBuffer) bool{
		"PLAIN":    authPlainHandler,
		"EXTERNAL": authExternalHandler,
	}
)
View Source
var Help = map[string]HelpEntry{

	"acc": {
		// contains filtered or unexported fields
	},
	"ambiance": {
		// contains filtered or unexported fields
	},
	"authenticate": {
		// contains filtered or unexported fields
	},
	"away": {
		// contains filtered or unexported fields
	},
	"brb": {
		// contains filtered or unexported fields
	},
	"cap": {
		// contains filtered or unexported fields
	},
	"chanserv": {
		// contains filtered or unexported fields
	},
	"chathistory": {
		// contains filtered or unexported fields
	},
	"cs": {
		// contains filtered or unexported fields
	},
	"debug": {
		// contains filtered or unexported fields
	},
	"dline": {
		// contains filtered or unexported fields
	},
	"help": {
		// contains filtered or unexported fields
	},
	"helpop": {
		// contains filtered or unexported fields
	},
	"history": {
		// contains filtered or unexported fields
	},
	"hostserv": {
		// contains filtered or unexported fields
	},
	"hs": {
		// contains filtered or unexported fields
	},
	"info": {
		// contains filtered or unexported fields
	},
	"invite": {
		// contains filtered or unexported fields
	},
	"ison": {
		// contains filtered or unexported fields
	},
	"join": {
		// contains filtered or unexported fields
	},
	"kick": {
		// contains filtered or unexported fields
	},
	"kill": {
		// contains filtered or unexported fields
	},
	"kline": {
		// contains filtered or unexported fields
	},
	"language": {
		// contains filtered or unexported fields
	},
	"list": {
		// contains filtered or unexported fields
	},
	"lusers": {
		// contains filtered or unexported fields
	},
	"mode": {
		// contains filtered or unexported fields
	},
	"monitor": {
		// contains filtered or unexported fields
	},
	"motd": {
		// contains filtered or unexported fields
	},
	"names": {
		// contains filtered or unexported fields
	},
	"nick": {
		// contains filtered or unexported fields
	},
	"nickserv": {
		// contains filtered or unexported fields
	},
	"notice": {
		// contains filtered or unexported fields
	},
	"npc": {
		// contains filtered or unexported fields
	},
	"npca": {
		// contains filtered or unexported fields
	},
	"ns": {
		// contains filtered or unexported fields
	},
	"oper": {
		// contains filtered or unexported fields
	},
	"part": {
		// contains filtered or unexported fields
	},
	"pass": {
		// contains filtered or unexported fields
	},
	"ping": {
		// contains filtered or unexported fields
	},
	"pong": {
		// contains filtered or unexported fields
	},
	"privmsg": {
		// contains filtered or unexported fields
	},
	"rename": {
		// contains filtered or unexported fields
	},
	"sajoin": {
		// contains filtered or unexported fields
	},
	"sanick": {
		// contains filtered or unexported fields
	},
	"samode": {
		// contains filtered or unexported fields
	},
	"scene": {
		// contains filtered or unexported fields
	},
	"setname": {
		// contains filtered or unexported fields
	},
	"tagmsg": {
		// contains filtered or unexported fields
	},
	"quit": {
		// contains filtered or unexported fields
	},
	"rehash": {
		// contains filtered or unexported fields
	},
	"resume": {
		// contains filtered or unexported fields
	},
	"time": {
		// contains filtered or unexported fields
	},
	"topic": {
		// contains filtered or unexported fields
	},
	"undline": {
		// contains filtered or unexported fields
	},
	"unkline": {
		// contains filtered or unexported fields
	},
	"user": {
		// contains filtered or unexported fields
	},
	"userhost": {
		// contains filtered or unexported fields
	},
	"version": {
		// contains filtered or unexported fields
	},
	"webirc": {
		// contains filtered or unexported fields
	},
	"who": {
		// contains filtered or unexported fields
	},
	"whois": {
		// contains filtered or unexported fields
	},
	"whowas": {
		// contains filtered or unexported fields
	},
	"znc": {
		// contains filtered or unexported fields
	},

	"modes": {
		// contains filtered or unexported fields
	},
	"cmode": {
		// contains filtered or unexported fields
	},
	"cmodes": {
		// contains filtered or unexported fields
	},
	"umode": {
		// contains filtered or unexported fields
	},
	"umodes": {
		// contains filtered or unexported fields
	},
	"snomask": {
		// contains filtered or unexported fields
	},
	"snomasks": {
		// contains filtered or unexported fields
	},

	"casemapping": {
		// contains filtered or unexported fields
	},
	"prefix": {
		// contains filtered or unexported fields
	},
}

Help contains the help strings distributed with the IRCd.

View Source
var OragonoServices = map[string]*ircService{
	"nickserv": {
		Name:           "NickServ",
		ShortName:      "NS",
		CommandAliases: []string{"NICKSERV", "NS"},
		Commands:       nickservCommands,
		HelpBanner:     nickservHelp,
	},
	"chanserv": {
		Name:           "ChanServ",
		ShortName:      "CS",
		CommandAliases: []string{"CHANSERV", "CS"},
		Commands:       chanservCommands,
		HelpBanner:     chanservHelp,
	},
	"hostserv": {
		Name:           "HostServ",
		ShortName:      "HS",
		CommandAliases: []string{"HOSTSERV", "HS"},
		Commands:       hostservCommands,
		HelpBanner:     hostservHelp,
	},
}

all services, by lowercase name

View Source
var (
	// ServerExitSignals are the signals the server will exit on.
	ServerExitSignals = []os.Signal{
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT,
	}
)

Functions

func ApplyUserModeChanges added in v0.12.0

func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool) modes.ModeChanges

ApplyUserModeChanges applies the given changes, and returns the applied changes.

func Casefold added in v0.2.0

func Casefold(str string) (string, error)

Casefold returns a casefolded string, without doing any name or channel character checks.

func CasefoldChannel added in v0.2.0

func CasefoldChannel(name string) (string, error)

CasefoldChannel returns a casefolded version of a channel name.

func CasefoldName added in v0.2.0

func CasefoldName(name string) (string, error)

CasefoldName returns a casefolded version of a nick/user name.

func ExpandUserHost

func ExpandUserHost(userhost string) (expanded string)

ExpandUserHost takes a userhost, and returns an expanded version.

func GenerateHelpIndex added in v0.8.0

func GenerateHelpIndex(lm *languages.Manager, forOpers bool) map[string]string

GenerateHelpIndex is used to generate HelpIndex. Returns: a map from language code to the help index in that language.

func GetLabel added in v0.11.0

func GetLabel(msg ircmsg.IrcMessage) string

GetLabel returns the label from the given message.

func IncompatibleSchemaError added in v0.12.0

func IncompatibleSchemaError(currentVersion string) (result *incompatibleSchemaError)

func InitDB

func InitDB(path string)

InitDB creates the database, implementing the `oragono initdb` command.

func OpenDatabase added in v0.10.0

func OpenDatabase(config *Config) (*buntdb.DB, error)

OpenDatabase returns an existing database, performing a schema version check.

func ParseDefaultChannelModes added in v0.9.0

func ParseDefaultChannelModes(rawModes *string) modes.Modes

ParseDefaultChannelModes parses the `default-modes` line of the config

func Skeleton added in v1.0.0

func Skeleton(name string) (string, error)

Skeleton produces a canonicalized identifier that tries to catch homoglyphic / confusable identifiers. It's a tweaked version of the TR39 skeleton algorithm. We apply the skeleton algorithm first and only then casefold, because casefolding first would lose some information about visual confusability. This has the weird consequence that the skeleton is not a function of the casefolded identifier --- therefore it must always be computed from the original (unfolded) identifier and stored/tracked separately from the casefolded identifier.

func UpgradeDB

func UpgradeDB(config *Config) (err error)

UpgradeDB upgrades the datastore to the latest schema.

Types

type AccountConfig added in v0.11.0

type AccountConfig struct {
	Registration          AccountRegistrationConfig
	AuthenticationEnabled bool `yaml:"authentication-enabled"`
	RequireSasl           struct {
		Enabled  bool
		Exempted []string
		// contains filtered or unexported fields
	} `yaml:"require-sasl"`
	LoginThrottling struct {
		Enabled     bool
		Duration    time.Duration
		MaxAttempts int `yaml:"max-attempts"`
	} `yaml:"login-throttling"`
	SkipServerPassword bool                  `yaml:"skip-server-password"`
	NickReservation    NickReservationConfig `yaml:"nick-reservation"`
	Bouncer            struct {
		Enabled          bool
		AllowedByDefault bool `yaml:"allowed-by-default"`
	}
	VHosts VHostConfig
}

type AccountCredentials

type AccountCredentials struct {
	Version        uint
	PassphraseSalt []byte // legacy field, not used by v1 and later
	PassphraseHash []byte
	Certificate    string // fingerprint
}

AccountCredentials stores the various methods for verifying accounts.

type AccountManager added in v0.11.0

type AccountManager struct {
	sync.RWMutex // tier 2
	// contains filtered or unexported fields
}

everything about accounts is persistent; therefore, the database is the authoritative source of truth for all account information. anything on the heap is just a cache

func (*AccountManager) AccountToClients added in v0.12.0

func (am *AccountManager) AccountToClients(account string) (result []*Client)

func (*AccountManager) AuthenticateByCertFP added in v0.11.0

func (am *AccountManager) AuthenticateByCertFP(client *Client) error

func (*AccountManager) AuthenticateByPassphrase added in v0.11.0

func (am *AccountManager) AuthenticateByPassphrase(client *Client, accountName string, passphrase string) error

func (*AccountManager) ChannelsForAccount added in v1.0.0

func (am *AccountManager) ChannelsForAccount(account string) (channels []string)

func (*AccountManager) EnforcementStatus added in v1.0.0

func (am *AccountManager) EnforcementStatus(cfnick, skeleton string) (account string, method NickEnforcementMethod)

Given a nick, looks up the account that owns it and the method (none/timeout/strict) used to enforce ownership.

func (*AccountManager) Initialize added in v1.1.0

func (am *AccountManager) Initialize(server *Server)

func (*AccountManager) LoadAccount added in v0.11.0

func (am *AccountManager) LoadAccount(accountName string) (result ClientAccount, err error)

func (*AccountManager) Login added in v0.11.0

func (am *AccountManager) Login(client *Client, account ClientAccount)

func (*AccountManager) Logout added in v0.11.0

func (am *AccountManager) Logout(client *Client)

func (*AccountManager) ModifyAccountSettings added in v1.1.0

func (am *AccountManager) ModifyAccountSettings(account string, munger settingsMunger) (newSettings AccountSettings, err error)

func (*AccountManager) NickToAccount added in v0.11.0

func (am *AccountManager) NickToAccount(nick string) string

func (*AccountManager) Register added in v0.11.0

func (am *AccountManager) Register(client *Client, account string, callbackNamespace string, callbackValue string, passphrase string, certfp string) error

func (*AccountManager) SetEnforcementStatus added in v1.0.0

func (am *AccountManager) SetEnforcementStatus(account string, method NickEnforcementMethod) (finalSettings AccountSettings, err error)

Sets a custom enforcement method for an account and stores it in the database.

func (*AccountManager) SetNickReserved added in v0.11.0

func (am *AccountManager) SetNickReserved(client *Client, nick string, saUnreserve bool, reserve bool) error

func (*AccountManager) Unregister added in v0.11.0

func (am *AccountManager) Unregister(account string) error

func (*AccountManager) VHostApprove added in v0.12.0

func (am *AccountManager) VHostApprove(account string) (result VHostInfo, err error)

func (*AccountManager) VHostListRequests added in v0.12.0

func (am *AccountManager) VHostListRequests(limit int) (requests []PendingVHostRequest, total int)

func (*AccountManager) VHostReject added in v0.12.0

func (am *AccountManager) VHostReject(account string, reason string) (result VHostInfo, err error)

func (*AccountManager) VHostRequest added in v0.12.0

func (am *AccountManager) VHostRequest(account string, vhost string) (result VHostInfo, err error)

func (*AccountManager) VHostSet added in v0.12.0

func (am *AccountManager) VHostSet(account string, vhost string) (result VHostInfo, err error)

func (*AccountManager) VHostSetEnabled added in v0.12.0

func (am *AccountManager) VHostSetEnabled(client *Client, enabled bool) (result VHostInfo, err error)

func (*AccountManager) Verify added in v0.11.0

func (am *AccountManager) Verify(client *Client, account string, code string) error

type AccountRegistrationConfig

type AccountRegistrationConfig struct {
	Enabled                bool
	EnabledCallbacks       []string      `yaml:"enabled-callbacks"`
	EnabledCredentialTypes []string      `yaml:"-"`
	VerifyTimeout          time.Duration `yaml:"verify-timeout"`
	Callbacks              struct {
		Mailto struct {
			Server string
			Port   int
			TLS    struct {
				Enabled            bool
				InsecureSkipVerify bool   `yaml:"insecure_skip_verify"`
				ServerName         string `yaml:"servername"`
			}
			Username             string
			Password             string
			Sender               string
			VerifyMessageSubject string `yaml:"verify-message-subject"`
			VerifyMessage        string `yaml:"verify-message"`
		}
	}
	BcryptCost uint `yaml:"bcrypt-cost"`
}

AccountRegistrationConfig controls account registration.

type AccountSettings added in v1.1.0

type AccountSettings struct {
	AutoreplayLines *int
	NickEnforcement NickEnforcementMethod
	AllowBouncer    BouncerAllowedSetting
	AutoreplayJoins bool
}

type AuthOutcome added in v1.1.0

type AuthOutcome uint

type BouncerAllowedSetting added in v1.1.0

type BouncerAllowedSetting int
const (
	BouncerAllowedServerDefault BouncerAllowedSetting = iota
	BouncerDisallowedByUser
	BouncerAllowedByUser
)

type BrbState added in v1.1.0

type BrbState uint
const (
	// BrbDisabled is the default state; the client will be disconnected if it has no sessions
	BrbDisabled BrbState = iota
	// BrbEnabled allows the client to remain online without sessions; if a timeout is
	// reached, it will be removed
	BrbEnabled
	// BrbDead is the state of a client after its timeout has expired; it will be removed
	// and therefore new sessions cannot be attached to it
	BrbDead
	// BrbSticky allows a client to remain online without sessions, with no timeout.
	// This is not used yet.
	BrbSticky
)

type BrbTimer added in v1.1.0

type BrbTimer struct {
	// contains filtered or unexported fields
}

func (*BrbTimer) Disable added in v1.1.0

func (bt *BrbTimer) Disable() (brbAt time.Time)

turns off BRB for a client and stops the timer; used on resume and during client teardown

func (*BrbTimer) Enable added in v1.1.0

func (bt *BrbTimer) Enable() (success bool, duration time.Duration)

attempts to enable BRB for a client, returns whether it succeeded

func (*BrbTimer) Initialize added in v1.1.0

func (bt *BrbTimer) Initialize(client *Client)

func (*BrbTimer) SetSticky added in v1.1.0

func (bt *BrbTimer) SetSticky() (success bool)

sets a client to be "sticky", i.e., indefinitely exempt from removal for lack of sessions

type Channel

type Channel struct {
	// contains filtered or unexported fields
}

Channel represents a channel that clients can join.

func NewChannel

func NewChannel(s *Server, name string, registered bool) *Channel

NewChannel creates a new channel from a `Server` and a `name` string, which must be unique on the server.

func (*Channel) ApplyChannelModeChanges added in v0.10.1

func (channel *Channel) ApplyChannelModeChanges(client *Client, isSamode bool, changes modes.ModeChanges, rb *ResponseBuffer) modes.ModeChanges

ApplyChannelModeChanges applies a given set of mode changes.

func (*Channel) CanSpeak

func (channel *Channel) CanSpeak(client *Client) bool

CanSpeak returns true if the client can speak on this channel.

func (*Channel) ClientHasPrivsOver added in v0.10.1

func (channel *Channel) ClientHasPrivsOver(client *Client, target *Client) bool

func (*Channel) ClientIsAtLeast added in v0.3.0

func (channel *Channel) ClientIsAtLeast(client *Client, permission modes.Mode) bool

ClientIsAtLeast returns whether the client has at least the given channel privilege.

func (*Channel) ClientPrefixes added in v0.10.1

func (channel *Channel) ClientPrefixes(client *Client, isMultiPrefix bool) string

func (*Channel) DirtyBits added in v1.1.0

func (channel *Channel) DirtyBits() (dirtyBits uint)

func (*Channel) EnsureLoaded added in v1.1.0

func (channel *Channel) EnsureLoaded()

EnsureLoaded blocks until the channel's registration info has been loaded from the database.

func (*Channel) ExportRegistration added in v0.10.2

func (channel *Channel) ExportRegistration(includeFlags uint) (info RegisteredChannel)

obtain a consistent snapshot of the channel state that can be persisted to the DB

func (*Channel) Founder added in v0.10.2

func (channel *Channel) Founder() string

func (*Channel) HighestUserMode added in v1.1.0

func (channel *Channel) HighestUserMode(client *Client) (result modes.Mode)

func (*Channel) Invite

func (channel *Channel) Invite(invitee *Client, inviter *Client, rb *ResponseBuffer)

Invite invites the given client to the channel, if the inviter can do so.

func (*Channel) IsClean added in v1.1.0

func (channel *Channel) IsClean() bool

IsClean returns whether a channel can be safely removed from the server. To avoid the obvious TOCTOU race condition, it must be called while holding ChannelManager's lock (that way, no one can join and make the channel dirty again between this method exiting and the actual deletion).

func (*Channel) IsEmpty

func (channel *Channel) IsEmpty() bool

func (*Channel) IsLoaded added in v1.1.0

func (channel *Channel) IsLoaded() bool

func (*Channel) IsRegistered added in v0.10.2

func (channel *Channel) IsRegistered() bool

IsRegistered returns whether the channel is registered.

func (*Channel) Join

func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *ResponseBuffer)

Join joins the given client to this channel (if they can be joined).

func (*Channel) Key added in v0.10.1

func (channel *Channel) Key() string

func (*Channel) Kick

func (channel *Channel) Kick(client *Client, target *Client, comment string, rb *ResponseBuffer)

func (*Channel) MarkDirty added in v1.1.0

func (channel *Channel) MarkDirty(dirtyBits uint)

MarkDirty marks part (or all) of a channel's data as needing to be written back to the database, then starts a writer goroutine if necessary. This is the equivalent of Socket.Write().

func (*Channel) Members added in v0.10.1

func (channel *Channel) Members() (result []*Client)

func (*Channel) Name added in v0.10.1

func (channel *Channel) Name() string

func (*Channel) NameCasefolded added in v0.10.1

func (channel *Channel) NameCasefolded() string

func (*Channel) Names

func (channel *Channel) Names(client *Client, rb *ResponseBuffer)

Names sends the list of users joined to the channel to the given client.

func (*Channel) Part

func (channel *Channel) Part(client *Client, message string, rb *ResponseBuffer)

Part parts the given client from this channel, with the given message.

func (*Channel) ProcessAccountToUmodeChange added in v0.12.0

func (channel *Channel) ProcessAccountToUmodeChange(client *Client, change modes.ModeChange) (results []modes.ModeChange, err error)

ProcessAccountToUmodeChange processes Add/Remove/List operations for channel persistent usermodes.

func (*Channel) Quit

func (channel *Channel) Quit(client *Client)

Quit removes the given client from the channel

func (*Channel) Rename added in v1.1.0

func (channel *Channel) Rename(name, nameCasefolded string)

func (*Channel) Resume added in v1.0.0

func (channel *Channel) Resume(session *Session, timestamp time.Time)

Resume is called after a successful global resume to: 1. Replace the old client with the new in the channel's data structures 2. Send JOIN and MODE lines to channel participants (including the new client) 3. Replay missed message history to the client

func (*Channel) SendSplitMessage added in v1.1.0

func (channel *Channel) SendSplitMessage(command string, minPrefixMode modes.Mode, clientOnlyTags map[string]string, client *Client, message utils.SplitMessage, rb *ResponseBuffer)

func (*Channel) SendTopic added in v0.10.1

func (channel *Channel) SendTopic(client *Client, rb *ResponseBuffer, sendNoTopic bool)

SendTopic sends the channel topic to the given client. `sendNoTopic` controls whether RPL_NOTOPIC is sent when the topic is unset

func (*Channel) SetRegistered added in v0.10.2

func (channel *Channel) SetRegistered(founder string) error

SetRegistered registers the channel, returning an error if it was already registered.

func (*Channel) SetTopic

func (channel *Channel) SetTopic(client *Client, topic string, rb *ResponseBuffer)

SetTopic sets the topic of this channel, if the client is allowed to do so.

func (*Channel) SetUnregistered added in v0.12.0

func (channel *Channel) SetUnregistered(expectedFounder string)

SetUnregistered deletes the channel's registration information.

func (*Channel) ShowMaskList

func (channel *Channel) ShowMaskList(client *Client, mode modes.Mode, rb *ResponseBuffer)

ShowMaskList shows the given list to the client.

func (*Channel) Store added in v1.1.0

func (channel *Channel) Store(dirtyBits uint) (err error)

Store writes part (or all) of the channel's data back to the database, blocking until the write is complete. This is the equivalent of Socket.BlockingWrite.

type ChannelManager added in v0.10.1

type ChannelManager struct {
	sync.RWMutex // tier 2
	// contains filtered or unexported fields
}

ChannelManager keeps track of all the channels on the server, providing synchronization for creation of new channels on first join, cleanup of empty channels on last part, and renames.

func (*ChannelManager) Channels added in v0.10.1

func (cm *ChannelManager) Channels() (result []*Channel)

Channels returns a slice containing all current channels

func (*ChannelManager) Cleanup added in v0.11.0

func (cm *ChannelManager) Cleanup(channel *Channel)

func (*ChannelManager) Get added in v0.10.1

func (cm *ChannelManager) Get(name string) (channel *Channel)

Get returns an existing channel with name equivalent to `name`, or nil

func (*ChannelManager) Initialize added in v1.1.0

func (cm *ChannelManager) Initialize(server *Server)

NewChannelManager returns a new ChannelManager.

func (*ChannelManager) Join added in v0.10.1

func (cm *ChannelManager) Join(client *Client, name string, key string, isSajoin bool, rb *ResponseBuffer) error

Join causes `client` to join the channel named `name`, creating it if necessary.

func (*ChannelManager) Len added in v0.10.1

func (cm *ChannelManager) Len() int

Len returns the number of channels

func (*ChannelManager) Part added in v0.10.1

func (cm *ChannelManager) Part(client *Client, name string, message string, rb *ResponseBuffer) error

Part parts `client` from the channel named `name`, deleting it if it's empty.

func (*ChannelManager) Rename added in v0.10.1

func (cm *ChannelManager) Rename(name string, newname string) (err error)

Rename renames a channel (but does not notify the members)

func (*ChannelManager) SetRegistered added in v1.1.0

func (cm *ChannelManager) SetRegistered(channelName string, account string) (err error)

func (*ChannelManager) SetUnregistered added in v1.1.0

func (cm *ChannelManager) SetUnregistered(channelName string, account string) (err error)

type ChannelRegistrationConfig added in v0.7.0

type ChannelRegistrationConfig struct {
	Enabled               bool
	MaxChannelsPerAccount int `yaml:"max-channels-per-account"`
}

ChannelRegistrationConfig controls channel registration.

type ChannelRegistry added in v0.10.2

type ChannelRegistry struct {
	// contains filtered or unexported fields
}

ChannelRegistry manages registered channels.

func (*ChannelRegistry) AllChannels added in v1.1.0

func (reg *ChannelRegistry) AllChannels() (result map[string]bool)

func (*ChannelRegistry) Delete added in v0.12.0

func (reg *ChannelRegistry) Delete(info RegisteredChannel) (err error)

Delete deletes a channel corresponding to `info`. If no such channel is present in the database, no error is returned.

func (*ChannelRegistry) Initialize added in v1.1.0

func (reg *ChannelRegistry) Initialize(server *Server)

NewChannelRegistry returns a new ChannelRegistry.

func (*ChannelRegistry) LoadChannel added in v0.10.2

func (reg *ChannelRegistry) LoadChannel(nameCasefolded string) (info RegisteredChannel, err error)

LoadChannel loads a channel from the store.

func (*ChannelRegistry) StoreChannel added in v0.10.2

func (reg *ChannelRegistry) StoreChannel(info RegisteredChannel, includeFlags uint) (err error)

StoreChannel obtains a consistent view of a channel, then persists it to the store.

type ChannelSet

type ChannelSet map[*Channel]bool

ChannelSet is a set of channels.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an IRC client.

func (*Client) Account added in v0.11.0

func (client *Client) Account() string

func (*Client) AccountName added in v0.10.2

func (client *Client) AccountName() string

func (*Client) AccountSettings added in v1.1.0

func (client *Client) AccountSettings() (result AccountSettings)

func (*Client) Active

func (client *Client) Active(session *Session)

Active updates when the client was last 'active' (i.e. the user should be sitting in front of their client).

func (*Client) AddSession added in v1.1.0

func (client *Client) AddSession(session *Session) (success bool)

func (*Client) AllNickmasks added in v0.6.0

func (client *Client) AllNickmasks() (masks []string)

AllNickmasks returns all the possible nickmasks for the client.

func (*Client) AllSessionData added in v1.1.0

func (client *Client) AllSessionData(currentSession *Session) (data []SessionData, currentIndex int)

func (*Client) ApplyProxiedIP added in v0.10.0

func (client *Client) ApplyProxiedIP(session *Session, proxiedIP string, tls bool) (err error, quitMsg string)

ApplyProxiedIP applies the given IP to the client.

func (*Client) Away added in v1.1.0

func (client *Client) Away() (result bool)

func (*Client) AwayMessage added in v1.0.0

func (client *Client) AwayMessage() (result string)

func (*Client) Channels added in v0.10.1

func (client *Client) Channels() (result []*Channel)

func (*Client) CheckInvited added in v1.0.0

func (client *Client) CheckInvited(casefoldedChannel string) (invited bool)

Checks that the client was invited to join a given channel

func (*Client) Details added in v1.0.0

func (client *Client) Details() (result ClientDetails)

func (*Client) Friends

func (client *Client) Friends(capabs ...caps.Capability) (result map[*Session]bool)

Friends refers to clients that share a channel with this client.

func (*Client) GetSessionByResumeID added in v1.1.0

func (client *Client) GetSessionByResumeID(resumeID string) (result *Session)

func (*Client) HasMode added in v0.10.1

func (client *Client) HasMode(mode modes.Mode) bool

func (*Client) HasNick

func (client *Client) HasNick() bool

HasNick returns true if the client's nickname is set (used in registration).

func (*Client) HasRoleCapabs added in v0.10.0

func (client *Client) HasRoleCapabs(capabs ...string) bool

HasRoleCapabs returns true if client has the given (role) capabilities.

func (*Client) HasUsername

func (client *Client) HasUsername() bool

HasUsername returns true if the client's username is set (used in registration).

func (*Client) Hostname added in v0.10.1

func (client *Client) Hostname() string

func (*Client) IP added in v0.8.1

func (client *Client) IP() net.IP

IP returns the IP address of this client.

func (*Client) IPString added in v0.8.1

func (client *Client) IPString() string

IPString returns the IP address of this client as a string.

func (*Client) IdleSeconds

func (client *Client) IdleSeconds() uint64

IdleSeconds returns the number of seconds this client's been idle.

func (*Client) IdleTime

func (client *Client) IdleTime() time.Duration

IdleTime returns how long this client's been idle.

func (*Client) Invite added in v1.0.0

func (client *Client) Invite(casefoldedChannel string)

Records that the client has been invited to join an invite-only channel

func (*Client) Languages added in v1.1.0

func (client *Client) Languages() (languages []string)

func (*Client) LoggedIntoAccount added in v0.9.1

func (client *Client) LoggedIntoAccount() bool

LoggedIntoAccount returns true if this client is logged into an account.

func (*Client) ModeString

func (client *Client) ModeString() (str string)

ModeString returns the mode string for this client.

func (*Client) Nick

func (client *Client) Nick() string

func (*Client) NickCasefolded added in v0.10.1

func (client *Client) NickCasefolded() string

func (*Client) NickMaskCasefolded added in v1.0.0

func (client *Client) NickMaskCasefolded() string

func (*Client) NickMaskString added in v0.10.1

func (client *Client) NickMaskString() string

func (*Client) Notice

func (client *Client) Notice(text string)

Notice sends the client a notice from the server.

func (*Client) NumChannels added in v1.0.0

func (client *Client) NumChannels() int

func (*Client) Oper added in v0.12.0

func (client *Client) Oper() *Oper

func (*Client) Quit

func (client *Client) Quit(message string, session *Session)

Quit sets the given quit message for the client. (You must ensure separately that destroy() is called, e.g., by returning `true` from the command handler or calling it yourself.)

func (*Client) RawHostname added in v1.1.0

func (client *Client) RawHostname() (result string)

func (*Client) Registered added in v0.10.0

func (client *Client) Registered() bool

func (*Client) ResumeID added in v1.0.0

func (client *Client) ResumeID() string

func (*Client) RplISupport

func (client *Client) RplISupport(rb *ResponseBuffer)

RplISupport outputs our ISUPPORT lines to the client. This is used on connection and in VERSION responses.

func (*Client) RplList

func (target *Client) RplList(channel *Channel, rb *ResponseBuffer)

RplList returns the RPL_LIST numeric for the given channel.

func (*Client) Send

func (client *Client) Send(tags map[string]string, prefix string, command string, params ...string) (err error)

Send sends an IRC line to the client.

func (*Client) Sessions added in v1.1.0

func (client *Client) Sessions() (sessions []*Session)

func (*Client) SetAccountName added in v0.11.0

func (client *Client) SetAccountName(account string) (changed bool)

func (*Client) SetAccountSettings added in v1.1.0

func (client *Client) SetAccountSettings(settings AccountSettings)

func (*Client) SetAway added in v1.1.0

func (client *Client) SetAway(away bool, awayMessage string) (changed bool)

func (*Client) SetAwayMessage added in v1.0.0

func (client *Client) SetAwayMessage(message string)

func (*Client) SetExitedSnomaskSent added in v1.1.0

func (client *Client) SetExitedSnomaskSent()

func (*Client) SetLanguages added in v1.1.0

func (client *Client) SetLanguages(languages []string)

func (*Client) SetMode added in v0.12.0

func (client *Client) SetMode(mode modes.Mode, on bool) bool

func (*Client) SetNames added in v1.0.0

func (client *Client) SetNames(username, realname string, fromIdent bool) error

SetNames sets the client's ident and realname.

func (*Client) SetOper added in v0.12.0

func (client *Client) SetOper(oper *Oper)

func (*Client) SetRawHostname added in v1.1.0

func (client *Client) SetRawHostname(rawHostname string)

func (*Client) SetRegistered added in v1.0.0

func (client *Client) SetRegistered()

func (*Client) SetResumeID added in v1.0.0

func (client *Client) SetResumeID(id string)

func (*Client) SetVHost added in v0.12.0

func (client *Client) SetVHost(vhost string) (updated bool)

SetVHost updates the client's hostserv-based vhost

func (*Client) SignonTime

func (client *Client) SignonTime() int64

SignonTime returns this client's signon time as a unix timestamp.

func (*Client) Username added in v0.10.1

func (client *Client) Username() string

func (*Client) WhoWas added in v0.12.0

func (client *Client) WhoWas() (result WhoWas)

func (*Client) WhoisChannelsNames

func (client *Client) WhoisChannelsNames(target *Client, multiPrefix bool) []string

WhoisChannelsNames returns the common channel names between two users.

type ClientAccount

type ClientAccount struct {
	// Name of the account.
	Name string
	// RegisteredAt represents the time that the account was registered.
	RegisteredAt    time.Time
	Credentials     AccountCredentials
	Verified        bool
	AdditionalNicks []string
	VHost           VHostInfo
	Settings        AccountSettings
}

ClientAccount represents a user account.

type ClientDetails added in v1.0.0

type ClientDetails struct {
	WhoWas
	// contains filtered or unexported fields
}

ClientDetails is a standard set of details about a client

type ClientManager added in v0.10.3

type ClientManager struct {
	sync.RWMutex // tier 2
	// contains filtered or unexported fields
}

ClientManager keeps track of clients by nick, enforcing uniqueness of casefolded nicks

func (*ClientManager) AllClients added in v0.10.3

func (clients *ClientManager) AllClients() (result []*Client)

func (*ClientManager) AllWithCaps added in v0.10.3

func (clients *ClientManager) AllWithCaps(capabs ...caps.Capability) (sessions []*Session)

AllWithCaps returns all clients with the given capabilities.

func (*ClientManager) AllWithCapsNotify added in v1.1.0

func (clients *ClientManager) AllWithCapsNotify(capabs ...caps.Capability) (sessions []*Session)

AllWithCapsNotify returns all clients with the given capabilities, and that support cap-notify.

func (*ClientManager) Count added in v0.10.3

func (clients *ClientManager) Count() int

Count returns how many clients are in the manager.

func (*ClientManager) FindAll added in v0.10.3

func (clients *ClientManager) FindAll(userhost string) (set ClientSet)

FindAll returns all clients that match the given userhost mask.

func (*ClientManager) Get added in v0.10.3

func (clients *ClientManager) Get(nick string) *Client

Get retrieves a client from the manager, if they exist.

func (*ClientManager) Initialize added in v1.1.0

func (clients *ClientManager) Initialize()

Initialize initializes a ClientManager.

func (*ClientManager) Remove added in v0.10.3

func (clients *ClientManager) Remove(client *Client) error

Remove removes a client from the lookup set.

func (*ClientManager) Resume added in v1.0.0

func (clients *ClientManager) Resume(oldClient *Client, session *Session) (err error)

Handles a RESUME by attaching a session to a designated client. It is the caller's responsibility to verify that the resume is allowed (checking tokens, TLS status, etc.) before calling this.

func (*ClientManager) SetNick added in v0.10.3

func (clients *ClientManager) SetNick(client *Client, session *Session, newNick string) error

SetNick sets a client's nickname, validating it against nicknames in use

type ClientSet

type ClientSet map[*Client]bool

ClientSet is a set of clients.

func (ClientSet) Add

func (clients ClientSet) Add(client *Client)

Add adds the given client to this set.

func (ClientSet) Has

func (clients ClientSet) Has(client *Client) bool

Has returns true if the given client is in this set.

func (ClientSet) Remove

func (clients ClientSet) Remove(client *Client)

Remove removes the given client from this set.

type Command

type Command struct {
	// contains filtered or unexported fields
}

Command represents a command accepted from a client.

func (*Command) Run

func (cmd *Command) Run(server *Server, client *Client, session *Session, msg ircmsg.IrcMessage) bool

Run runs this command with the given client/message.

type Config

type Config struct {
	Network struct {
		Name string
	}

	Server struct {
		Password string

		Name string

		Listen       []string
		UnixBindMode os.FileMode                 `yaml:"unix-bind-mode"`
		TLSListeners map[string]*TLSListenConfig `yaml:"tls-listeners"`
		TorListeners TorListenersConfig          `yaml:"tor-listeners"`
		STS          STSConfig
		CheckIdent   bool `yaml:"check-ident"`
		MOTD         string

		MOTDFormatting   bool     `yaml:"motd-formatting"`
		ProxyAllowedFrom []string `yaml:"proxy-allowed-from"`

		WebIRC               []webircConfig `yaml:"webirc"`
		MaxSendQString       string         `yaml:"max-sendq"`
		MaxSendQBytes        int
		AllowPlaintextResume bool `yaml:"allow-plaintext-resume"`
		Compatibility        struct {
			ForceTrailing *bool `yaml:"force-trailing"`

			SendUnprefixedSasl bool `yaml:"send-unprefixed-sasl"`
			// contains filtered or unexported fields
		}

		ConnectionLimiter   connection_limits.LimiterConfig   `yaml:"connection-limits"`
		ConnectionThrottler connection_limits.ThrottlerConfig `yaml:"connection-throttling"`
		Cloaks              cloaks.CloakConfig                `yaml:"ip-cloaking"`
		// contains filtered or unexported fields
	}

	Languages struct {
		Enabled bool
		Path    string
		Default string
	}

	Datastore struct {
		Path        string
		AutoUpgrade bool
	}

	Accounts AccountConfig

	Channels struct {
		DefaultModes *string `yaml:"default-modes"`

		MaxChannelsPerClient int  `yaml:"max-channels-per-client"`
		OpOnlyCreation       bool `yaml:"operator-only-creation"`
		Registration         ChannelRegistrationConfig
		// contains filtered or unexported fields
	}

	OperClasses map[string]*OperClassConfig `yaml:"oper-classes"`

	Opers map[string]*OperConfig

	Logging []logger.LoggingConfig

	Debug struct {
		RecoverFromErrors *bool `yaml:"recover-from-errors"`

		PprofListener *string `yaml:"pprof-listener"`
		// contains filtered or unexported fields
	}

	Limits Limits

	Fakelag FakelagConfig

	History struct {
		Enabled          bool
		ChannelLength    int `yaml:"channel-length"`
		ClientLength     int `yaml:"client-length"`
		AutoreplayOnJoin int `yaml:"autoreplay-on-join"`
		ChathistoryMax   int `yaml:"chathistory-maxmessages"`
	}

	Filename string
	// contains filtered or unexported fields
}

Config defines the overall configuration.

func LoadConfig

func LoadConfig(filename string) (config *Config, err error)

LoadConfig loads the given YAML configuration file.

func (*Config) OperatorClasses added in v0.4.0

func (conf *Config) OperatorClasses() (map[string]*OperClass, error)

OperatorClasses returns a map of assembled operator classes from the given config.

func (*Config) Operators

func (conf *Config) Operators(oc map[string]*OperClass) (map[string]*Oper, error)

Operators returns a map of operator configs from the given OperClass and config.

func (*Config) TLSListeners

func (conf *Config) TLSListeners() (map[string]*tls.Config, error)

TLSListeners returns a list of TLS listeners and their configs.

type DLineManager added in v0.5.0

type DLineManager struct {
	sync.RWMutex // tier 1
	// contains filtered or unexported fields
}

DLineManager manages and dlines.

func NewDLineManager added in v0.5.0

func NewDLineManager(server *Server) *DLineManager

NewDLineManager returns a new DLineManager.

func (*DLineManager) AddIP added in v0.5.0

func (dm *DLineManager) AddIP(addr net.IP, duration time.Duration, reason, operReason, operName string) error

AddIP adds an IP address to the blocked list.

func (*DLineManager) AddNetwork added in v0.5.0

func (dm *DLineManager) AddNetwork(network net.IPNet, duration time.Duration, reason, operReason, operName string) error

AddNetwork adds a network to the blocked list.

func (*DLineManager) AllBans added in v0.5.0

func (dm *DLineManager) AllBans() map[string]IPBanInfo

AllBans returns all bans (for use with APIs, etc).

func (*DLineManager) CheckIP added in v0.5.0

func (dm *DLineManager) CheckIP(addr net.IP) (isBanned bool, info IPBanInfo)

CheckIP returns whether or not an IP address was banned, and how long it is banned for.

func (*DLineManager) RemoveIP added in v0.5.0

func (dm *DLineManager) RemoveIP(addr net.IP) error

RemoveIP removes an IP address from the blocked list.

func (*DLineManager) RemoveNetwork added in v0.5.0

func (dm *DLineManager) RemoveNetwork(network net.IPNet) error

RemoveNetwork removes a network from the blocked list.

type Fakelag added in v0.11.0

type Fakelag struct {
	// contains filtered or unexported fields
}

this is intentionally not threadsafe, because it should only be touched from the loop that accepts the client's input and runs commands

func (*Fakelag) Initialize added in v1.1.0

func (fl *Fakelag) Initialize(config FakelagConfig)

func (*Fakelag) Touch added in v0.11.0

func (fl *Fakelag) Touch()

register a new command, sleep if necessary to delay it

type FakelagConfig added in v0.11.0

type FakelagConfig struct {
	Enabled           bool
	Window            time.Duration
	BurstLimit        uint `yaml:"burst-limit"`
	MessagesPerWindow uint `yaml:"messages-per-window"`
	Cooldown          time.Duration
}

type FakelagState added in v0.11.0

type FakelagState uint
const (
	// initially, the client is "bursting" and can send n commands without
	// encountering fakelag
	FakelagBursting FakelagState = iota
	// after that, they're "throttled" and we sleep in between commands until
	// they're spaced sufficiently far apart
	FakelagThrottled
)

type HelpEntry added in v0.2.0

type HelpEntry struct {
	// contains filtered or unexported fields
}

HelpEntry represents an entry in the Help map.

type HelpEntryType added in v0.8.0

type HelpEntryType int

HelpEntryType represents the different sorts of help entries that can exist.

const (
	// CommandHelpEntry is a help entry explaining a client command.
	CommandHelpEntry HelpEntryType = iota
	// InformationHelpEntry is a help entry explaining general server info.
	InformationHelpEntry
	// ISupportHelpEntry is a help entry explaining a specific RPL_ISUPPORT token.
	ISupportHelpEntry
)

type HelpIndexManager added in v1.1.0

type HelpIndexManager struct {
	sync.RWMutex // tier 1
	// contains filtered or unexported fields
}

func (*HelpIndexManager) GenerateIndices added in v1.1.0

func (hm *HelpIndexManager) GenerateIndices(lm *languages.Manager)

GenerateIndices regenerates our help indexes for each currently enabled language.

func (*HelpIndexManager) GetIndex added in v1.1.0

func (hm *HelpIndexManager) GetIndex(languages []string, oper bool) string

GetHelpIndex returns the help index for the given language.

type IPBanInfo added in v0.5.0

type IPBanInfo struct {
	// Reason is the ban reason.
	Reason string `json:"reason"`
	// OperReason is an oper ban reason.
	OperReason string `json:"oper_reason"`
	// OperName is the oper who set the ban.
	OperName string `json:"oper_name"`
	// time of ban creation
	TimeCreated time.Time
	// duration of the ban; 0 means "permanent"
	Duration time.Duration
}

IPBanInfo holds info about an IP/net ban.

func (IPBanInfo) BanMessage added in v0.9.0

func (info IPBanInfo) BanMessage(message string) string

BanMessage returns the ban message.

func (IPBanInfo) TimeLeft added in v1.0.0

func (info IPBanInfo) TimeLeft() string

type IdleTimer added in v0.10.0

type IdleTimer struct {
	sync.Mutex // tier 1
	// contains filtered or unexported fields
}

func (*IdleTimer) Initialize added in v1.1.0

func (it *IdleTimer) Initialize(session *Session)

Initialize sets up an IdleTimer and starts counting idle time; if there is no activity from the client, it will eventually be stopped.

func (*IdleTimer) Stop added in v0.10.0

func (it *IdleTimer) Stop()

Stop stops counting idle time.

func (*IdleTimer) Touch added in v0.10.0

func (it *IdleTimer) Touch()

type KLineInfo added in v0.6.0

type KLineInfo struct {
	// Mask that is blocked.
	Mask string
	// Matcher, to facilitate fast matching.
	Matcher ircmatch.Matcher
	// Info contains information on the ban.
	Info IPBanInfo
}

KLineInfo contains the address itself and expiration time for a given network.

type KLineManager added in v0.6.0

type KLineManager struct {
	sync.RWMutex // tier 1
	// contains filtered or unexported fields
}

KLineManager manages and klines.

func NewKLineManager added in v0.6.0

func NewKLineManager(s *Server) *KLineManager

NewKLineManager returns a new KLineManager.

func (*KLineManager) AddMask added in v0.6.0

func (km *KLineManager) AddMask(mask string, duration time.Duration, reason, operReason, operName string) error

AddMask adds to the blocked list.

func (*KLineManager) AllBans added in v0.6.0

func (km *KLineManager) AllBans() map[string]IPBanInfo

AllBans returns all bans (for use with APIs, etc).

func (*KLineManager) CheckMasks added in v0.6.0

func (km *KLineManager) CheckMasks(masks ...string) (isBanned bool, info IPBanInfo)

CheckMasks returns whether or not the hostmask(s) are banned, and how long they are banned for.

func (*KLineManager) RemoveMask added in v0.6.0

func (km *KLineManager) RemoveMask(mask string) error

RemoveMask removes a mask from the blocked list.

type Limits

type Limits struct {
	AwayLen              int           `yaml:"awaylen"`
	ChanListModes        int           `yaml:"chan-list-modes"`
	ChannelLen           int           `yaml:"channellen"`
	IdentLen             int           `yaml:"identlen"`
	KickLen              int           `yaml:"kicklen"`
	LineLen              LineLenLimits `yaml:"linelen"`
	MonitorEntries       int           `yaml:"monitor-entries"`
	NickLen              int           `yaml:"nicklen"`
	TopicLen             int           `yaml:"topiclen"`
	WhowasEntries        int           `yaml:"whowas-entries"`
	RegistrationMessages int           `yaml:"registration-messages"`
}

Various server-enforced limits on data size.

type LineLenLimits added in v0.6.0

type LineLenLimits struct {
	Rest int
}

LineLenConfig controls line lengths.

type ListenerWrapper added in v0.9.0

type ListenerWrapper struct {
	// contains filtered or unexported fields
}

ListenerWrapper wraps a listener so it can be safely reconfigured or stopped

type MemberSet

type MemberSet map[*Client]*modes.ModeSet

MemberSet is a set of members with modes.

func (MemberSet) Add

func (members MemberSet) Add(member *Client)

Add adds the given client to this set.

func (MemberSet) AnyHasMode

func (members MemberSet) AnyHasMode(mode modes.Mode) bool

AnyHasMode returns true if any of our clients has the given mode.

func (MemberSet) Has

func (members MemberSet) Has(member *Client) bool

Has returns true if the given client is in this set.

func (MemberSet) Remove

func (members MemberSet) Remove(member *Client)

Remove removes the given client from this set.

type MonitorManager added in v0.10.0

type MonitorManager struct {
	sync.RWMutex // tier 2
	// contains filtered or unexported fields
}

MonitorManager keeps track of who's monitoring which nicks.

func (*MonitorManager) Add added in v0.10.0

func (manager *MonitorManager) Add(client *Client, nick string, limit int) error

Add registers `client` to receive notifications about `nick`.

func (*MonitorManager) AlertAbout added in v0.10.0

func (manager *MonitorManager) AlertAbout(client *Client, online bool)

AlertAbout alerts everyone monitoring `client`'s nick that `client` is now {on,off}line.

func (*MonitorManager) Initialize added in v1.1.0

func (mm *MonitorManager) Initialize()

func (*MonitorManager) List added in v0.10.0

func (manager *MonitorManager) List(client *Client) (nicks []string)

List lists all nicks that `client` is registered to receive notifications about.

func (*MonitorManager) Remove added in v0.10.0

func (manager *MonitorManager) Remove(client *Client, nick string) error

Remove unregisters `client` from receiving notifications about `nick`.

func (*MonitorManager) RemoveAll added in v0.10.0

func (manager *MonitorManager) RemoveAll(client *Client)

RemoveAll unregisters `client` from receiving notifications about *all* nicks.

type NickEnforcementMethod added in v1.1.0

type NickEnforcementMethod int
const (
	// NickEnforcementOptional is the zero value; it serializes to
	// "optional" in the yaml config, and "default" as an arg to `NS ENFORCE`.
	// in both cases, it means "defer to the other source of truth", i.e.,
	// in the config, defer to the user's custom setting, and as a custom setting,
	// defer to the default in the config. if both are NickEnforcementOptional then
	// there is no enforcement.
	// XXX: these are serialized as numbers in the database, so beware of collisions
	// when refactoring (any numbers currently in use must keep their meanings, or
	// else be fixed up by a schema change)
	NickEnforcementOptional NickEnforcementMethod = iota
	NickEnforcementNone
	NickEnforcementWithTimeout
	NickEnforcementStrict
)

func (*NickEnforcementMethod) UnmarshalYAML added in v1.1.0

func (nr *NickEnforcementMethod) UnmarshalYAML(unmarshal func(interface{}) error) error

type NickReservationConfig added in v0.11.0

type NickReservationConfig struct {
	Enabled                bool
	AdditionalNickLimit    int `yaml:"additional-nick-limit"`
	Method                 NickEnforcementMethod
	AllowCustomEnforcement bool          `yaml:"allow-custom-enforcement"`
	RenameTimeout          time.Duration `yaml:"rename-timeout"`
	RenamePrefix           string        `yaml:"rename-prefix"`
}

type NickTimer added in v0.11.0

type NickTimer struct {
	sync.Mutex // tier 1
	// contains filtered or unexported fields
}

NickTimer manages timing out of clients who are squatting reserved nicks

func (*NickTimer) Enabled added in v1.1.0

func (nt *NickTimer) Enabled() bool

func (*NickTimer) Initialize added in v1.1.0

func (nt *NickTimer) Initialize(client *Client)

Initialize sets up a NickTimer, based on server config settings.

func (*NickTimer) Stop added in v0.11.0

func (nt *NickTimer) Stop()

Stop stops counting time and cleans up the timer

func (*NickTimer) Timeout added in v1.1.0

func (nt *NickTimer) Timeout() (timeout time.Duration)

func (*NickTimer) Touch added in v0.11.0

func (nt *NickTimer) Touch(rb *ResponseBuffer)

Touch records a nick change and updates the timer as necessary

type Oper added in v0.4.0

type Oper struct {
	Name      string
	Class     *OperClass
	WhoisLine string
	Vhost     string
	Pass      []byte
	Modes     []modes.ModeChange
}

Oper represents a single assembled operator's config.

type OperClass added in v0.4.0

type OperClass struct {
	Title        string
	WhoisLine    string          `yaml:"whois-line"`
	Capabilities map[string]bool // map to make lookups much easier
}

OperClass defines an assembled operator class.

type OperClassConfig added in v0.4.0

type OperClassConfig struct {
	Title        string
	WhoisLine    string
	Extends      string
	Capabilities []string
}

OperClassConfig defines a specific operator class.

type OperConfig added in v0.4.0

type OperConfig struct {
	Class     string
	Vhost     string
	WhoisLine string `yaml:"whois-line"`
	Password  string
	Modes     string
}

OperConfig defines a specific operator's configuration.

type PendingVHostRequest added in v0.12.0

type PendingVHostRequest struct {
	VHostInfo
	Account string
}

pair type, <VHostInfo, accountName>

type RegisteredChannel added in v0.7.0

type RegisteredChannel struct {
	// Name of the channel.
	Name string
	// Casefolded name of the channel.
	NameCasefolded string
	// RegisteredAt represents the time that the channel was registered.
	RegisteredAt time.Time
	// Founder indicates the founder of the channel.
	Founder string
	// Topic represents the channel topic.
	Topic string
	// TopicSetBy represents the host that set the topic.
	TopicSetBy string
	// TopicSetTime represents the time the topic was set.
	TopicSetTime time.Time
	// Modes represents the channel modes
	Modes []modes.Mode
	// Key represents the channel key / password
	Key string
	// AccountToUMode maps user accounts to their persistent channel modes (e.g., +q, +h)
	AccountToUMode map[string]modes.Mode
	// Banlist represents the bans set on the channel.
	Banlist []string
	// Exceptlist represents the exceptions set on the channel.
	Exceptlist []string
	// Invitelist represents the invite exceptions set on the channel.
	Invitelist []string
}

RegisteredChannel holds details about a given registered channel.

type ResponseBuffer added in v0.11.0

type ResponseBuffer struct {
	Label string // label if this is a labeled response batch
	// contains filtered or unexported fields
}

ResponseBuffer - put simply - buffers messages and then outputs them to a given client.

Using a ResponseBuffer lets you really easily implement labeled-response, since the buffer will silently create a batch if required and label the outgoing messages as necessary (or leave it off and simply tag the outgoing message).

func NewResponseBuffer added in v0.11.0

func NewResponseBuffer(session *Session) *ResponseBuffer

NewResponseBuffer returns a new ResponseBuffer.

func (*ResponseBuffer) Add added in v0.11.0

func (rb *ResponseBuffer) Add(tags map[string]string, prefix string, command string, params ...string)

Add adds a standard new message to our queue.

func (*ResponseBuffer) AddFromClient added in v0.11.0

func (rb *ResponseBuffer) AddFromClient(time time.Time, msgid string, fromNickMask string, fromAccount string, tags map[string]string, command string, params ...string)

AddFromClient adds a new message from a specific client to our queue.

func (*ResponseBuffer) AddMessage added in v1.1.0

func (rb *ResponseBuffer) AddMessage(msg ircmsg.IrcMessage)

func (*ResponseBuffer) AddSplitMessageFromClient added in v0.11.0

func (rb *ResponseBuffer) AddSplitMessageFromClient(fromNickMask string, fromAccount string, tags map[string]string, command string, target string, message utils.SplitMessage)

AddSplitMessageFromClient adds a new split message from a specific client to our queue.

func (*ResponseBuffer) EndNestedBatch added in v1.1.0

func (rb *ResponseBuffer) EndNestedBatch(batchID string)

Ends a nested batch

func (*ResponseBuffer) Flush added in v1.0.0

func (rb *ResponseBuffer) Flush(blocking bool) error

Flush sends all messages in the buffer to the client. Afterwards, the buffer can still be used. Client code MUST subsequently call Send() to ensure that the final `BATCH -` message is sent. If `blocking` is true you MUST be sending to the client from its own goroutine.

func (*ResponseBuffer) ForceBatchStart added in v1.1.0

func (rb *ResponseBuffer) ForceBatchStart(batchType string, blocking bool)

ForceBatchStart forcibly starts a batch of batch `batchType`. Normally, Send/Flush will decide automatically whether to start a batch of type draft/labeled-response. This allows changing the batch type and forcing the creation of a possibly empty batch.

func (*ResponseBuffer) Notice added in v0.11.0

func (rb *ResponseBuffer) Notice(text string)

Notice sends the client the given notice from the server.

func (*ResponseBuffer) Send added in v0.11.0

func (rb *ResponseBuffer) Send(blocking bool) error

Send sends all messages in the buffer to the client. Afterwards, the buffer is in an undefined state and MUST NOT be used further. If `blocking` is true you MUST be sending to the client from its own goroutine.

func (*ResponseBuffer) StartNestedBatch added in v1.1.0

func (rb *ResponseBuffer) StartNestedBatch(batchType string, params ...string) (batchID string)

Starts a nested batch (see the ResponseBuffer struct definition for a description of how this works)

func (*ResponseBuffer) StartNestedHistoryBatch added in v1.1.0

func (rb *ResponseBuffer) StartNestedHistoryBatch(params ...string) (batchID string)

Convenience to start a nested batch for history lines, at the highest level supported by the client (`history`, `chathistory`, or no batch, in descending order).

type ResumeDetails added in v0.11.0

type ResumeDetails struct {
	PresentedToken    string
	Timestamp         time.Time
	HistoryIncomplete bool
}

ResumeDetails is a place to stash data at various stages of the resume process: when handling the RESUME command itself, when completing the registration, and when rejoining channels.

type ResumeManager added in v1.0.0

type ResumeManager struct {
	sync.Mutex // level 2
	// contains filtered or unexported fields
}

func (*ResumeManager) Delete added in v1.0.0

func (rm *ResumeManager) Delete(client *Client)

Delete stops tracking a client's resume token.

func (*ResumeManager) GenerateToken added in v1.0.0

func (rm *ResumeManager) GenerateToken(client *Client) (token string, id string)

GenerateToken generates a resume token for a client. If the client has already been assigned one, it returns "".

func (*ResumeManager) Initialize added in v1.0.0

func (rm *ResumeManager) Initialize(server *Server)

func (*ResumeManager) VerifyToken added in v1.0.0

func (rm *ResumeManager) VerifyToken(newClient *Client, token string) (oldClient *Client, id string)

VerifyToken looks up the client corresponding to a resume token, returning nil if there is no such client or the token is invalid. If successful, the token is consumed and cannot be used to resume again.

type STSConfig added in v0.7.0

type STSConfig struct {
	Enabled        bool
	Duration       time.Duration `yaml:"duration-real"`
	DurationString string        `yaml:"duration"`
	Port           int
	Preload        bool
}

STSConfig controls the STS configuration/

func (*STSConfig) Value added in v0.7.0

func (sts *STSConfig) Value() string

Value returns the STS value to advertise in CAP

type SchemaChange added in v0.12.0

type SchemaChange struct {
	InitialVersion string // the change will take this version
	TargetVersion  string // and transform it into this version
	Changer        SchemaChanger
}

type SchemaChanger added in v0.12.0

type SchemaChanger func(*Config, *buntdb.Tx) error

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the main Oragono server.

func NewServer

func NewServer(config *Config, logger *logger.Manager) (*Server, error)

NewServer returns a new Oragono server.

func (*Server) AccountConfig added in v0.11.0

func (server *Server) AccountConfig() *AccountConfig

func (*Server) ChannelRegistrationEnabled added in v0.10.2

func (server *Server) ChannelRegistrationEnabled() bool

func (*Server) Config added in v0.12.0

func (server *Server) Config() (config *Config)

func (*Server) GetOperator added in v0.12.0

func (server *Server) GetOperator(name string) (oper *Oper)

func (*Server) Languages added in v1.1.0

func (server *Server) Languages() (lm *languages.Manager)

func (*Server) MOTD

func (server *Server) MOTD(client *Client, rb *ResponseBuffer)

MOTD serves the Message of the Day.

func (*Server) RandomlyRename added in v0.11.0

func (server *Server) RandomlyRename(client *Client)

func (*Server) Run

func (server *Server) Run()

Run starts the server.

func (*Server) RunClient added in v1.1.0

func (server *Server) RunClient(conn clientConn)

RunClient sets up a new client and runs its goroutine.

func (*Server) SetConfig added in v1.1.0

func (server *Server) SetConfig(config *Config)

func (*Server) Shutdown

func (server *Server) Shutdown()

Shutdown shuts down the server.

type ServerSemaphores added in v0.12.0

type ServerSemaphores struct {
	// each distinct operation MUST have its own semaphore;
	// methods that acquire a semaphore MUST NOT call methods that acquire another
	ClientDestroy utils.Semaphore
}

ServerSemaphores includes a named Semaphore corresponding to each concurrency-limited sever operation.

func (*ServerSemaphores) Initialize added in v1.1.0

func (serversem *ServerSemaphores) Initialize()

Initialize initializes a set of server semaphores.

type Session added in v1.1.0

type Session struct {
	// contains filtered or unexported fields
}

Session is an individual client connection to the server (TCP connection and associated per-connection data, such as capabilities). There is a many-one relationship between sessions and clients.

func (*Session) Destroyed added in v1.1.0

func (session *Session) Destroyed() bool

returns whether the session was actively destroyed (for example, by ping timeout or NS GHOST). avoids a race condition between asynchronous idle-timing-out of sessions, and a condition that allows implicit BRB on connection errors (since destroy()'s socket.Close() appears to socket.Read() as a connection error)

func (*Session) HasHistoryCaps added in v1.1.0

func (session *Session) HasHistoryCaps() bool

returns whether the client supports a smart history replay cap, and therefore autoreplay-on-join and similar should be suppressed

func (*Session) MaxlenRest added in v1.1.0

func (session *Session) MaxlenRest() int

allow the negotiated message length limit to be read without locks; this is a convenience so that Session.SendRawMessage doesn't have to acquire any Client locks

func (*Session) Ping added in v1.1.0

func (session *Session) Ping()

Ping sends the client a PING message.

func (*Session) Send added in v1.1.0

func (session *Session) Send(tags map[string]string, prefix string, command string, params ...string) (err error)

func (*Session) SendRawMessage added in v1.1.0

func (session *Session) SendRawMessage(message ircmsg.IrcMessage, blocking bool) error

SendRawMessage sends a raw message to the client.

func (*Session) SetDestroyed added in v1.1.0

func (session *Session) SetDestroyed()

sets the timed-out flag

func (*Session) SetMaxlenRest added in v1.1.0

func (session *Session) SetMaxlenRest()

set the negotiated message length based on session capabilities

func (*Session) SetQuitMessage added in v1.1.0

func (sd *Session) SetQuitMessage(message string) (set bool)

sets the session quit message, if there isn't one already

func (*Session) SetResumeID added in v1.1.0

func (session *Session) SetResumeID(resumeID string)

type SessionData added in v1.1.0

type SessionData struct {
	// contains filtered or unexported fields
}

type SnoManager added in v0.8.0

type SnoManager struct {
	// contains filtered or unexported fields
}

SnoManager keeps track of which clients to send snomasks to.

func (*SnoManager) AddMasks added in v0.8.0

func (m *SnoManager) AddMasks(client *Client, masks ...sno.Mask)

AddMasks adds the given snomasks to the client.

func (*SnoManager) Initialize added in v1.1.0

func (m *SnoManager) Initialize()

func (*SnoManager) RemoveClient added in v0.8.0

func (m *SnoManager) RemoveClient(client *Client)

RemoveClient removes the given client from all of our lists.

func (*SnoManager) RemoveMasks added in v0.8.0

func (m *SnoManager) RemoveMasks(client *Client, masks ...sno.Mask)

RemoveMasks removes the given snomasks from the client.

func (*SnoManager) Send added in v0.8.0

func (m *SnoManager) Send(mask sno.Mask, content string)

Send sends the given snomask to all users signed up for it.

func (*SnoManager) String added in v0.8.0

func (m *SnoManager) String(client *Client) string

String returns the snomasks currently enabled.

type Socket

type Socket struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Socket represents an IRC socket.

func NewSocket

func NewSocket(conn net.Conn, maxReadQBytes int, maxSendQBytes int) *Socket

NewSocket returns a new Socket.

func (*Socket) BlockingWrite added in v1.0.0

func (socket *Socket) BlockingWrite(data []byte) (err error)

BlockingWrite sends the given string out of Socket. Requirements:

  1. MUST block until the message is sent
  2. MUST bypass sendq (calls to BlockingWrite cannot, on their own, cause a sendq overflow)
  3. MUST provide mutual exclusion for socket.conn.Write
  4. MUST respect the same ordering guarantees as Write (i.e., if a call to Write that sends message m1 happens-before a call to BlockingWrite that sends message m2, m1 must be sent on the wire before m2

Callers MUST be writing to the client's socket from the client's own goroutine; other callers must use the nonblocking Write call instead. Otherwise, a client with a slow/unreliable connection risks stalling the progress of the system as a whole.

func (*Socket) CertFP

func (socket *Socket) CertFP() (string, error)

CertFP returns the fingerprint of the certificate provided by the client.

func (*Socket) Close

func (socket *Socket) Close()

Close stops a Socket from being able to send/receive any more data.

func (*Socket) IsClosed added in v0.8.0

func (socket *Socket) IsClosed() bool

IsClosed returns whether the socket is closed.

func (*Socket) Read

func (socket *Socket) Read() (string, error)

Read returns a single IRC line from a Socket.

func (*Socket) SetFinalData added in v0.8.0

func (socket *Socket) SetFinalData(data []byte)

SetFinalData sets the final data to send when the SocketWriter closes.

func (*Socket) Write

func (socket *Socket) Write(data []byte) (err error)

Write sends the given string out of Socket. Requirements: 1. MUST NOT block for macroscopic amounts of time 2. MUST NOT reorder messages 3. MUST provide mutual exclusion for socket.conn.Write 4. SHOULD NOT tie up additional goroutines, beyond the one blocked on socket.conn.Write

type Stats added in v0.12.0

type Stats struct {
	sync.RWMutex

	Total     int
	Invisible int
	Operators int
}

Stats contains the numbers of total, invisible and operators on the server

func (*Stats) ChangeInvisible added in v0.12.0

func (s *Stats) ChangeInvisible(i int)

ChangeInvisible increments the invisible count

func (*Stats) ChangeOperators added in v0.12.0

func (s *Stats) ChangeOperators(i int)

ChangeOperators increases the operator count

func (*Stats) ChangeTotal added in v0.12.0

func (s *Stats) ChangeTotal(i int)

ChangeTotal increments the total user count on server

func (*Stats) GetStats added in v0.12.0

func (s *Stats) GetStats() (int, int, int)

GetStats retrives total, invisible and oper count

type TLSListenConfig

type TLSListenConfig struct {
	Cert string
	Key  string
}

TLSListenConfig defines configuration options for listening on TLS.

func (*TLSListenConfig) Config

func (conf *TLSListenConfig) Config() (*tls.Config, error)

Config returns the TLS contiguration assicated with this TLSListenConfig.

type TimerState added in v0.10.0

type TimerState uint
const (
	TimerUnregistered TimerState = iota // client is unregistered
	TimerActive                         // client is actively sending commands
	TimerIdle                           // client is idle, we sent PING and are waiting for PONG
	TimerDead                           // client was terminated
)

type TorListenersConfig added in v1.1.0

type TorListenersConfig struct {
	Listeners                 []string
	RequireSasl               bool `yaml:"require-sasl"`
	Vhost                     string
	MaxConnections            int           `yaml:"max-connections"`
	ThrottleDuration          time.Duration `yaml:"throttle-duration"`
	MaxConnectionsPerDuration int           `yaml:"max-connections-per-duration"`
}

type UserMaskSet

type UserMaskSet struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

UserMaskSet holds a set of client masks and lets you match hostnames to them.

func NewUserMaskSet

func NewUserMaskSet() *UserMaskSet

NewUserMaskSet returns a new UserMaskSet.

func (*UserMaskSet) Add

func (set *UserMaskSet) Add(mask string) (added bool)

Add adds the given mask to this set.

func (*UserMaskSet) AddAll

func (set *UserMaskSet) AddAll(masks []string) (added bool)

AddAll adds the given masks to this set.

func (*UserMaskSet) Length added in v0.10.1

func (set *UserMaskSet) Length() int

func (*UserMaskSet) Match

func (set *UserMaskSet) Match(userhost string) bool

Match matches the given n!u@h.

func (*UserMaskSet) Remove

func (set *UserMaskSet) Remove(mask string) (removed bool)

Remove removes the given mask from this set.

func (*UserMaskSet) String

func (set *UserMaskSet) String() string

String returns the masks in this set.

type VHostConfig added in v0.12.0

type VHostConfig struct {
	Enabled        bool
	MaxLength      int    `yaml:"max-length"`
	ValidRegexpRaw string `yaml:"valid-regexp"`
	ValidRegexp    *regexp.Regexp
	UserRequests   struct {
		Enabled  bool
		Channel  string
		Cooldown time.Duration
	} `yaml:"user-requests"`
}

type VHostInfo added in v0.12.0

type VHostInfo struct {
	ApprovedVHost   string
	Enabled         bool
	RequestedVHost  string
	RejectedVHost   string
	RejectionReason string
	LastRequestTime time.Time
}

represents someone's status in hostserv

type WhoWas

type WhoWas struct {
	// contains filtered or unexported fields
}

WhoWas is the subset of client details needed to answer a WHOWAS query

type WhoWasList

type WhoWasList struct {
	// contains filtered or unexported fields
}

WhoWasList holds our list of prior clients (for use with the WHOWAS command).

func (*WhoWasList) Append

func (list *WhoWasList) Append(whowas WhoWas)

Append adds an entry to the WhoWasList.

func (*WhoWasList) Find

func (list *WhoWasList) Find(nickname string, limit int) (results []WhoWas)

Find tries to find an entry in our WhoWasList with the given details.

func (*WhoWasList) Initialize added in v1.1.0

func (list *WhoWasList) Initialize(size int)

NewWhoWasList returns a new WhoWasList

Directories

Path Synopsis
Package sno holds Server Notice masks for easy reference.
Package sno holds Server Notice masks for easy reference.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL