irc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2016 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IDLE_TIMEOUT        = time.Minute + time.Second*30 // how long before a client is considered idle
	QUIT_TIMEOUT        = time.Minute                  // how long after idle before a client is kicked
	IdentTimeoutSeconds = 8
)
View Source
const (
	SEM_VER       = "0.1.0"
	CRLF          = "\r\n"
	MAX_REPLY_LEN = 512 - len(CRLF)
)
View Source
const (
	RPL_WELCOME                     = "001"
	RPL_YOURHOST                    = "002"
	RPL_CREATED                     = "003"
	RPL_MYINFO                      = "004"
	RPL_ISUPPORT                    = "005"
	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_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"
	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"
)

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 (
	ErrNickMissing      = errors.New("nick missing")
	ErrNicknameInUse    = errors.New("nickname in use")
	ErrNicknameMismatch = errors.New("nickname mismatch")
)
View Source
var (
	SupportedChannelModes = ChannelModes{
		BanMask, ExceptMask, InviteMask, InviteOnly, Key, NoOutside,
		OpOnlyTopic, Persistent, Secret, UserLimit,
	}

	DefaultChannelModes = ChannelModes{
		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 = ChannelModes{
		ChannelFounder, ChannelAdmin, ChannelOperator, Halfop,
	}

	ChannelModePrefixes = map[ChannelMode]string{
		ChannelFounder:  "~",
		ChannelAdmin:    "&",
		ChannelOperator: "@",
		Halfop:          "%",
		Voice:           "+",
	}
)
View Source
var (
	ChannelNameExpr = regexp.MustCompile("^$")
	NicknameExpr    = regexp.MustCompile("^$")
)
View Source
var Commands = map[string]Command{
	"AUTHENTICATE": {
		// contains filtered or unexported fields
	},
	"AWAY": {
		// contains filtered or unexported fields
	},
	"CAP": {
		// contains filtered or unexported fields
	},
	"DEBUG": {
		// 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
	},
	"LIST": {
		// contains filtered or unexported fields
	},
	"MODE": {
		// contains filtered or unexported fields
	},
	"MOTD": {
		// contains filtered or unexported fields
	},
	"NAMES": {
		// contains filtered or unexported fields
	},
	"NICK": {
		// contains filtered or unexported fields
	},
	"NOTICE": {
		// 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
	},
	"SANICK": {
		// contains filtered or unexported fields
	},
	"QUIT": {
		// contains filtered or unexported fields
	},
	"REG": {
		// contains filtered or unexported fields
	},
	"TIME": {
		// contains filtered or unexported fields
	},
	"TOPIC": {
		// contains filtered or unexported fields
	},
	"USER": {
		// contains filtered or unexported fields
	},
	"VERSION": {
		// 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 (
	EmptyPasswordError = errors.New("empty password")
)
View Source
var (
	Log = NewLogging("warn")
)
View Source
var (
	SupportedUserModes = UserModes{
		Away, Invisible, Operator,
	}
)
View Source
var (
	TIMEOUT_STATED_SECONDS = strconv.Itoa(int((IDLE_TIMEOUT + QUIT_TIMEOUT).Seconds()))
)
View Source
var (
	VER = fmt.Sprintf("oragono-%s", SEM_VER)
)

Functions

func ComparePassword

func ComparePassword(hash, password []byte) error

func DecodePassword

func DecodePassword(encoded string) (decoded []byte, err error)

func GenerateEncodedPassword

func GenerateEncodedPassword(passwd string) (encoded string, err error)

func InitDB

func InitDB(path string)

InitDB creates the database.

func IsHostname

func IsHostname(name string) bool

func NewLogger

func NewLogger(on bool) *log.Logger

func NewSalt

func NewSalt() ([]byte, error)

NewSalt returns a salt for crypto uses.

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
}

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"`
		}
	}
}

type CapModifier

type CapModifier rune

CapModifiers are indicators showing the state of a capability after a REQ or ACK.

const (
	Ack     CapModifier = '~'
	Disable CapModifier = '-'
	Sticky  CapModifier = '='
)

func (CapModifier) String

func (mod CapModifier) String() string

type CapState

type CapState uint
const (
	CapNone        CapState = iota
	CapNegotiating CapState = iota
	CapNegotiated  CapState = iota
)

type Capability

type Capability string

Capabilities are optional features a client may request from a server.

const (
	AccountTag      Capability = "account-tag"
	AwayNotify      Capability = "away-notify"
	ExtendedJoin    Capability = "extended-join"
	MultiPrefix     Capability = "multi-prefix"
	SASL            Capability = "sasl"
	ServerTime      Capability = "server-time"
	UserhostInNames Capability = "userhost-in-names"
)

func (Capability) String

func (capability Capability) String() string

type CapabilitySet

type CapabilitySet map[Capability]bool

func (CapabilitySet) DisableString

func (set CapabilitySet) DisableString() string

func (CapabilitySet) String

func (set CapabilitySet) String() string

type Channel

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

func NewChannel

func NewChannel(s *Server, name Name, addDefaultModes bool) *Channel

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

func (*Channel) CanSpeak

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

func (*Channel) CheckKey

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

func (*Channel) ClientIsOperator

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

func (*Channel) GetTopic

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

func (*Channel) Id

func (channel *Channel) Id() Name

func (*Channel) Invite

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

func (*Channel) IsEmpty

func (channel *Channel) IsEmpty() bool

func (*Channel) IsFull

func (channel *Channel) IsFull() bool

func (*Channel) Join

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

func (*Channel) Kick

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

func (*Channel) ModeString

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

<mode> <mode params>

func (*Channel) Names

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

func (*Channel) Nick

func (channel *Channel) Nick() Name

func (*Channel) Nicks

func (channel *Channel) Nicks(target *Client) []string

func (*Channel) Notice

func (channel *Channel) Notice(client *Client, message string)

func (*Channel) Part

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

func (*Channel) Persist

func (channel *Channel) Persist() (err error)

func (*Channel) PrivMsg

func (channel *Channel) PrivMsg(client *Client, message string)

func (*Channel) Quit

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

func (*Channel) SetTopic

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

func (*Channel) ShowMaskList

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

func (*Channel) String

func (channel *Channel) String() string

type ChannelMode

type ChannelMode rune

channel mode flags

const (
	ChannelFounder  ChannelMode = 'q' // arg
	ChannelAdmin    ChannelMode = 'a' // arg
	ChannelOperator ChannelMode = 'o' // arg
	Halfop          ChannelMode = 'h' // arg
	Voice           ChannelMode = 'v' // arg

	BanMask     ChannelMode = 'b' // arg
	ExceptMask  ChannelMode = 'e' // arg
	InviteMask  ChannelMode = 'I' // arg
	InviteOnly  ChannelMode = 'i' // flag
	Key         ChannelMode = 'k' // flag arg
	Moderated   ChannelMode = 'm' // flag
	NoOutside   ChannelMode = 'n' // flag
	OpOnlyTopic ChannelMode = 't' // flag
	Persistent  ChannelMode = 'P' // flag
	ReOp        ChannelMode = 'r' // flag
	Secret      ChannelMode = 's' // flag
	UserLimit   ChannelMode = 'l' // flag arg
)

func (ChannelMode) String

func (mode ChannelMode) String() string

type ChannelModeChange

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

func (*ChannelModeChange) String

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

type ChannelModeChanges

type ChannelModeChanges []*ChannelModeChange

func (ChannelModeChanges) String

func (changes ChannelModeChanges) String() string

type ChannelModeCommand

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

type ChannelModeSet

type ChannelModeSet map[ChannelMode]bool

func (ChannelModeSet) Prefixes

func (modes ChannelModeSet) Prefixes(isMultiPrefix bool) string

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

func (ChannelModeSet) String

func (set ChannelModeSet) String() string

type ChannelModes

type ChannelModes []ChannelMode

func (ChannelModes) String

func (modes ChannelModes) String() string

type ChannelNameMap

type ChannelNameMap map[Name]*Channel

func (ChannelNameMap) Add

func (channels ChannelNameMap) Add(channel *Channel) error

func (ChannelNameMap) Get

func (channels ChannelNameMap) Get(name Name) *Channel

func (ChannelNameMap) Remove

func (channels ChannelNameMap) Remove(channel *Channel) error

type ChannelSet

type ChannelSet map[*Channel]bool

func (ChannelSet) Add

func (channels ChannelSet) Add(channel *Channel)

func (ChannelSet) First

func (channels ChannelSet) First() *Channel

func (ChannelSet) Remove

func (channels ChannelSet) Remove(channel *Channel)

type Client

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

func NewClient

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

func (*Client) Active

func (client *Client) Active()

func (*Client) ChangeNickname

func (client *Client) ChangeNickname(nickname Name)

func (*Client) Friends

func (client *Client) Friends() ClientSet

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

func (*Client) HasNick

func (client *Client) HasNick() bool

func (*Client) HasUsername

func (client *Client) HasUsername() bool

func (*Client) Id

func (c *Client) Id() Name

func (*Client) Idle

func (client *Client) Idle()

func (*Client) IdleSeconds

func (client *Client) IdleSeconds() uint64

func (*Client) IdleTime

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

func (*Client) ModeString

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

<mode>

func (*Client) Nick

func (c *Client) Nick() Name

func (*Client) Notice

func (client *Client) Notice(text string)

Notice sends the client a notice from the server.

func (*Client) Quit

func (client *Client) Quit(message string)

func (*Client) Register

func (client *Client) Register()

func (*Client) Reply

func (client *Client) Reply(reply string) error

func (*Client) RplISupport

func (client *Client) RplISupport()

func (*Client) RplList

func (target *Client) RplList(channel *Channel)

func (*Client) RplWhoReply

func (target *Client) RplWhoReply(channel *Channel, client *Client)

<channel> <user> <host> <server> <nick> ( "H" / "G" ) ["*"] [ ( "@" / "+" ) ] :<hopcount> <real name>

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(from *Client, tags *map[string]ircmsg.TagValue, prefix string, 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) SetNickname

func (client *Client) SetNickname(nickname Name)

func (*Client) SignonTime

func (client *Client) SignonTime() int64

func (*Client) String

func (c *Client) String() string

func (*Client) Touch

func (client *Client) Touch()

func (*Client) UserHost

func (c *Client) UserHost() Name

func (*Client) WhoisChannelsNames

func (client *Client) WhoisChannelsNames(target *Client) []string

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

func NewClientLookupSet

func NewClientLookupSet() *ClientLookupSet

func (*ClientLookupSet) Add

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

func (*ClientLookupSet) Find

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

func (*ClientLookupSet) FindAll

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

func (*ClientLookupSet) Get

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

func (*ClientLookupSet) Remove

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

type ClientSet

type ClientSet map[*Client]bool

func (ClientSet) Add

func (clients ClientSet) Add(client *Client)

func (ClientSet) Has

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

func (ClientSet) Remove

func (clients ClientSet) Remove(client *Client)

type ClientSocket

type ClientSocket struct {
	ReceiveEvents chan Message
	SendLines     chan string
	// contains filtered or unexported fields
}

ClientSocket listens to a socket using the IRC protocol, processes events, and also sends IRC lines out of that socket.

func NewClientSocket

func NewClientSocket(conn net.Conn, client Client) ClientSocket

NewClientSocket returns a new ClientSocket.

func (*ClientSocket) RunEvents

func (cs *ClientSocket) RunEvents()

RunEvents handles received IRC lines and processes incoming commands.

func (*ClientSocket) RunSocketListener

func (cs *ClientSocket) RunSocketListener()

RunSocketListener receives lines from the IRC socket.

func (*ClientSocket) RunSocketSender

func (cs *ClientSocket) RunSocketSender()

RunSocketSender sends lines to the IRC socket.

func (*ClientSocket) Send

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

Send sends an IRC line to the listener.

func (*ClientSocket) Start

func (cs *ClientSocket) Start()

Start creates and starts running the necessary event loops.

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
		Wslisten         string                      `yaml:"ws-listen"`
		TLSListeners     map[string]*TLSListenConfig `yaml:"tls-listeners"`
		CheckIdent       bool                        `yaml:"check-ident"`
		Log              string
		MOTD             string
		ProxyAllowedFrom []string `yaml:"proxy-allowed-from"`
	}

	Datastore struct {
		Path string
	}

	Registration struct {
		Accounts AccountRegistrationConfig
	}

	Operator map[string]*PassConfig

	Limits struct {
		NickLen       int  `yaml:"nicklen"`
		ChannelLen    int  `yaml:"channellen"`
		AwayLen       int  `yaml:"awaylen"`
		KickLen       int  `yaml:"kicklen"`
		TopicLen      int  `yaml:"topiclen"`
		WhowasEntries uint `yaml:"whowas-entries"`
	}
}

func LoadConfig

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

func (*Config) Operators

func (conf *Config) Operators() map[Name][]byte

func (*Config) TLSListeners

func (conf *Config) TLSListeners() map[Name]*tls.Config

type ISupportList

type ISupportList struct {
	Tokens      map[string]*string
	CachedReply [][]string
}

ISupportList holds a list of ISUPPORT tokens

func NewISupportList

func NewISupportList() *ISupportList

NewISupportList returns a new ISupportList

func (*ISupportList) Add

func (il *ISupportList) Add(name string, value string)

Add adds an RPL_ISUPPORT token to our internal list

func (*ISupportList) AddNoValue

func (il *ISupportList) AddNoValue(name string)

AddNoValue adds an RPL_ISUPPORT token that does not have a value

func (*ISupportList) RegenerateCachedReply

func (il *ISupportList) RegenerateCachedReply()

RegenerateCachedReply regenerates the cached RPL_ISUPPORT reply

type Identifiable

type Identifiable interface {
	Id() Name
	Nick() Name
}

type Limits

type Limits struct {
	AwayLen  int
	KickLen  int
	TopicLen int
}

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

type Logging

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

func NewLogging

func NewLogging(level string) *Logging

func (*Logging) SetLevel

func (logging *Logging) SetLevel(level string)

type MemberSet

type MemberSet map[*Client]ChannelModeSet

func (MemberSet) Add

func (members MemberSet) Add(member *Client)

func (MemberSet) AnyHasMode

func (members MemberSet) AnyHasMode(mode ChannelMode) bool

func (MemberSet) Has

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

func (MemberSet) HasMode

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

func (MemberSet) Remove

func (members MemberSet) Remove(member *Client)

type Message

type Message struct {
	Type MessageType
	Verb MessageVerb
	Info map[MessageInfoKey]interface{}
}

Message represents an internal message passed by oragono.

func NewMessage

func NewMessage(mt MessageType, mv MessageVerb) Message

NewMessage returns a new Message. This is purely a convenience function.

type MessageInfoKey

type MessageInfoKey int

MessageInfoKey represents a key in the Info attribute of a Message.

const (
	// LineIK represents an IRC line message info key
	LineIK MessageInfoKey = iota
)

type MessageType

type MessageType int

MessageType represents the type of message it is.

const (
	// LineMT represents an IRC line Message Type
	LineMT MessageType = iota
)

type MessageVerb

type MessageVerb int

MessageVerb represents the verb (i.e. the specific command, etc) of a message.

const (
	// NoMV represents no Message Verb
	NoMV MessageVerb = iota
)

type ModeChange

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

func (*ModeChange) String

func (change *ModeChange) String() string

type ModeChanges

type ModeChanges []*ModeChange

func (ModeChanges) String

func (changes ModeChanges) String() string

type ModeOp

type ModeOp rune
const (
	Add    ModeOp = '+'
	List   ModeOp = '='
	Remove ModeOp = '-'
)

func (ModeOp) String

func (op ModeOp) String() string

type Name

type Name string

Names are normalized and canonicalized to remove formatting marks and simplify usage. They are things like hostnames and usermasks.

func AddrLookupHostname

func AddrLookupHostname(addr net.Addr) Name

func ExpandUserHost

func ExpandUserHost(userhost Name) (expanded Name)

func IPString

func IPString(addr net.Addr) Name

func LookupHostname

func LookupHostname(addr Name) Name

func NewName

func NewName(str string) Name

func NewNames

func NewNames(strs []string) []Name

func (Name) IsChannel

func (name Name) IsChannel() bool

func (Name) IsNickname

func (name Name) IsNickname() bool

func (Name) String

func (name Name) String() string

func (Name) Text

func (name Name) Text() Text

It's safe to coerce a Name to Text. Name is a strict subset of Text.

func (Name) ToLower

func (name Name) ToLower() Name

type PassConfig

type PassConfig struct {
	Password string
}

func (*PassConfig) PasswordBytes

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

type PasswordManager

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

PasswordManager supports the hashing and comparing of passwords with the given salt.

func NewPasswordManager

func NewPasswordManager(salt []byte) PasswordManager

NewPasswordManager returns a new PasswordManager with the given salt.

func (*PasswordManager) CompareHashAndPassword

func (pwm *PasswordManager) CompareHashAndPassword(hashedPassword []byte, specialSalt []byte, password string) error

CompareHashAndPassword compares a hashed password with its possible plaintext equivalent. Returns nil on success, or an error on failure.

func (*PasswordManager) GenerateFromPassword

func (pwm *PasswordManager) GenerateFromPassword(specialSalt []byte, password string) ([]byte, error)

GenerateFromPassword encrypts the given password.

type Server

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

func NewServer

func NewServer(config *Config) *Server

func (*Server) Id

func (s *Server) Id() Name

func (*Server) MOTD

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

func (*Server) Nick

func (s *Server) Nick() Name

func (*Server) Run

func (server *Server) Run()

func (*Server) Shutdown

func (server *Server) Shutdown()

func (*Server) String

func (s *Server) String() string

type Socket

type Socket struct {
	Closed bool
	// contains filtered or unexported fields
}

Socket represents an IRC socket.

func NewSocket

func NewSocket(conn net.Conn) 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) Read

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

Read returns a single IRC line from a Socket.

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

Certificate returns the TLS certificate assicated with this TLSListenConfig

type Text

type Text string

Text is PRIVMSG, NOTICE, or TOPIC data. It's canonicalized UTF8 data to simplify but keeps all formatting.

func NewText

func NewText(str string) Text

func (Text) String

func (text Text) String() string

type UserMaskSet

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

TODO(dan): move this over to generally using glob syntax instead? kinda more expected in normal ban/etc masks, though regex is useful (probably as an extban?)

func NewUserMaskSet

func NewUserMaskSet() *UserMaskSet

func (*UserMaskSet) Add

func (set *UserMaskSet) Add(mask Name) bool

func (*UserMaskSet) AddAll

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

func (*UserMaskSet) Match

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

func (*UserMaskSet) Remove

func (set *UserMaskSet) Remove(mask Name) bool

func (*UserMaskSet) String

func (set *UserMaskSet) String() string

type UserMode

type UserMode rune

user mode flags

const (
	Away          UserMode = 'a'
	Invisible     UserMode = 'i'
	LocalOperator UserMode = 'O'
	Operator      UserMode = 'o'
	Restricted    UserMode = 'r'
	ServerNotice  UserMode = 's' // deprecated
	TLS           UserMode = 'Z'
	WallOps       UserMode = 'w'
)

func (UserMode) String

func (mode UserMode) String() string

type UserModes

type UserModes []UserMode

func (UserModes) String

func (modes UserModes) String() string

type WSContainer

type WSContainer struct {
	*websocket.Conn
}

func (WSContainer) Read

func (this WSContainer) Read(msg []byte) (int, error)

func (WSContainer) SetDeadline

func (this WSContainer) SetDeadline(t time.Time) error

func (WSContainer) Write

func (this WSContainer) Write(msg []byte) (int, error)

type WhoWas

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

type WhoWasList

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

func NewWhoWasList

func NewWhoWasList(size uint) *WhoWasList

func (*WhoWasList) Append

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

func (*WhoWasList) Each

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

Iterate the buffer in reverse.

func (*WhoWasList) Find

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

Jump to

Keyboard shortcuts

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