Documentation ¶
Overview ¶
Package ircserver implements an IRC server which strictly adheres to a processing model where output is only ever generated in response to input, and only depends on state that is local to the IRC server.
That means the output of two IRC server instances will be byte-for-byte identical if you feed them exactly the same input (in the same order), which is what RobustIRC does when recovering from a raft snapshot.
Index ¶
- Variables
- func ChanToLower(channelname string) lcChan
- func IsServicesNickname(nick string) bool
- func IsValidChannel(channel string) bool
- func IsValidNickname(nick string) bool
- func NickToLower(nick string) lcNick
- type IRCServer
- func (i *IRCServer) Banned(remoteAddr string) string
- func (i *IRCServer) ChannelLimit() uint64
- func (i *IRCServer) CreateSession(id robust.Id, auth string, timestamp time.Time) error
- func (i *IRCServer) ExpireSessions() []*robust.Message
- func (i *IRCServer) GetAuth(sessionid robust.Id) (string, error)
- func (i *IRCServer) GetNick(sessionid robust.Id) string
- func (i *IRCServer) GetSession(id robust.Id) (*Session, error)
- func (i *IRCServer) GetSessions() map[robust.Id]Session
- func (i *IRCServer) LastPostMessage(sessionid robust.Id) uint64
- func (i *IRCServer) Marshal(lastIncludedIndex uint64) ([]byte, error)
- func (i *IRCServer) MaybeDeleteSession(session robust.Id)
- func (i *IRCServer) NumChannels() int
- func (i *IRCServer) NumSessions() int
- func (i *IRCServer) OriginWhitelisted(origin string) bool
- func (i *IRCServer) ProcessMessage(msg *robust.Message, ircmsg *irc.Message) *Replyctx
- func (i *IRCServer) SessionLimit() uint64
- func (i *IRCServer) SetLastProcessed(id robust.Id)
- func (i *IRCServer) ThrottleUntil(sessionid robust.Id) time.Time
- func (i *IRCServer) TrustedBridge(authHeader string) string
- func (i *IRCServer) Unmarshal(data []byte) (uint64, error)
- func (i *IRCServer) UpdateLastClientMessageID(msg *robust.Message) error
- type Replyctx
- type Session
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSessionNotYetSeen is returned when the session was not (yet?) seen on // this follower. We cannot say with confidence that it does not exist. ErrSessionNotYetSeen = errors.New("Session not yet seen") // ErrNoSuchSession is returned when the session definitely does not exist. ErrNoSuchSession = errors.New("No such session") // ErrSessionLimitReached is returned when the number of sessions exceeds the configured limit. ErrSessionLimitReached = errors.New("MaxSessions limit reached") // CursorEOF is returned by a logCursor when there are no more messages. CursorEOF = errors.New("No more messages") )
var (
Commands = make(map[string]*ircCommand)
)
Functions ¶
func ChanToLower ¶
func ChanToLower(channelname string) lcChan
ChanToLower converts a channel to lower case.
func IsServicesNickname ¶
func IsValidChannel ¶
func IsValidNickname ¶
IsValidNickname returns true if the provided nickname is valid according to RFC2812 (see https://tools.ietf.org/html/rfc2812#section-2.3.1), otherwise false.
func NickToLower ¶
func NickToLower(nick string) lcNick
NickToLower converts a nickname to lower case, following RFC2812:
Because of IRC's scandanavian origin, the characters {}| are considered to be the lower case equivalents of the characters []\, respectively. This is a critical issue when determining the equivalence of two nicknames.
Types ¶
type IRCServer ¶
type IRCServer struct { // ServerPrefix is the prefix for output messages that come from the // server, as opposed to from a client. ServerPrefix *irc.Prefix // serverCreation is the time at which the IRCServer object was created. // Used for the RPL_CREATED message. ServerCreation time.Time // Config contains the network configuration. Config config.Network ConfigMu *sync.RWMutex // contains filtered or unexported fields }
func NewIRCServer ¶
NewIRCServer returns a new IRC server.
func (*IRCServer) ChannelLimit ¶
func (*IRCServer) CreateSession ¶
CreateSession creates a new session (equivalent to an IRC connection).
func (*IRCServer) ExpireSessions ¶
ExpireSessions returns DeleteSession robust.Messages for all sessions that are older than timeout. These messages are then applied to raft.
func (*IRCServer) GetAuth ¶
GetAuth returns the authentication string of |sessionid|, a random shared secret between the RobustIRC network and the client to prevent session hijacking.
func (*IRCServer) GetNick ¶
GetNick returns the nickname of |sessionid|, or the empty string if that session does not exist.
func (*IRCServer) GetSession ¶
GetSession returns a pointer to the session specified by 'id'.
It returns ErrNoSuchSession when the session definitely does not exist (based on the timestamp), but ErrSessionNotYetSeen when the session might exist in the future, but was not yet seen on this IRC instance server (perhaps due to raft delay).
func (*IRCServer) GetSessions ¶
GetSessions returns a copy of sessions that can be used in the status handler (i.e. it goes stale, but doesn’t block other operations).
func (*IRCServer) LastPostMessage ¶
LastPostMessage returns |sessionid|’s last processed client message id and the corresponding reply (for duplicate detection).
func (*IRCServer) MaybeDeleteSession ¶
func (*IRCServer) NumChannels ¶
NumSessions returns the current number of channels.
func (*IRCServer) NumSessions ¶
NumSessions returns the current number of sessions.
func (*IRCServer) OriginWhitelisted ¶
func (*IRCServer) ProcessMessage ¶
ProcessMessage modifies state in response to 'message' and returns zero or more IRC messages in response to 'message'. These messages can then be stored for eventual retrieval by the clients by calling SendMessages.
func (*IRCServer) SessionLimit ¶
func (*IRCServer) SetLastProcessed ¶
func (*IRCServer) ThrottleUntil ¶
ThrottleUntil returns the last activity of |sessionid| or the zero time.
func (*IRCServer) TrustedBridge ¶
type Replyctx ¶
Replyctx is a reply context, i.e. information necessary when replying to an IRC message. A reply context object will be passed to all cmd* functions and the send* functions use it to keep track of the replyid for example.
type Session ¶
type Session struct { Id robust.Id Nick string Username string Realname string Channels map[lcChan]bool LastActivity time.Time LastNonPing time.Time LastSolvedCaptcha time.Time Operator bool AwayMsg string Created int64 // The (raw) password from a PASS command. Pass string Server bool RemoteAddr string // network address of the most recent message // contains filtered or unexported fields }
Source Files ¶
- cmd_away.go
- cmd_gline.go
- cmd_invite.go
- cmd_ison.go
- cmd_join.go
- cmd_kick.go
- cmd_kill.go
- cmd_knock.go
- cmd_list.go
- cmd_mode.go
- cmd_motd.go
- cmd_names.go
- cmd_nick.go
- cmd_oper.go
- cmd_part.go
- cmd_pass.go
- cmd_ping.go
- cmd_privmsg.go
- cmd_quit.go
- cmd_topic.go
- cmd_user.go
- cmd_userhost.go
- cmd_who.go
- cmd_whois.go
- commands.go
- ircserver.go
- modes.go
- scmd_invite.go
- scmd_join.go
- scmd_kick.go
- scmd_kill.go
- scmd_mode.go
- scmd_nick.go
- scmd_part.go
- scmd_ping.go
- scmd_privmsg.go
- scmd_quit.go
- scmd_svshold.go
- scmd_svsjoin.go
- scmd_svsmode.go
- scmd_svsnick.go
- scmd_svspart.go
- scmd_topic.go
- serialize.go
- server_commands.go