Documentation ¶
Overview ¶
Package ircbnc provides the backend for the GoshuBNC IRC bouncer.
Index ¶
- Constants
- Variables
- func BncName(name string) (string, error)
- func CapAccountNotify(caps *CapManager)
- func CapAccountTag(caps *CapManager)
- func CapAwayNotify(caps *CapManager)
- func CapBatch(caps *CapManager)
- func CapExtendedJoin(caps *CapManager)
- func CapInviteNotify(caps *CapManager)
- func CapServerTime(caps *CapManager)
- func CapUserhostInNames(caps *CapManager)
- func IrcName(name string, isChannel bool) (string, error)
- func NewListener(m *Manager, conn net.Conn)
- func SplitMask(mask string) (string, string, string)
- type CapManager
- func (caps *CapManager) FilterSupported(requested []string) map[string]string
- func (caps *CapManager) InitCapOnListener(listener *Listener, cap string)
- func (caps *CapManager) MessageFromClient(listener *Listener, message *ircmsg.IrcMessage) bool
- func (caps *CapManager) MessageToClient(listener *Listener, message *ircmsg.IrcMessage) bool
- func (caps *CapManager) SupportedString() string
- type ClientCommand
- type Config
- type DataStoreInterface
- type HookEmitter
- type HookIrcRaw
- type HookListenerClose
- type HookNewListener
- type HookStateSent
- type Listener
- func (listener *Listener) DumpChannels()
- func (listener *Listener) DumpRegistration()
- func (listener *Listener) IsCapEnabled(cap string) bool
- func (listener *Listener) RunSocketReader()
- func (listener *Listener) Send(tags *map[string]ircmsg.TagValue, prefix string, command string, ...) error
- func (listener *Listener) SendExtraISupports()
- func (listener *Listener) SendLine(line string)
- func (listener *Listener) SendMessage(msg *ircmsg.IrcMessage) error
- func (listener *Listener) SendNilConnect()
- func (listener *Listener) SendStatus(line string)
- type Manager
- type MessageDatastore
- type RegistrationLocks
- type ServerConnection
- func (sc *ServerConnection) AddListener(listener *Listener)
- func (sc *ServerConnection) Connect()
- func (sc *ServerConnection) Disconnect()
- func (sc *ServerConnection) DumpChannels(listener *Listener)
- func (sc *ServerConnection) DumpRegistration(listener *Listener)
- func (sc *ServerConnection) ReadyToConnect() bool
- func (sc *ServerConnection) RemoveListener(listener *Listener)
- func (sc *ServerConnection) Save() error
- type ServerConnectionAddress
- type ServerConnectionAddresses
- type ServerConnectionBuffer
- type ServerConnectionBuffers
- func (buffers *ServerConnectionBuffers) Add(buffer *ServerConnectionBuffer)
- func (buffers *ServerConnectionBuffers) Get(findName string) *ServerConnectionBuffer
- func (buffers *ServerConnectionBuffers) Map() map[string]*ServerConnectionBuffer
- func (buffers *ServerConnectionBuffers) Remove(name string)
- type Socket
- func (socket *Socket) CertFP() (string, error)
- func (socket *Socket) Close()
- func (socket *Socket) IsClosed() bool
- func (socket *Socket) Read() (string, error)
- func (socket *Socket) RunSocketWriter()
- func (socket *Socket) SetFinalData(data string)
- func (socket *Socket) Write(data string) error
- func (socket *Socket) WriteLine(line string) error
- type TLSListenConfig
- type User
Constants ¶
const (
// SemVer is the semantic version of GoshuBNC.
SemVer = "0.1.0-unreleased"
)
Variables ¶
var ClientCommands map[string]ClientCommand
ClientCommands holds all commands executable by a client connected to a listener.
var HookIrcRawName = "irc.raw"
var HookListenerCloseName = "listener.close"
var HookNewListenerName = "listener.new"
var HookStateSentName = "listener.statesent"
var ( // Ver is the full version of GoshuBNC, used in responses to clients. Ver = fmt.Sprintf("goshubnc-%s", SemVer) )
Functions ¶
func BncName ¶
BncName takes the given name and returns a casefolded name appropriate for use with ircbnc. This includes usernames, network names, etc.
func CapBatch ¶
func CapBatch(caps *CapManager)
*
- CAP: batch
- Not used on it's own, but other commands such as CHATHISTORY make use of it
Types ¶
type CapManager ¶
type CapManager struct { Supported map[string]string FnsInitListener map[string]func(*Listener) FnsMessageToClient []func(*Listener, *ircmsg.IrcMessage) bool FnsMessageFromClient []func(*Listener, *ircmsg.IrcMessage) bool }
var Capabilities CapManager
func (*CapManager) FilterSupported ¶
func (caps *CapManager) FilterSupported(requested []string) map[string]string
FilterSupported filters the supported CAPs by the requested
func (*CapManager) InitCapOnListener ¶
func (caps *CapManager) InitCapOnListener(listener *Listener, cap string)
MessageToClient runs messages through any CAPs before being sent to the client
func (*CapManager) MessageFromClient ¶
func (caps *CapManager) MessageFromClient(listener *Listener, message *ircmsg.IrcMessage) bool
MessageFromClient runs messages received from a client through any CAPs
func (*CapManager) MessageToClient ¶
func (caps *CapManager) MessageToClient(listener *Listener, message *ircmsg.IrcMessage) bool
MessageToClient runs messages through any CAPs before being sent to the client
func (*CapManager) SupportedString ¶
func (caps *CapManager) SupportedString() string
SupportedString returns a list ready to send to the client of all our CAPs
type ClientCommand ¶
type ClientCommand struct {
// contains filtered or unexported fields
}
ClientCommand represents a command accepted on a listener.
func (*ClientCommand) Run ¶
func (cmd *ClientCommand) Run(listener *Listener, msg ircmsg.IrcMessage) bool
Run runs this command with the given listener/message.
type Config ¶
type Config struct { Bouncer struct { Storage map[string]string Listeners []string TLSListeners map[string]*TLSListenConfig `yaml:"tls-listeners"` Logging map[string]string } }
Config defines a configuration file for GoshuBNC
func LoadConfig ¶
LoadConfig returns a Config instance
type DataStoreInterface ¶
type DataStoreInterface interface { Init(manager *Manager) error Setup() error GetAllUsers() []*User GetUserById(id string) *User GetUserByUsername(username string) *User SaveUser(*User) error SetUserPassword(user *User, newPassword string) AuthUser(username string, password string) (authedUserId string, authSuccess bool) GetUserNetworks(userId string) SaveConnection(connection *ServerConnection) error DelConnection(connection *ServerConnection) error }
type HookEmitter ¶
type HookEmitter struct {
Registered map[string][]func(interface{})
}
func MakeHookEmitter ¶
func MakeHookEmitter() HookEmitter
func (*HookEmitter) Dispatch ¶
func (hooks *HookEmitter) Dispatch(hookName string, data interface{})
func (*HookEmitter) Register ¶
func (hooks *HookEmitter) Register(hookName string, p func(interface{}))
type HookIrcRaw ¶
type HookIrcRaw struct { Listener *Listener FromServer bool FromClient bool User *User Server *ServerConnection Raw string Message ircmsg.IrcMessage Halt bool }
type HookListenerClose ¶
type HookListenerClose struct {
Listener *Listener
}
type HookNewListener ¶
type HookStateSent ¶
type HookStateSent struct { Listener *Listener Server *ServerConnection }
type Listener ¶
type Listener struct { Socket Socket Manager *Manager ConnectTime time.Time Caps map[string]string ExtraISupports map[string]string TagsEnabled bool ClientNick string Source string Registered bool User *User ServerConnection *ServerConnection // contains filtered or unexported fields }
Listener is a listener for a client connected directly to us.
func (*Listener) DumpChannels ¶
func (listener *Listener) DumpChannels()
DumpChannels dumps the active channels to the listener.
func (*Listener) DumpRegistration ¶
func (listener *Listener) DumpRegistration()
DumpRegistration dumps the registration numerics/replies to the listener.
func (*Listener) IsCapEnabled ¶
func (*Listener) RunSocketReader ¶
func (listener *Listener) RunSocketReader()
RunSocketReader reads lines from the listener socket and dispatches them as appropriate.
func (*Listener) Send ¶
func (listener *Listener) Send(tags *map[string]ircmsg.TagValue, prefix string, command string, params ...string) error
Send sends an IRC line to the user.
func (*Listener) SendExtraISupports ¶
func (listener *Listener) SendExtraISupports()
func (*Listener) SendMessage ¶
func (listener *Listener) SendMessage(msg *ircmsg.IrcMessage) error
SendMessage sends an IrcMessage to the user
func (*Listener) SendNilConnect ¶
func (listener *Listener) SendNilConnect()
SendNilConnect sends a connection init (001+ERR_NOMOTD) to the listener when they are not connected to a server.
func (*Listener) SendStatus ¶
SendStatus sends a status PRIVMSG to the user.
type Manager ¶
type Manager struct { Config *Config Ds DataStoreInterface Messages MessageDatastore Users map[string]*User Listeners []net.Listener Source string StatusNick string StatusSource string Bus HookEmitter Salt []byte // contains filtered or unexported fields }
Manager handles the different components that keep GoshuBNC spinning.
var ( // QuitSignals is the list of signals we quit on //TODO(dan): Rehash on one of these signals instead, same as Oragono. QuitSignals = []os.Signal{syscall.SIGINT, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGQUIT} // BNC: The global instance of Manager. // TODO: NewManager() sets this each time it's run. It's only run once so no issue.. but it's not tidy BNC *Manager )
func NewManager ¶
func NewManager(config *Config, ds DataStoreInterface) *Manager
NewManager create a new IRC bouncer from the given config and database.
type MessageDatastore ¶
type MessageDatastore interface { Store(hookEvent *HookIrcRaw) GetFromTime(userID string, networkID string, bufferName string, timeFrom time.Time, num int) []*ircmsg.IrcMessage GetBeforeTime(userID string, networkID string, bufferName string, timeFrom time.Time, num int) []*ircmsg.IrcMessage Search(userID string, networkID string, bufferName string, timeFrom time.Time, timeTo time.Time, num int) []*ircmsg.IrcMessage SupportsStore() bool SupportsRetrieve() bool SupportsSearch() bool }
type RegistrationLocks ¶
RegistrationLocks ensure the user can't complete registration until they've finished the reg process.
func (*RegistrationLocks) Completed ¶
func (rl *RegistrationLocks) Completed() bool
Completed returns true if all of our registration locks have been completed.
func (*RegistrationLocks) Set ¶
func (rl *RegistrationLocks) Set(lockName string, val bool)
Set sets the given registration lock.
type ServerConnection ¶
type ServerConnection struct { Name string User *User Enabled bool Nickname string FbNickname string Username string Realname string CurrentMask string Buffers ServerConnectionBuffers ListenersLock sync.Mutex Listeners []*Listener Password string Addresses []ServerConnectionAddress Foo *ircclient.Client // contains filtered or unexported fields }
ServerConnection represents a connection to an IRC server.
func NewServerConnection ¶
func NewServerConnection() *ServerConnection
func (*ServerConnection) AddListener ¶
func (sc *ServerConnection) AddListener(listener *Listener)
AddListener adds the given listener to this ServerConnection.
func (*ServerConnection) Connect ¶
func (sc *ServerConnection) Connect()
func (*ServerConnection) Disconnect ¶
func (sc *ServerConnection) Disconnect()
func (*ServerConnection) DumpChannels ¶
func (sc *ServerConnection) DumpChannels(listener *Listener)
func (*ServerConnection) DumpRegistration ¶
func (sc *ServerConnection) DumpRegistration(listener *Listener)
DumpRegistration dumps the registration messages of this server to the given Listener.
func (*ServerConnection) ReadyToConnect ¶
func (sc *ServerConnection) ReadyToConnect() bool
func (*ServerConnection) RemoveListener ¶
func (sc *ServerConnection) RemoveListener(listener *Listener)
func (*ServerConnection) Save ¶
func (sc *ServerConnection) Save() error
type ServerConnectionAddress ¶
type ServerConnectionAddresses ¶
type ServerConnectionAddresses []ServerConnectionAddress
type ServerConnectionBuffer ¶
type ServerConnectionBuffers ¶
type ServerConnectionBuffers map[string]*ServerConnectionBuffer
func (*ServerConnectionBuffers) Add ¶
func (buffers *ServerConnectionBuffers) Add(buffer *ServerConnectionBuffer)
func (*ServerConnectionBuffers) Get ¶
func (buffers *ServerConnectionBuffers) Get(findName string) *ServerConnectionBuffer
func (*ServerConnectionBuffers) Map ¶
func (buffers *ServerConnectionBuffers) Map() map[string]*ServerConnectionBuffer
TODO(dan): Why do we use this function instead of just having ServerConnectionBuffers be a struct with a hidden map?
func (*ServerConnectionBuffers) Remove ¶
func (buffers *ServerConnectionBuffers) Remove(name string)
type Socket ¶
type Socket struct { MaxSendQBytes uint64 // contains filtered or unexported fields }
Socket represents an IRC socket.
func (*Socket) Close ¶
func (socket *Socket) Close()
Close stops a Socket from being able to send/receive any more data.
func (*Socket) RunSocketWriter ¶
func (socket *Socket) RunSocketWriter()
RunSocketWriter starts writing messages to the outgoing socket.
func (*Socket) SetFinalData ¶
SetFinalData sets the final data to send when the SocketWriter closes.
type TLSListenConfig ¶
TLSListenConfig defines configuration options for listening on TLS
type User ¶
type User struct { Manager *Manager Config *Config ID string Name string Role string HashedPassword []byte Salt []byte Permissions []string DefaultNick string DefaultFbNick string DefaultUser string DefaultReal string Networks map[string]*ServerConnection }
User represents an ircbnc user.
func (*User) StartServerConnections ¶
func (user *User) StartServerConnections()
StartServerConnections starts running the server connections of this user.