irc

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2017 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RegisterTimeout is how long clients have to register before we disconnect them
	RegisterTimeout = time.Minute
	// IdleTimeout is how long without traffic before a registered client is considered idle.
	IdleTimeout = time.Minute + time.Second*30
	// QuitTimeout is how long without traffic before an idle client is disconnected
	QuitTimeout = time.Minute
)
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_NOTOPIC                     = "331"
	RPL_TOPIC                       = "332"
	RPL_TOPICTIME                   = "333"
	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_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_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_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_REGISTRATION_SUCCESS        = "920"
	ERR_ACCOUNT_ALREADY_EXISTS      = "921"
	ERR_REG_UNSPECIFIED_ERROR       = "922"
	RPL_VERIFYSUCCESS               = "923"
	ERR_ACCOUNT_ALREADY_VERIFIED    = "924"
	ERR_ACCOUNT_INVALID_VERIFY_CODE = "925"
	RPL_REG_VERIFICATION_REQUIRED   = "927"
	ERR_REG_INVALID_CRED_TYPE       = "928"
	ERR_REG_INVALID_CALLBACK        = "929"
)
View Source
const (
	// IdentTimeoutSeconds is how many seconds before our ident (username) check times out.
	IdentTimeoutSeconds = 1.5
)
View Source
const (
	// SemVer is the semantic version of Oragono.
	SemVer = "0.10.1"
)

Variables

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) bool{
		"PLAIN":    authPlainHandler,
		"EXTERNAL": authExternalHandler,
	}

	// NoAccount is a placeholder which means that the user is not logged into an account.
	NoAccount = ClientAccount{
		Name: "*",
	}
)
View Source
var (
	// SupportedCapabilities are the caps we advertise.
	// MaxLine, SASL and STS are set during server startup.
	SupportedCapabilities = caps.NewSet(caps.AccountTag, caps.AccountNotify, caps.AwayNotify, caps.CapNotify, caps.ChgHost, caps.EchoMessage, caps.ExtendedJoin, caps.InviteNotify, caps.MessageTags, caps.MultiPrefix, caps.Rename, caps.ServerTime, caps.UserhostInNames)

	// CapValues are the actual values we advertise to v3.2 clients.
	// actual values are set during server startup.
	CapValues = caps.NewValues()
)
View Source
var (
	InvalidChannelName = errors.New("Invalid channel name")
	NoSuchChannel      = errors.New("No such channel")
	ChannelNameInUse   = errors.New("Channel name in use")
)
View Source
var (
	ErrNickMissing      = errors.New("nick missing")
	ErrNicknameInUse    = errors.New("nickname in use")
	ErrNicknameMismatch = errors.New("nickname mismatch")
)
View Source
var (
	ChannelFounder  Mode = 'q' // arg
	ChannelAdmin    Mode = 'a' // arg
	ChannelOperator Mode = 'o' // arg
	Halfop          Mode = 'h' // arg
	Voice           Mode = 'v' // arg

	// SupportedChannelModes are the channel modes that we support.
	SupportedChannelModes = Modes{
		BanMask, ChanRoleplaying, ExceptMask, InviteMask, InviteOnly, Key,
		Moderated, NoOutside, OpOnlyTopic, RegisteredOnly, Secret, UserLimit,
	}

	// 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{
		NoOutside, OpOnlyTopic,
	}

	// ChannelPrivModes holds the list of modes that are privileged, ie founder/op/halfop, in order.
	// voice is not in this list because it cannot perform channel operator actions.
	ChannelPrivModes = Modes{
		ChannelFounder, ChannelAdmin, ChannelOperator, Halfop,
	}

	ChannelModePrefixes = map[Mode]string{
		ChannelFounder:  "~",
		ChannelAdmin:    "&",
		ChannelOperator: "@",
		Halfop:          "%",
		Voice:           "+",
	}
)
View Source
var Commands = map[string]Command{
	"ACC": {
		// contains filtered or unexported fields
	},
	"AMBIANCE": {
		// contains filtered or unexported fields
	},
	"AUTHENTICATE": {
		// contains filtered or unexported fields
	},
	"AWAY": {
		// contains filtered or unexported fields
	},
	"CAP": {
		// contains filtered or unexported fields
	},
	"CHANSERV": {
		// 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
	},
	"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
	},
	"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
	},
	"PROXY": {
		// contains filtered or unexported fields
	},
	"RENAME": {
		// contains filtered or unexported fields
	},
	"SANICK": {
		// contains filtered or unexported fields
	},
	"SAMODE": {
		// contains filtered or unexported fields
	},
	"SCENE": {
		// contains filtered or unexported fields
	},
	"TAGMSG": {
		// contains filtered or unexported fields
	},
	"QUIT": {
		// contains filtered or unexported fields
	},
	"REHASH": {
		// 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
	},
}

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

View Source
var ErrMonitorLimitExceeded = errors.New("Monitor limit exceeded")

ErrMonitorLimitExceeded is used when the monitor list exceeds our limit.

View Source
var (
	// ErrNickAlreadySet is a weird error that's sent when the server's consistency has been compromised.
	ErrNickAlreadySet = errors.New("Nickname is already set")
)
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
	},
	"cap": {
		// contains filtered or unexported fields
	},
	"chanserv": {
		// 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
	},
	"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
	},
	"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
	},
	"proxy": {
		// contains filtered or unexported fields
	},
	"rename": {
		// contains filtered or unexported fields
	},
	"sanick": {
		// contains filtered or unexported fields
	},
	"samode": {
		// contains filtered or unexported fields
	},
	"scene": {
		// contains filtered or unexported fields
	},
	"tagmsg": {
		// contains filtered or unexported fields
	},
	"quit": {
		// contains filtered or unexported fields
	},
	"rehash": {
		// 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
	},

	"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 HelpIndex string

HelpIndex contains the list of all help topics for regular users.

View Source
var HelpIndexOpers string

HelpIndexOpers contains the list of all help topics for opers.

View Source
var (
	RenamePrivsNeeded = errors.New("Only chanops can rename channels")
)
View Source
var (
	// ServerExitSignals are the signals the server will exit on.
	ServerExitSignals = []os.Signal{
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT,
	}
)
View Source
var (
	// SupportedUserModes are the user modes that we actually support (modifying).
	SupportedUserModes = Modes{
		Away, Invisible, Operator, RegisteredOnly, ServerNotice, UserRoleplaying,
	}
)
View Source
var (
	// Ver is the full version of Oragono, used in responses to clients.
	Ver = fmt.Sprintf("oragono-%s", SemVer)
)

Functions

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(forOpers bool) string

GenerateHelpIndex is used to generate HelpIndex.

func GenerateHelpIndices added in v0.10.0

func GenerateHelpIndices() error

GenerateHelpIndices generates our help indexes and confirms we have HELP entries for every command.

func GetClientOnlyTags added in v0.2.0

func GetClientOnlyTags(tags map[string]ircmsg.TagValue) *map[string]ircmsg.TagValue

GetClientOnlyTags takes a tag map and returns a map containing just the client-only tags from it.

func InitDB

func InitDB(path string)

InitDB creates the database.

func OpenDatabase added in v0.10.0

func OpenDatabase(path string) (*buntdb.DB, error)

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

func SplitChannelMembershipPrefixes added in v0.3.0

func SplitChannelMembershipPrefixes(target string) (prefixes string, name string)

SplitChannelMembershipPrefixes takes a target and returns the prefixes on it, then the name.

func UpgradeDB

func UpgradeDB(path string)

UpgradeDB upgrades the datastore to the latest schema.

Types

type AccountCredentials

type AccountCredentials struct {
	PassphraseSalt []byte
	PassphraseHash []byte
	Certificate    string // fingerprint
}

AccountCredentials stores the various methods for verifying accounts.

type AccountRegistration

type AccountRegistration struct {
	Enabled                    bool
	EnabledCallbacks           []string
	EnabledCredentialTypes     []string
	AllowMultiplePerConnection bool
}

AccountRegistration manages the registration of accounts.

func NewAccountRegistration

func NewAccountRegistration(config AccountRegistrationConfig) (accountReg AccountRegistration)

NewAccountRegistration returns a new AccountRegistration, configured correctly.

type AccountRegistrationConfig

type AccountRegistrationConfig struct {
	Enabled          bool
	EnabledCallbacks []string `yaml:"enabled-callbacks"`
	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"`
		}
	}
	AllowMultiplePerConnection bool `yaml:"allow-multiple-per-connection"`
}

AccountRegistrationConfig controls account registration.

type CapState

type CapState uint

CapState shows whether we're negotiating caps, finished, etc for connection registration.

const (
	// CapNone means CAP hasn't been negotiated at all.
	CapNone CapState = iota
	// CapNegotiating means CAP is being negotiated and registration should be paused.
	CapNegotiating CapState = iota
	// CapNegotiated means CAP negotiation has been successfully ended and reg should complete.
	CapNegotiated CapState = iota
)

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, addDefaultModes 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 ModeChanges) 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) CheckKey

func (channel *Channel) CheckKey(key string) bool

CheckKey returns true if the key is not set or matches the given key.

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 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) HasMode added in v0.10.1

func (channel *Channel) HasMode(mode Mode) bool

func (*Channel) Invite

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

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

func (*Channel) IsEmpty

func (channel *Channel) IsEmpty() bool

func (*Channel) IsFull

func (channel *Channel) IsFull() bool

IsFull returns true if this channel is at its' members limit.

func (*Channel) Join

func (channel *Channel) Join(client *Client, key string)

Join joins the given client to this channel (if they can be joined). TODO(dan): /SAJOIN and maybe a ForceJoin function?

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)

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)

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)

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

func (*Channel) Quit

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

Quit removes the given client from the channel

func (*Channel) SendTopic added in v0.10.1

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

SendTopic sends the channel topic to the given client.

func (*Channel) SetTopic

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

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

func (*Channel) ShowMaskList

func (channel *Channel) ShowMaskList(client *Client, mode Mode)

ShowMaskList shows the given list to the client.

func (*Channel) SplitNotice added in v0.6.0

func (channel *Channel) SplitNotice(msgid string, minPrefix *Mode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client, message SplitMessage)

SplitNotice sends a private message to everyone in this channel.

func (*Channel) SplitPrivMsg added in v0.6.0

func (channel *Channel) SplitPrivMsg(msgid string, minPrefix *Mode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client, message SplitMessage)

SplitPrivMsg sends a private message to everyone in this channel.

func (*Channel) TagMsg added in v0.6.0

func (channel *Channel) TagMsg(msgid string, minPrefix *Mode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client)

TagMsg sends a tag message to everyone in this channel who can accept them.

func (*Channel) UserLimit added in v0.10.1

func (channel *Channel) UserLimit() uint64

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 NewChannelManager added in v0.10.1

func NewChannelManager() *ChannelManager

NewChannelManager returns a new ChannelManager.

func (*ChannelManager) Channels added in v0.10.1

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

Channels returns a slice containing all current channels

func (*ChannelManager) Get added in v0.10.1

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

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

func (*ChannelManager) Join added in v0.10.1

func (cm *ChannelManager) Join(client *Client, name string, key string) 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) 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) error

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

type ChannelRegistrationConfig added in v0.7.0

type ChannelRegistrationConfig struct {
	Enabled bool
}

ChannelRegistrationConfig controls channel registration.

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 NewClient

func NewClient(server *Server, conn net.Conn, isTLS bool) *Client

NewClient returns a client with all the appropriate info setup.

func (*Client) Active

func (client *Client) Active()

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

func (*Client) AllNickmasks added in v0.6.0

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

AllNickmasks returns all the possible nickmasks for the client.

func (*Client) ApplyProxiedIP added in v0.10.0

func (client *Client) ApplyProxiedIP(proxiedIP string, tls bool) (exiting bool)

ApplyProxiedIP applies the given IP to the client.

func (*Client) ChanServNotice added in v0.7.0

func (client *Client) ChanServNotice(text string)

ChanServNotice sends the client a notice from ChanServ.

func (*Client) ChangeNickname

func (client *Client) ChangeNickname(nickname string) error

ChangeNickname changes the existing nickname of the client.

func (*Client) Channels added in v0.10.1

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

func (*Client) Destroyed added in v0.10.0

func (client *Client) Destroyed() bool

func (*Client) Friends

func (client *Client) Friends(capabs ...caps.Capability) ClientSet

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

func (*Client) HasMode added in v0.10.1

func (client *Client) HasMode(mode 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) LoggedIntoAccount added in v0.9.1

func (client *Client) LoggedIntoAccount() bool

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

func (*Client) LoginToAccount added in v0.7.0

func (client *Client) LoginToAccount(account *ClientAccount)

LoginToAccount logs the client into the given account.

func (*Client) LogoutOfAccount added in v0.9.0

func (client *Client) LogoutOfAccount()

LogoutOfAccount logs the client out of their current 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) 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) Ping added in v0.10.0

func (client *Client) Ping()

Ping sends the client a PING message.

func (*Client) Quit

func (client *Client) Quit(message string)

Quit sets the given quit message for the client and tells the client to quit out.

func (*Client) Realname added in v0.10.1

func (client *Client) Realname() string

func (*Client) Register

func (client *Client) Register()

Register sets the client details as appropriate when entering the network.

func (*Client) Registered added in v0.10.0

func (client *Client) Registered() bool

func (*Client) RplISupport

func (client *Client) RplISupport()

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)

RplList returns the RPL_LIST numeric for the given channel.

func (*Client) Send

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

Send sends an IRC line to the client.

func (*Client) SendFromClient

func (client *Client) SendFromClient(msgid string, from *Client, tags *map[string]ircmsg.TagValue, command string, params ...string) error

SendFromClient sends an IRC line coming from a specific client. Adds account-tag to the line as well.

func (*Client) SendSplitMsgFromClient added in v0.6.0

func (client *Client) SendSplitMsgFromClient(msgid string, from *Client, tags *map[string]ircmsg.TagValue, command, target string, message SplitMessage)

SendSplitMsgFromClient sends an IRC PRIVMSG/NOTICE coming from a specific client. Adds account-tag to the line as well.

func (*Client) SetNickname

func (client *Client) SetNickname(nickname string) error

SetNickname sets the very first nickname for the client.

func (*Client) SignonTime

func (client *Client) SignonTime() int64

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

func (*Client) Touch

func (client *Client) Touch()

Touch marks the client as alive (as it it has a connection to us and we can receive messages from it).

func (*Client) Username added in v0.10.1

func (client *Client) Username() string

func (*Client) WhoisChannelsNames

func (client *Client) WhoisChannelsNames(target *Client) []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
	// Clients that are currently logged into this account (useful for notifications).
	Clients []*Client
}

ClientAccount represents a user account.

type ClientLookupSet

type ClientLookupSet struct {
	ByNickMutex sync.RWMutex
	ByNick      map[string]*Client
}

ClientLookupSet represents a way to store, search and lookup clients.

func NewClientLookupSet

func NewClientLookupSet() *ClientLookupSet

NewClientLookupSet returns a new lookup set.

func (*ClientLookupSet) Add

func (clients *ClientLookupSet) Add(client *Client, nick string) error

Add adds a client to the lookup set.

func (*ClientLookupSet) AllWithCaps added in v0.3.0

func (clients *ClientLookupSet) AllWithCaps(capabs ...caps.Capability) (set ClientSet)

AllWithCaps returns all clients with the given capabilities.

func (*ClientLookupSet) Count added in v0.5.0

func (clients *ClientLookupSet) Count() int

Count returns how many clients are in the lookup set.

func (*ClientLookupSet) Find

func (clients *ClientLookupSet) Find(userhost string) *Client

Find returns the first client that matches the given userhost mask.

func (*ClientLookupSet) FindAll

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

FindAll returns all clients that match the given userhost mask.

func (*ClientLookupSet) Get

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

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

func (*ClientLookupSet) Has added in v0.2.0

func (clients *ClientLookupSet) Has(nick string) bool

Has returns whether or not the given client exists. TODO(dan): This seems like ripe ground for a race, if code does Has then Get, and assumes the Get will return a client.

func (*ClientLookupSet) Remove

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

Remove removes a client from the lookup set.

func (*ClientLookupSet) Replace added in v0.5.0

func (clients *ClientLookupSet) Replace(oldNick, newNick string, client *Client) error

Replace renames an existing client in the lookup set.

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, msg ircmsg.IrcMessage) bool

Run runs this command with the given client/message.

type Config

type Config struct {
	Network struct {
		Name string
	}

	Server struct {
		PassConfig
		Password            string
		Name                string
		Listen              []string
		TLSListeners        map[string]*TLSListenConfig `yaml:"tls-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       uint64
		ConnectionLimiter   connection_limits.LimiterConfig   `yaml:"connection-limits"`
		ConnectionThrottler connection_limits.ThrottlerConfig `yaml:"connection-throttling"`
	}

	Datastore struct {
		Path string
	}

	Accounts struct {
		Registration          AccountRegistrationConfig
		AuthenticationEnabled bool `yaml:"authentication-enabled"`
	}

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

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

	Opers map[string]*OperConfig

	Logging []logger.LoggingConfig

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

	Limits struct {
		AwayLen        uint          `yaml:"awaylen"`
		ChanListModes  uint          `yaml:"chan-list-modes"`
		ChannelLen     uint          `yaml:"channellen"`
		KickLen        uint          `yaml:"kicklen"`
		MonitorEntries uint          `yaml:"monitor-entries"`
		NickLen        uint          `yaml:"nicklen"`
		TopicLen       uint          `yaml:"topiclen"`
		WhowasEntries  uint          `yaml:"whowas-entries"`
		LineLen        LineLenConfig `yaml:"linelen"`
	}

	Filename string
}

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

TLSListeners returns a list of TLS listeners and their configs.

type DLineManager added in v0.5.0

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

DLineManager manages and dlines.

func NewDLineManager added in v0.5.0

func NewDLineManager() *DLineManager

NewDLineManager returns a new DLineManager.

func (*DLineManager) AddIP added in v0.5.0

func (dm *DLineManager) AddIP(addr net.IP, length *IPRestrictTime, reason string, operReason string)

AddIP adds an IP address to the blocked list.

func (*DLineManager) AddNetwork added in v0.5.0

func (dm *DLineManager) AddNetwork(network net.IPNet, length *IPRestrictTime, reason string, operReason string)

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)

RemoveIP removes an IP from the blocked list.

func (*DLineManager) RemoveNetwork added in v0.5.0

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

RemoveNetwork removes a network from the blocked list.

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 = 0
	// InformationHelpEntry is a help entry explaining general server info.
	InformationHelpEntry HelpEntryType = 1
	// ISupportHelpEntry is a help entry explaining a specific RPL_ISUPPORT token.
	ISupportHelpEntry HelpEntryType = 2
)

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"`
	// Time holds details about the duration, if it exists.
	Time *IPRestrictTime `json:"time"`
}

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.

type IPRestrictTime added in v0.5.0

type IPRestrictTime struct {
	// Duration is how long this block lasts for.
	Duration time.Duration `json:"duration"`
	// Expires is when this block expires.
	Expires time.Time `json:"expires"`
}

IPRestrictTime contains the expiration info about the given IP.

func (*IPRestrictTime) IsExpired added in v0.5.0

func (iptime *IPRestrictTime) IsExpired() bool

IsExpired returns true if the time has expired.

type IdleTimer added in v0.10.0

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

func NewIdleTimer added in v0.10.0

func NewIdleTimer(client *Client) *IdleTimer

NewIdleTimer sets up a new IdleTimer using constant timeouts.

func (*IdleTimer) Start added in v0.10.0

func (it *IdleTimer) Start()

Start 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()

Touch registers activity (e.g., sending a command) from an client.

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
	// contains filtered or unexported fields
}

KLineManager manages and klines.

func NewKLineManager added in v0.6.0

func NewKLineManager() *KLineManager

NewKLineManager returns a new KLineManager.

func (*KLineManager) AddMask added in v0.6.0

func (km *KLineManager) AddMask(mask string, length *IPRestrictTime, reason string, operReason string)

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)

RemoveMask removes a mask from the blocked list.

type Limits

type Limits struct {
	AwayLen        int
	ChannelLen     int
	KickLen        int
	MonitorEntries int
	NickLen        int
	TopicLen       int
	ChanListModes  int
	LineLen        LineLenLimits
}

Limits holds the maximum limits for various things such as topic lengths.

type LineLenConfig added in v0.6.0

type LineLenConfig struct {
	Tags int
	Rest int
}

LineLenConfig controls line lengths.

type LineLenLimits added in v0.6.0

type LineLenLimits struct {
	Tags int
	Rest int
}

LineLenLimits holds the maximum limits for IRC lines.

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]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 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) HasMode

func (members MemberSet) HasMode(member *Client, mode Mode) bool

HasMode returns true if the given client is in this set with the given mode.

func (MemberSet) Remove

func (members MemberSet) Remove(member *Client)

Remove removes the given client from this set.

type Mode added in v0.7.0

type Mode rune

Mode represents a user/channel/server mode

const (
	Away            Mode = 'a'
	Invisible       Mode = 'i'
	LocalOperator   Mode = 'O'
	Operator        Mode = 'o'
	Restricted      Mode = 'r'
	RegisteredOnly  Mode = 'R'
	ServerNotice    Mode = 's'
	TLS             Mode = 'Z'
	UserRoleplaying Mode = 'E'
	WallOps         Mode = 'w'
)

User Modes

const (
	BanMask         Mode = 'b' // arg
	ChanRoleplaying Mode = 'E' // flag
	ExceptMask      Mode = 'e' // arg
	InviteMask      Mode = 'I' // arg
	InviteOnly      Mode = 'i' // flag
	Key             Mode = 'k' // flag arg
	Moderated       Mode = 'm' // flag
	NoOutside       Mode = 'n' // flag
	OpOnlyTopic     Mode = 't' // flag
	// RegisteredOnly mode is reused here from umode definition
	Secret    Mode = 's' // flag
	UserLimit Mode = 'l' // flag arg
)

Channel Modes

func GetLowestChannelModePrefix added in v0.3.0

func GetLowestChannelModePrefix(prefixes string) *Mode

GetLowestChannelModePrefix returns the lowest channel prefix mode out of the given prefixes.

func (Mode) String added in v0.7.0

func (mode Mode) String() string

type ModeChange

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

ModeChange is a single mode changing

func (*ModeChange) String

func (change *ModeChange) String() (str string)

type ModeChanges

type ModeChanges []ModeChange

ModeChanges are a collection of 'ModeChange's

func ParseChannelModeChanges added in v0.7.0

func ParseChannelModeChanges(params ...string) (ModeChanges, map[rune]bool)

ParseChannelModeChanges returns the valid changes, and the list of unknown chars.

func ParseUserModeChanges added in v0.8.0

func ParseUserModeChanges(params ...string) (ModeChanges, map[rune]bool)

ParseUserModeChanges returns the valid changes, and the list of unknown chars.

func (ModeChanges) String

func (changes ModeChanges) String() string

type ModeOp

type ModeOp rune

ModeOp is an operation performed with modes

const (
	// Add is used when adding the given key.
	Add ModeOp = '+'
	// List is used when listing modes (for instance, listing the current bans on a channel).
	List ModeOp = '='
	// Remove is used when taking away the given key.
	Remove ModeOp = '-'
)

func (ModeOp) String

func (op ModeOp) String() string

type ModeSet added in v0.7.0

type ModeSet map[Mode]bool

ModeSet holds a set of modes.

func (ModeSet) Prefixes added in v0.7.0

func (modes ModeSet) Prefixes(isMultiPrefix bool) string

Prefixes returns a list of prefixes for the given set of channel modes.

func (ModeSet) String added in v0.7.0

func (set ModeSet) String() string

String returns the modes in this set.

type Modes added in v0.7.0

type Modes []Mode

Modes is just a raw list of modes

func ParseDefaultChannelModes added in v0.9.0

func ParseDefaultChannelModes(config *Config) Modes

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

func (Modes) String added in v0.7.0

func (modes Modes) String() string

type MonitorManager added in v0.10.0

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

MonitorManager keeps track of who's monitoring which nicks.

func NewMonitorManager added in v0.10.0

func NewMonitorManager() *MonitorManager

NewMonitorManager returns a new MonitorManager.

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) 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 Oper added in v0.4.0

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

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.

func (*OperConfig) PasswordBytes added in v0.4.0

func (conf *OperConfig) PasswordBytes() []byte

PasswordBytes returns the bytes represented by the password hash.

type PassConfig

type PassConfig struct {
	Password string
}

PassConfig holds the connection password.

func (*PassConfig) PasswordBytes

func (conf *PassConfig) PasswordBytes() []byte

PasswordBytes returns the bytes represented by the password hash.

type RegisteredChannel added in v0.7.0

type RegisteredChannel struct {
	// Name of the channel.
	Name 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
	// 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 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 Server

type Server struct {
	MaxSendQBytes uint64
	// 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) DefaultChannelModes added in v0.10.1

func (server *Server) DefaultChannelModes() Modes

func (*Server) GetDefaultChannelModes added in v0.10.0

func (server *Server) GetDefaultChannelModes() Modes

GetDefaultChannelModes returns our default channel modes.

func (*Server) ISupport added in v0.10.1

func (server *Server) ISupport() *isupport.List

func (*Server) Limits added in v0.10.1

func (server *Server) Limits() Limits

func (*Server) MOTD

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

MOTD serves the Message of the Day.

func (*Server) Password added in v0.10.1

func (server *Server) Password() []byte

func (*Server) ProxyAllowedFrom added in v0.10.0

func (server *Server) ProxyAllowedFrom() []string

func (*Server) RecoverFromErrors added in v0.10.1

func (server *Server) RecoverFromErrors() bool

func (*Server) Run

func (server *Server) Run()

Run starts the server.

func (*Server) Shutdown

func (server *Server) Shutdown()

Shutdown shuts down the server.

func (*Server) WebIRCConfig added in v0.10.0

func (server *Server) WebIRCConfig() []webircConfig

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 NewSnoManager added in v0.8.0

func NewSnoManager() *SnoManager

NewSnoManager returns a new SnoManager

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) 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 {
	MaxSendQBytes uint64
	// contains filtered or unexported fields
}

Socket represents an IRC socket.

func NewSocket

func NewSocket(conn net.Conn, maxSendQBytes uint64) Socket

NewSocket returns a new Socket.

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) RunSocketWriter added in v0.7.0

func (socket *Socket) RunSocketWriter()

RunSocketWriter starts writing messages to the outgoing socket.

func (*Socket) SetFinalData added in v0.8.0

func (socket *Socket) SetFinalData(data string)

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

func (*Socket) Write

func (socket *Socket) Write(data string) error

Write sends the given string out of Socket.

func (*Socket) WriteLine

func (socket *Socket) WriteLine(line string) error

WriteLine writes the given line out of Socket.

type SplitMessage added in v0.6.0

type SplitMessage struct {
	For512     []string
	ForMaxLine string
}

SplitMessage represents a message that's been split for sending.

type StackImpactConfig added in v0.8.0

type StackImpactConfig struct {
	Enabled  bool
	AgentKey string `yaml:"agent-key"`
	AppName  string `yaml:"app-name"`
}

StackImpactConfig is the config used for StackImpact's profiling.

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
)

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) 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) 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 WhoWas

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

WhoWas is an entry in the WhoWasList.

type WhoWasList

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

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

func NewWhoWasList

func NewWhoWasList(size uint) *WhoWasList

NewWhoWasList returns a new WhoWasList

func (*WhoWasList) Append

func (list *WhoWasList) Append(client *Client)

Append adds an entry to the WhoWasList.

func (*WhoWasList) Each

func (list *WhoWasList) Each() <-chan *WhoWas

Each iterates the WhoWasList in reverse.

func (*WhoWasList) Find

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

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

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