irc

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2014 License: MIT Imports: 24 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SEM_VER       = "ergonomadic-1.2.6"
	CRLF          = "\r\n"
	MAX_REPLY_LEN = 512 - len(CRLF)

	LOGIN_TIMEOUT = time.Minute / 2 // how long the client has to login
	IDLE_TIMEOUT  = time.Minute     // how long before a client is considered idle
	QUIT_TIMEOUT  = time.Minute     // how long after idle before a client is kicked

	// string codes
	AWAY    StringCode = "AWAY"
	CAP     StringCode = "CAP"
	DEBUG   StringCode = "DEBUG"
	ERROR   StringCode = "ERROR"
	INVITE  StringCode = "INVITE"
	ISON    StringCode = "ISON"
	JOIN    StringCode = "JOIN"
	KICK    StringCode = "KICK"
	KILL    StringCode = "KILL"
	LIST    StringCode = "LIST"
	MODE    StringCode = "MODE"
	MOTD    StringCode = "MOTD"
	NAMES   StringCode = "NAMES"
	NICK    StringCode = "NICK"
	NOTICE  StringCode = "NOTICE"
	OPER    StringCode = "OPER"
	PART    StringCode = "PART"
	PASS    StringCode = "PASS"
	PING    StringCode = "PING"
	PONG    StringCode = "PONG"
	PRIVMSG StringCode = "PRIVMSG"
	PROXY   StringCode = "PROXY"
	QUIT    StringCode = "QUIT"
	TIME    StringCode = "TIME"
	TOPIC   StringCode = "TOPIC"
	USER    StringCode = "USER"
	VERSION StringCode = "VERSION"
	WHO     StringCode = "WHO"
	WHOIS   StringCode = "WHOIS"

	// numeric codes
	RPL_WELCOME           NumericCode = 1
	RPL_YOURHOST          NumericCode = 2
	RPL_CREATED           NumericCode = 3
	RPL_MYINFO            NumericCode = 4
	RPL_BOUNCE            NumericCode = 5
	RPL_TRACELINK         NumericCode = 200
	RPL_TRACECONNECTING   NumericCode = 201
	RPL_TRACEHANDSHAKE    NumericCode = 202
	RPL_TRACEUNKNOWN      NumericCode = 203
	RPL_TRACEOPERATOR     NumericCode = 204
	RPL_TRACEUSER         NumericCode = 205
	RPL_TRACESERVER       NumericCode = 206
	RPL_TRACESERVICE      NumericCode = 207
	RPL_TRACENEWTYPE      NumericCode = 208
	RPL_TRACECLASS        NumericCode = 209
	RPL_TRACERECONNECT    NumericCode = 210
	RPL_STATSLINKINFO     NumericCode = 211
	RPL_STATSCOMMANDS     NumericCode = 212
	RPL_ENDOFSTATS        NumericCode = 219
	RPL_UMODEIS           NumericCode = 221
	RPL_SERVLIST          NumericCode = 234
	RPL_SERVLISTEND       NumericCode = 235
	RPL_STATSUPTIME       NumericCode = 242
	RPL_STATSOLINE        NumericCode = 243
	RPL_LUSERCLIENT       NumericCode = 251
	RPL_LUSEROP           NumericCode = 252
	RPL_LUSERUNKNOWN      NumericCode = 253
	RPL_LUSERCHANNELS     NumericCode = 254
	RPL_LUSERME           NumericCode = 255
	RPL_ADMINME           NumericCode = 256
	RPL_ADMINLOC1         NumericCode = 257
	RPL_ADMINLOC2         NumericCode = 258
	RPL_ADMINEMAIL        NumericCode = 259
	RPL_TRACELOG          NumericCode = 261
	RPL_TRACEEND          NumericCode = 262
	RPL_TRYAGAIN          NumericCode = 263
	RPL_AWAY              NumericCode = 301
	RPL_USERHOST          NumericCode = 302
	RPL_ISON              NumericCode = 303
	RPL_UNAWAY            NumericCode = 305
	RPL_NOWAWAY           NumericCode = 306
	RPL_WHOISUSER         NumericCode = 311
	RPL_WHOISSERVER       NumericCode = 312
	RPL_WHOISOPERATOR     NumericCode = 313
	RPL_WHOWASUSER        NumericCode = 314
	RPL_ENDOFWHO          NumericCode = 315
	RPL_WHOISIDLE         NumericCode = 317
	RPL_ENDOFWHOIS        NumericCode = 318
	RPL_WHOISCHANNELS     NumericCode = 319
	RPL_LIST              NumericCode = 322
	RPL_LISTEND           NumericCode = 323
	RPL_CHANNELMODEIS     NumericCode = 324
	RPL_UNIQOPIS          NumericCode = 325
	RPL_NOTOPIC           NumericCode = 331
	RPL_TOPIC             NumericCode = 332
	RPL_INVITING          NumericCode = 341
	RPL_SUMMONING         NumericCode = 342
	RPL_INVITELIST        NumericCode = 346
	RPL_ENDOFINVITELIST   NumericCode = 347
	RPL_EXCEPTLIST        NumericCode = 348
	RPL_ENDOFEXCEPTLIST   NumericCode = 349
	RPL_VERSION           NumericCode = 351
	RPL_WHOREPLY          NumericCode = 352
	RPL_NAMREPLY          NumericCode = 353
	RPL_LINKS             NumericCode = 364
	RPL_ENDOFLINKS        NumericCode = 365
	RPL_ENDOFNAMES        NumericCode = 366
	RPL_BANLIST           NumericCode = 367
	RPL_ENDOFBANLIST      NumericCode = 368
	RPL_ENDOFWHOWAS       NumericCode = 369
	RPL_INFO              NumericCode = 371
	RPL_MOTD              NumericCode = 372
	RPL_ENDOFINFO         NumericCode = 374
	RPL_MOTDSTART         NumericCode = 375
	RPL_ENDOFMOTD         NumericCode = 376
	RPL_YOUREOPER         NumericCode = 381
	RPL_REHASHING         NumericCode = 382
	RPL_YOURESERVICE      NumericCode = 383
	RPL_TIME              NumericCode = 391
	RPL_USERSSTART        NumericCode = 392
	RPL_USERS             NumericCode = 393
	RPL_ENDOFUSERS        NumericCode = 394
	RPL_NOUSERS           NumericCode = 395
	ERR_NOSUCHNICK        NumericCode = 401
	ERR_NOSUCHSERVER      NumericCode = 402
	ERR_NOSUCHCHANNEL     NumericCode = 403
	ERR_CANNOTSENDTOCHAN  NumericCode = 404
	ERR_TOOMANYCHANNELS   NumericCode = 405
	ERR_WASNOSUCHNICK     NumericCode = 406
	ERR_TOOMANYTARGETS    NumericCode = 407
	ERR_NOSUCHSERVICE     NumericCode = 408
	ERR_NOORIGIN          NumericCode = 409
	ERR_NORECIPIENT       NumericCode = 411
	ERR_NOTEXTTOSEND      NumericCode = 412
	ERR_NOTOPLEVEL        NumericCode = 413
	ERR_WILDTOPLEVEL      NumericCode = 414
	ERR_BADMASK           NumericCode = 415
	ERR_UNKNOWNCOMMAND    NumericCode = 421
	ERR_NOMOTD            NumericCode = 422
	ERR_NOADMININFO       NumericCode = 423
	ERR_FILEERROR         NumericCode = 424
	ERR_NONICKNAMEGIVEN   NumericCode = 431
	ERR_ERRONEUSNICKNAME  NumericCode = 432
	ERR_NICKNAMEINUSE     NumericCode = 433
	ERR_NICKCOLLISION     NumericCode = 436
	ERR_UNAVAILRESOURCE   NumericCode = 437
	ERR_USERNOTINCHANNEL  NumericCode = 441
	ERR_NOTONCHANNEL      NumericCode = 442
	ERR_USERONCHANNEL     NumericCode = 443
	ERR_NOLOGIN           NumericCode = 444
	ERR_SUMMONDISABLED    NumericCode = 445
	ERR_USERSDISABLED     NumericCode = 446
	ERR_NOTREGISTERED     NumericCode = 451
	ERR_NEEDMOREPARAMS    NumericCode = 461
	ERR_ALREADYREGISTRED  NumericCode = 462
	ERR_NOPERMFORHOST     NumericCode = 463
	ERR_PASSWDMISMATCH    NumericCode = 464
	ERR_YOUREBANNEDCREEP  NumericCode = 465
	ERR_YOUWILLBEBANNED   NumericCode = 466
	ERR_KEYSET            NumericCode = 467
	ERR_CHANNELISFULL     NumericCode = 471
	ERR_UNKNOWNMODE       NumericCode = 472
	ERR_INVITEONLYCHAN    NumericCode = 473
	ERR_BANNEDFROMCHAN    NumericCode = 474
	ERR_BADCHANNELKEY     NumericCode = 475
	ERR_BADCHANMASK       NumericCode = 476
	ERR_NOCHANMODES       NumericCode = 477
	ERR_BANLISTFULL       NumericCode = 478
	ERR_NOPRIVILEGES      NumericCode = 481
	ERR_CHANOPRIVSNEEDED  NumericCode = 482
	ERR_CANTKILLSERVER    NumericCode = 483
	ERR_RESTRICTED        NumericCode = 484
	ERR_UNIQOPPRIVSNEEDED NumericCode = 485
	ERR_NOOPERHOST        NumericCode = 491
	ERR_UMODEUNKNOWNFLAG  NumericCode = 501
	ERR_USERSDONTMATCH    NumericCode = 502

	Add    ModeOp = '+'
	List   ModeOp = '='
	Remove ModeOp = '-'

	Away          UserMode = 'a'
	Invisible     UserMode = 'i'
	LocalOperator UserMode = 'O'
	Operator      UserMode = 'o'
	Restricted    UserMode = 'r'
	ServerNotice  UserMode = 's' // deprecated
	WallOps       UserMode = 'w'

	Anonymous       ChannelMode = 'a' // flag
	BanMask         ChannelMode = 'b' // arg
	ChannelCreator  ChannelMode = 'O' // flag
	ChannelOperator ChannelMode = 'o' // 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
	Private         ChannelMode = 'p' // flag
	Quiet           ChannelMode = 'q' // flag
	ReOp            ChannelMode = 'r' // flag
	Secret          ChannelMode = 's' // flag, deprecated
	UserLimit       ChannelMode = 'l' // flag arg
	Voice           ChannelMode = 'v' // arg
)
View Source
const (
	R   = '→'
	W   = '←'
	EOF = ""
)

Variables

View Source
var (
	NotEnoughArgsError = errors.New("not enough arguments")
	ErrParseCommand    = errors.New("failed to parse message")
)
View Source
var (
	// debugging flags
	DEBUG_NET     = false
	DEBUG_CLIENT  = false
	DEBUG_CHANNEL = false
	DEBUG_SERVER  = false

	// errors
	ErrAlreadyDestroyed = errors.New("already destroyed")

	// regexps
	ChannelNameExpr = regexp.MustCompile(`^[&!#+][[:word:]]{1,63}$`)
	NicknameExpr    = regexp.MustCompile(
		"^[[:alpha:]\\[\\]{}^`][[:word:]\\[\\]{}^`]{1,31}$")
)
View Source
var (
	ErrNickMissing      = errors.New("nick missing")
	ErrNicknameInUse    = errors.New("nickname in use")
	ErrNicknameMismatch = errors.New("nickname mismatch")
)

Functions

func AddrLookupHostname

func AddrLookupHostname(addr net.Addr) string

func IPString

func IPString(addr net.Addr) string

func IsChannel

func IsChannel(target string) bool

func IsNickname

func IsNickname(nick string) bool

func LookupHostname

func LookupHostname(addr string) string

func NewAwayCommand

func NewAwayCommand(args []string) (editableCommand, error)

func NewCapCommand

func NewCapCommand(args []string) (editableCommand, error)

func NewChannelModeCommand

func NewChannelModeCommand(args []string) (editableCommand, error)

MODE <channel> *( ( "-" / "+" ) *<modes> *<modeparams> )

func NewDebugCommand

func NewDebugCommand(args []string) (editableCommand, error)

func NewInviteCommand

func NewInviteCommand(args []string) (editableCommand, error)

func NewIsOnCommand

func NewIsOnCommand(args []string) (editableCommand, error)

func NewJoinCommand

func NewJoinCommand(args []string) (editableCommand, error)

func NewKickCommand

func NewKickCommand(args []string) (editableCommand, error)

func NewKillCommand

func NewKillCommand(args []string) (editableCommand, error)

func NewListCommand

func NewListCommand(args []string) (editableCommand, error)

func NewMOTDCommand

func NewMOTDCommand(args []string) (editableCommand, error)

func NewModeCommand

func NewModeCommand(args []string) (editableCommand, error)

func NewNamesCommand

func NewNamesCommand(args []string) (editableCommand, error)

func NewNickCommand

func NewNickCommand(args []string) (editableCommand, error)

func NewNoticeCommand

func NewNoticeCommand(args []string) (editableCommand, error)

func NewNumericReply

func NewNumericReply(target *Client, code NumericCode,
	format string, args ...interface{}) string

func NewOperCommand

func NewOperCommand(args []string) (editableCommand, error)

OPER <name> <password>

func NewPartCommand

func NewPartCommand(args []string) (editableCommand, error)

func NewPassCommand

func NewPassCommand(args []string) (editableCommand, error)

func NewPingCommand

func NewPingCommand(args []string) (editableCommand, error)

func NewPongCommand

func NewPongCommand(args []string) (editableCommand, error)

func NewPrivMsgCommand

func NewPrivMsgCommand(args []string) (editableCommand, error)

func NewProxyCommand

func NewProxyCommand(args []string) (editableCommand, error)

func NewQuitCommand

func NewQuitCommand(args []string) (editableCommand, error)

func NewStringReply

func NewStringReply(source Identifier, code StringCode,
	format string, args ...interface{}) string

func NewTimeCommand

func NewTimeCommand(args []string) (editableCommand, error)

func NewTopicCommand

func NewTopicCommand(args []string) (editableCommand, error)

func NewUserCommand

func NewUserCommand(args []string) (editableCommand, error)

func NewUserModeCommand

func NewUserModeCommand(args []string) (editableCommand, error)

MODE <nickname> *( ( "+" / "-" ) *( "i" / "w" / "o" / "O" / "r" ) )

func NewVersionCommand

func NewVersionCommand(args []string) (editableCommand, error)

func NewWhoCommand

func NewWhoCommand(args []string) (editableCommand, error)

WHO [ <mask> [ "o" ] ]

func NewWhoisCommand

func NewWhoisCommand(args []string) (editableCommand, error)

WHOIS [ <target> ] <mask> *( "," <mask> )

func ParseCommand

func ParseCommand(line string) (cmd editableCommand, err error)

func RplChannelMode

func RplChannelMode(client *Client, channel *Channel,
	changes ChannelModeChanges) string

func RplError

func RplError(message string) string

func RplInviteMsg

func RplInviteMsg(inviter *Client, channel string) string

func RplJoin

func RplJoin(client *Client, channel *Channel) string

func RplKick

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

func RplKill

func RplKill(client *Client, target *Client, comment string) string

func RplMode

func RplMode(client *Client, target *Client, changes ModeChanges) string

func RplNick

func RplNick(source Identifier, newNick string) string

func RplNotice

func RplNotice(source Identifier, target Identifier, message string) string

func RplPart

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

func RplPing

func RplPing(target Identifier) string

func RplPong

func RplPong(client *Client) string

func RplPrivMsg

func RplPrivMsg(source Identifier, target Identifier, message string) string

func RplQuit

func RplQuit(client *Client, message string) string

func RplTopicMsg

func RplTopicMsg(source Identifier, channel *Channel) string

Types

type AuthServerCommand

type AuthServerCommand interface {
	Command
	HandleAuthServer(*Server)
}

type AwayCommand

type AwayCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*AwayCommand) HandleServer

func (msg *AwayCommand) HandleServer(server *Server)

func (*AwayCommand) String

func (msg *AwayCommand) String() string

type BaseCommand

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

func (*BaseCommand) Client

func (command *BaseCommand) Client() *Client

func (*BaseCommand) Code

func (command *BaseCommand) Code() StringCode

func (*BaseCommand) SetClient

func (command *BaseCommand) SetClient(client *Client)

func (*BaseCommand) SetCode

func (command *BaseCommand) SetCode(code StringCode)

type CapCommand

type CapCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

TODO

func (*CapCommand) HandleAuthServer

func (msg *CapCommand) HandleAuthServer(server *Server)

func (*CapCommand) HandleRegServer

func (msg *CapCommand) HandleRegServer(server *Server)

func (*CapCommand) String

func (msg *CapCommand) String() string

type Channel

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

func NewChannel

func NewChannel(s *Server, name string) *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() string

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

func (channel *Channel) Mode(client *Client, changes ChannelModeChanges)

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

func (*Channel) Nicks

func (channel *Channel) Nicks() []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()

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

func (channel *Channel) String() string

type ChannelMode

type ChannelMode rune

channel mode flags

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() (str string)

type ChannelModeCommand

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

func (*ChannelModeCommand) HandleServer

func (msg *ChannelModeCommand) HandleServer(server *Server)

func (*ChannelModeCommand) String

func (msg *ChannelModeCommand) String() string

type ChannelModeSet

type ChannelModeSet map[ChannelMode]bool

func (ChannelModeSet) String

func (set ChannelModeSet) String() string

type ChannelNameMap

type ChannelNameMap map[string]*Channel

func (ChannelNameMap) Add

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

func (ChannelNameMap) Get

func (channels ChannelNameMap) Get(name string) *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) *Client

func (*Client) Active

func (client *Client) Active()

func (*Client) ChangeNickname

func (client *Client) ChangeNickname(nickname string)

func (*Client) ErrAlreadyRegistered

func (target *Client) ErrAlreadyRegistered()

func (*Client) ErrBadChannelKey

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

func (*Client) ErrCannotSendToChan

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

func (*Client) ErrChanOPrivIsNeeded

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

<channel> :You're not channel operator

func (*Client) ErrChannelIsFull

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

func (*Client) ErrErroneusNickname

func (target *Client) ErrErroneusNickname(nick string)

func (*Client) ErrInviteOnlyChannel

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

func (*Client) ErrNeedMoreParams

func (target *Client) ErrNeedMoreParams(command string)

func (*Client) ErrNickNameInUse

func (target *Client) ErrNickNameInUse(nick string)

func (*Client) ErrNoChanModes

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

func (*Client) ErrNoMOTD

func (target *Client) ErrNoMOTD()

func (*Client) ErrNoNicknameGiven

func (target *Client) ErrNoNicknameGiven()

func (*Client) ErrNoPrivileges

func (target *Client) ErrNoPrivileges()

func (*Client) ErrNoSuchChannel

func (target *Client) ErrNoSuchChannel(channel string)

func (*Client) ErrNoSuchNick

func (target *Client) ErrNoSuchNick(nick string)

func (*Client) ErrNoSuchServer

func (target *Client) ErrNoSuchServer(server string)

func (*Client) ErrNotOnChannel

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

func (*Client) ErrPasswdMismatch

func (target *Client) ErrPasswdMismatch()

func (*Client) ErrRestricted

func (target *Client) ErrRestricted()

func (*Client) ErrUnknownCommand

func (target *Client) ErrUnknownCommand(code StringCode)

func (*Client) ErrUnknownMode

func (target *Client) ErrUnknownMode(mode ChannelMode, channel *Channel)

func (*Client) ErrUserNotInChannel

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

func (*Client) ErrUserOnChannel

func (target *Client) ErrUserOnChannel(channel *Channel, member *Client)

func (*Client) ErrUsersDontMatch

func (target *Client) ErrUsersDontMatch()

func (*Client) Friends

func (client *Client) Friends() ClientSet

func (*Client) HasNick

func (client *Client) HasNick() bool

func (*Client) HasUsername

func (client *Client) HasUsername() bool

func (*Client) Id

func (c *Client) Id() string

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

func (target *Client) MultilineReply(names []string, code NumericCode, format string,
	args ...interface{})

func (*Client) Nick

func (c *Client) Nick() string

func (*Client) NumericReply

func (target *Client) NumericReply(code NumericCode,
	format string, args ...interface{})

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)

func (*Client) RplAway

func (target *Client) RplAway(client *Client)

func (*Client) RplBanList

func (target *Client) RplBanList(channel *Channel, mask UserMask)

func (*Client) RplChannelModeIs

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

func (*Client) RplCreated

func (target *Client) RplCreated()

func (*Client) RplEndOfBanList

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

func (*Client) RplEndOfExceptList

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

func (*Client) RplEndOfInviteList

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

func (*Client) RplEndOfMaskList

func (target *Client) RplEndOfMaskList(mode ChannelMode, channel *Channel)

func (*Client) RplEndOfNames

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

func (*Client) RplEndOfWho

func (target *Client) RplEndOfWho(name string)

<name> :End of WHO list

func (*Client) RplEndOfWhois

func (target *Client) RplEndOfWhois()

func (*Client) RplExceptList

func (target *Client) RplExceptList(channel *Channel, mask UserMask)

func (*Client) RplInviteList

func (target *Client) RplInviteList(channel *Channel, mask UserMask)

func (*Client) RplInviting

func (target *Client) RplInviting(invitee *Client, channel string)

func (*Client) RplInvitingMsg

func (target *Client) RplInvitingMsg(invitee *Client, channel string)

<nick> <channel> NB: correction in errata

func (*Client) RplIsOn

func (target *Client) RplIsOn(nicks []string)

func (*Client) RplList

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

func (*Client) RplListEnd

func (target *Client) RplListEnd(server *Server)

func (*Client) RplMOTD

func (target *Client) RplMOTD(line string)

func (*Client) RplMOTDEnd

func (target *Client) RplMOTDEnd()

func (*Client) RplMOTDStart

func (target *Client) RplMOTDStart()

func (*Client) RplMaskList

func (target *Client) RplMaskList(mode ChannelMode, channel *Channel, mask UserMask)

func (*Client) RplMyInfo

func (target *Client) RplMyInfo()

func (*Client) RplNamReply

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

func (*Client) RplNoTopic

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

func (*Client) RplNowAway

func (target *Client) RplNowAway()

func (*Client) RplTime

func (target *Client) RplTime()

func (*Client) RplTopic

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

func (*Client) RplUModeIs

func (target *Client) RplUModeIs(client *Client)

func (*Client) RplUnAway

func (target *Client) RplUnAway()

func (*Client) RplVersion

func (target *Client) RplVersion()

func (*Client) RplWelcome

func (target *Client) RplWelcome()

func (*Client) RplWhoReply

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

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

func (*Client) RplWhoisChannels

func (target *Client) RplWhoisChannels(client *Client)

func (*Client) RplWhoisIdle

func (target *Client) RplWhoisIdle(client *Client)

func (*Client) RplWhoisOperator

func (target *Client) RplWhoisOperator(client *Client)

func (*Client) RplWhoisUser

func (target *Client) RplWhoisUser(client *Client)

func (*Client) RplYourHost

func (target *Client) RplYourHost()

func (*Client) RplYoureOper

func (target *Client) RplYoureOper()

:You are now an IRC operator

func (*Client) SetNickname

func (client *Client) SetNickname(nickname string)

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

func (*Client) WhoisChannelsNames

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

type ClientNameMap

type ClientNameMap map[string]*Client

func (ClientNameMap) Add

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

func (ClientNameMap) Get

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

func (ClientNameMap) Remove

func (clients ClientNameMap) 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 Command

type Command interface {
	Code() StringCode
	Client() *Client
}

type Config

type Config struct {
	Debug     map[string]bool
	Listeners []ListenerConfig
	MOTD      string
	Name      string
	Operators []OperatorConfig
	Password  string
	// contains filtered or unexported fields
}

func LoadConfig

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

func (*Config) Database

func (conf *Config) Database() string

func (*Config) OperatorsMap

func (conf *Config) OperatorsMap() map[string][]byte

func (*Config) PasswordBytes

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

type DebugCommand

type DebugCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*DebugCommand) HandleServer

func (msg *DebugCommand) HandleServer(server *Server)

type Identifier

type Identifier interface {
	Id() string
	Nick() string
}

type InviteCommand

type InviteCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*InviteCommand) HandleServer

func (msg *InviteCommand) HandleServer(server *Server)

type IsOnCommand

type IsOnCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*IsOnCommand) HandleServer

func (msg *IsOnCommand) HandleServer(server *Server)

func (*IsOnCommand) String

func (msg *IsOnCommand) String() string

type JoinCommand

type JoinCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*JoinCommand) HandleServer

func (m *JoinCommand) HandleServer(s *Server)

func (*JoinCommand) String

func (cmd *JoinCommand) String() string

type KickCommand

type KickCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*KickCommand) Comment

func (msg *KickCommand) Comment() string

func (*KickCommand) HandleServer

func (msg *KickCommand) HandleServer(server *Server)

type KillCommand

type KillCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*KillCommand) HandleServer

func (msg *KillCommand) HandleServer(server *Server)

type ListCommand

type ListCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*ListCommand) HandleServer

func (msg *ListCommand) HandleServer(server *Server)

type ListenerConfig

type ListenerConfig struct {
	Net         string
	Address     string
	Key         string
	Certificate string
}

func (*ListenerConfig) IsTLS

func (config *ListenerConfig) IsTLS() bool

type MOTDCommand

type MOTDCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*MOTDCommand) HandleServer

func (msg *MOTDCommand) HandleServer(server *Server)

type Mask

type Mask string

a string with wildcards

type MemberSet

type MemberSet map[*Client]ChannelModeSet

func (MemberSet) Add

func (members MemberSet) Add(member *Client)

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

type ModeCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*ModeCommand) HandleServer

func (m *ModeCommand) HandleServer(s *Server)

func (*ModeCommand) String

func (cmd *ModeCommand) String() string

type ModeOp

type ModeOp rune

add, remove, list modes

func (ModeOp) String

func (op ModeOp) String() string

type NamesCommand

type NamesCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*NamesCommand) HandleServer

func (msg *NamesCommand) HandleServer(server *Server)

type NickCommand

type NickCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*NickCommand) HandleRegServer

func (m *NickCommand) HandleRegServer(s *Server)

func (*NickCommand) HandleServer

func (msg *NickCommand) HandleServer(server *Server)

func (*NickCommand) String

func (m *NickCommand) String() string

type NoticeCommand

type NoticeCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*NoticeCommand) HandleServer

func (msg *NoticeCommand) HandleServer(server *Server)

func (*NoticeCommand) String

func (cmd *NoticeCommand) String() string

type NumericCode

type NumericCode uint

func (NumericCode) String

func (code NumericCode) String() string

type OperCommand

type OperCommand struct {
	PassCommand
	// contains filtered or unexported fields
}

func (*OperCommand) HandleServer

func (msg *OperCommand) HandleServer(server *Server)

func (*OperCommand) LoadPassword

func (msg *OperCommand) LoadPassword(server *Server)

func (*OperCommand) String

func (msg *OperCommand) String() string

type OperatorConfig

type OperatorConfig struct {
	Name     string
	Password string
}

func (*OperatorConfig) PasswordBytes

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

type PartCommand

type PartCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*PartCommand) HandleServer

func (m *PartCommand) HandleServer(server *Server)

func (*PartCommand) Message

func (cmd *PartCommand) Message() string

func (*PartCommand) String

func (cmd *PartCommand) String() string

type PassCommand

type PassCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*PassCommand) CheckPassword

func (cmd *PassCommand) CheckPassword()

func (*PassCommand) HandleAuthServer

func (msg *PassCommand) HandleAuthServer(server *Server)

func (*PassCommand) HandleServer

func (m *PassCommand) HandleServer(s *Server)

func (*PassCommand) LoadPassword

func (cmd *PassCommand) LoadPassword(server *Server)

func (*PassCommand) String

func (cmd *PassCommand) String() string

type Phase

type Phase uint
const (
	Authorization Phase = iota
	Registration  Phase = iota
	Normal        Phase = iota
)

type PingCommand

type PingCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*PingCommand) HandleServer

func (m *PingCommand) HandleServer(s *Server)

func (*PingCommand) String

func (cmd *PingCommand) String() string

type PongCommand

type PongCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*PongCommand) HandleServer

func (m *PongCommand) HandleServer(s *Server)

func (*PongCommand) String

func (cmd *PongCommand) String() string

type PrivMsgCommand

type PrivMsgCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*PrivMsgCommand) HandleServer

func (msg *PrivMsgCommand) HandleServer(server *Server)

func (*PrivMsgCommand) String

func (cmd *PrivMsgCommand) String() string

type ProxyCommand

type ProxyCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

HAPROXY support

func (*ProxyCommand) HandleAuthServer

func (msg *ProxyCommand) HandleAuthServer(server *Server)

func (*ProxyCommand) HandleRegServer

func (msg *ProxyCommand) HandleRegServer(server *Server)

func (*ProxyCommand) String

func (msg *ProxyCommand) String() string

type QuitCommand

type QuitCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*QuitCommand) HandleAuthServer

func (msg *QuitCommand) HandleAuthServer(server *Server)

func (*QuitCommand) HandleRegServer

func (msg *QuitCommand) HandleRegServer(server *Server)

func (*QuitCommand) HandleServer

func (msg *QuitCommand) HandleServer(server *Server)

func (*QuitCommand) String

func (cmd *QuitCommand) String() string

type RFC1459UserCommand

type RFC1459UserCommand struct {
	UserCommand
	// contains filtered or unexported fields
}

USER <username> <hostname> <servername> <realname>

func (*RFC1459UserCommand) HandleRegServer

func (msg *RFC1459UserCommand) HandleRegServer(server *Server)

func (*RFC1459UserCommand) String

func (cmd *RFC1459UserCommand) String() string

type RFC2812UserCommand

type RFC2812UserCommand struct {
	UserCommand
	// contains filtered or unexported fields
}

USER <user> <mode> <unused> <realname>

func (*RFC2812UserCommand) Flags

func (cmd *RFC2812UserCommand) Flags() []UserMode

func (*RFC2812UserCommand) HandleRegServer

func (msg *RFC2812UserCommand) HandleRegServer(server *Server)

func (*RFC2812UserCommand) String

func (cmd *RFC2812UserCommand) String() string

type RegServerCommand

type RegServerCommand interface {
	Command
	HandleRegServer(*Server)
}

type Replier

type Replier interface {
	Reply(...string)
}

type ReplyCode

type ReplyCode interface {
	String() string
}

type Server

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

func NewServer

func NewServer(config *Config) *Server

func (*Server) GenerateGuestNick

func (s *Server) GenerateGuestNick() string

func (*Server) Id

func (s *Server) Id() string

func (*Server) InitPhase

func (server *Server) InitPhase() Phase

func (*Server) MOTD

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

func (*Server) Nick

func (s *Server) Nick() string

func (*Server) Reply

func (server *Server) Reply(target *Client, format string, args ...interface{})

func (*Server) Run

func (server *Server) Run()

func (*Server) String

func (s *Server) String() string

type ServerCommand

type ServerCommand interface {
	Command
	HandleServer(*Server)
}

type Socket

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

func NewSocket

func NewSocket(conn net.Conn, commands chan<- editableCommand) *Socket

func (*Socket) Close

func (socket *Socket) Close()

func (*Socket) String

func (socket *Socket) String() string

func (*Socket) Write

func (socket *Socket) Write(line string) (err error)

type StringCode

type StringCode string

func (StringCode) String

func (code StringCode) String() string

type TimeCommand

type TimeCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*TimeCommand) HandleServer

func (msg *TimeCommand) HandleServer(server *Server)

type TopicCommand

type TopicCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*TopicCommand) HandleServer

func (msg *TopicCommand) HandleServer(server *Server)

func (*TopicCommand) String

func (cmd *TopicCommand) String() string

type UnknownCommand

type UnknownCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func NewUnknownCommand

func NewUnknownCommand(args []string) *UnknownCommand

func (*UnknownCommand) String

func (cmd *UnknownCommand) String() string

type UserCommand

type UserCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*UserCommand) HandleRegServer2

func (msg *UserCommand) HandleRegServer2(server *Server)

func (*UserCommand) HandleServer

func (m *UserCommand) HandleServer(s *Server)

type UserMask

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

func (*UserMask) String

func (mask *UserMask) String() string

type UserMode

type UserMode rune

user mode flags

func (UserMode) String

func (mode UserMode) String() string

type VersionCommand

type VersionCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*VersionCommand) HandleServer

func (msg *VersionCommand) HandleServer(server *Server)

type WhoCommand

type WhoCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*WhoCommand) HandleServer

func (msg *WhoCommand) HandleServer(server *Server)

func (*WhoCommand) String

func (msg *WhoCommand) String() string

type WhoisCommand

type WhoisCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func (*WhoisCommand) HandleServer

func (m *WhoisCommand) HandleServer(server *Server)

func (*WhoisCommand) String

func (msg *WhoisCommand) String() string

Jump to

Keyboard shortcuts

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