Documentation ¶
Index ¶
- Constants
- Variables
- func FilterChannelModes(channel *Channel, actor *Client, channelMode ChannelModeDelta, ...) (ChannelModeDelta, []MemberModeDelta)
- func ParseChannelModeString(modes string, args []string, resolveClient ResolveClientFn) (channel ChannelModeDelta, member []MemberModeDelta)
- func StringifyChannelModes(channel ChannelModeDelta, member []MemberModeDelta, ...) string
- type AlreadyAMemberError
- type Channel
- type ChannelModeDelta
- type Client
- type Config
- type EventHandler
- type Link
- type LinkMessage
- type MemberModeDelta
- type Membership
- type ModeDelta
- type NameInUseError
- type Node
- func (n *Node) AttachChannel(channel *Channel) error
- func (n *Node) AttachClient(client *Client) error
- func (n *Node) BeginLink(reader io.ReadCloser, writer io.WriteCloser, logger io.Writer, name string)
- func (n *Node) BurstTo(newServer *Server)
- func (n *Node) ChangeChannelMode(client *Client, channel *Channel, channelModes ChannelModeDelta, ...)
- func (n *Node) ChannelMessage(client *Client, channel *Channel, message string)
- func (n *Node) Do(fn NodeDoFn)
- func (n *Node) JoinOrCreateChannel(client *Client, subnet *Subnet, name string) (*Channel, error)
- func (n *Node) NetworkName() string
- func (n *Node) PartChannel(channel *Channel, client *Client, reason string)
- func (n *Node) PrivateMessage(from, to *Client, message string)
- func (n *Node) Quit(client *Client, reason string)
- func (n *Node) SendAll(msg SSMessage)
- func (n *Node) SendAllSkip(msg SSMessage, skip *Server)
- func (n *Node) Shutdown()
- func (n *Node) Sync() chan struct{}
- type NodeDoFn
- type ProxyEventHandler
- func (peh *ProxyEventHandler) OnChannelJoin(channel *Channel, client *Client, membership *Membership)
- func (peh *ProxyEventHandler) OnChannelMessage(from *Client, to *Channel, message string)
- func (peh *ProxyEventHandler) OnChannelModeChange(channel *Channel, by *Client, delta ChannelModeDelta, ...)
- func (peh *ProxyEventHandler) OnChannelPart(channel *Channel, client *Client, reason string)
- func (peh *ProxyEventHandler) OnPrivateMessage(from *Client, to *Client, message string)
- func (peh *ProxyEventHandler) OnServerLink(server *Server, hub *Server)
- type ResolveClientFn
- type SSBurstComplete
- type SSChannel
- type SSChannelId
- type SSChannelMessage
- type SSChannelMode
- type SSChannelModeDelta
- type SSClient
- type SSClientId
- type SSHello
- type SSKill
- type SSKillReason
- type SSMemberModeDelta
- type SSMembership
- type SSMembershipEnd
- type SSMessage
- type SSMessageHeader
- type SSModeDelta
- type SSPrivateMessage
- type SSServer
- type SSSplit
- type SSSync
- type SendQ
- type SerializeClientFn
- type Server
- type ServerProtocolFactory
- type ServerProtocolReader
- type ServerProtocolWriter
- type Subnet
Constants ¶
const ( SS_MSG_TYPE_UNKNOWN uint32 = iota SS_MSG_TYPE_HELLO SS_MSG_TYPE_BURST_COMPLETE SS_MSG_TYPE_SYNC SS_MSG_TYPE_CLIENT SS_MSG_TYPE_SERVER SS_MSG_TYPE_KILL SS_MSG_TYPE_SPLIT SS_MSG_TYPE_CHANNEL SS_MSG_TYPE_CHANNEL_MODE SS_MSG_TYPE_MEMBERSHIP SS_MSG_TYPE_MEMBERSHIP_END SS_MSG_TYPE_PM SS_MSG_TYPE_CM )
Message types. Sent on the wire - do not reorder or delete types.
Variables ¶
var SendQFull error = errors.New("SendQFull")
Functions ¶
func FilterChannelModes ¶
func FilterChannelModes(channel *Channel, actor *Client, channelMode ChannelModeDelta, memberDelta []MemberModeDelta) (ChannelModeDelta, []MemberModeDelta)
func ParseChannelModeString ¶
func ParseChannelModeString(modes string, args []string, resolveClient ResolveClientFn) (channel ChannelModeDelta, member []MemberModeDelta)
func StringifyChannelModes ¶
func StringifyChannelModes(channel ChannelModeDelta, member []MemberModeDelta, serializeClient SerializeClientFn) string
Types ¶
type AlreadyAMemberError ¶
type AlreadyAMemberError struct{}
func (AlreadyAMemberError) Error ¶
func (_ AlreadyAMemberError) Error() string
type Channel ¶
type Channel struct { Node *Node Subnet *Subnet Name string Lname string Ts time.Time Topic string TopicTs time.Time TopicBy string LocalMember map[*Client]*Membership Member map[*Client]*Membership Mode struct { TopicProtected bool NoExternalMessages bool Moderated bool Secret bool Limit uint32 Key string } }
func (*Channel) ApplyModeDelta ¶
func (ch *Channel) ApplyModeDelta(delta ChannelModeDelta, memberDelta []MemberModeDelta) (ChannelModeDelta, []MemberModeDelta)
func (*Channel) DebugString ¶
func (*Channel) Id ¶
func (ch *Channel) Id() SSChannelId
type ChannelModeDelta ¶
type ChannelModeDelta struct {
TopicProtected, NoExternalMessages, Moderated, Secret ModeDelta
Limit, Key ModeDelta
LimitValue uint32
KeyValue string
}
func (*ChannelModeDelta) IsEmpty ¶
func (cmd *ChannelModeDelta) IsEmpty() bool
func (*ChannelModeDelta) String ¶
func (cmd *ChannelModeDelta) String() string
type Client ¶
type Client struct { Subnet *Subnet Server *Server Nick, Lnick string Ident, Vident string Host, Vhost string Ip, Vip string Gecos string Ts time.Time Member map[*Channel]*Membership }
func (*Client) DebugString ¶
func (*Client) Id ¶
func (c *Client) Id() SSClientId
type Config ¶
type Config struct {
// Basic server name and info.
ServerName, ServerDesc string
// Network name.
NetName string
// Name of the default subnet (must match for networks to link)
DefaultSubnetName string
}
Configuration spec for this node.
type EventHandler ¶
type EventHandler interface { OnServerLink(server *Server, hub *Server) OnChannelJoin(channel *Channel, client *Client, membership *Membership) OnChannelMessage(from *Client, to *Channel, message string) OnChannelModeChange(channel *Channel, by *Client, delta ChannelModeDelta, memberDelta []MemberModeDelta) OnPrivateMessage(from *Client, to *Client, message string) OnChannelPart(channel *Channel, client *Client, reason string) }
type Link ¶
type Link struct { Silence bool // contains filtered or unexported fields }
Represents a link between a local and a directly connected remote node.
func NewLink ¶
func NewLink(reader io.ReadCloser, writer io.WriteCloser, sendBufferSize int, protoFactory ServerProtocolFactory, recv chan<- LinkMessage, wg *sync.WaitGroup) *Link
func (*Link) WriteMessage ¶
type LinkMessage ¶
type LinkMessage struct {
// contains filtered or unexported fields
}
A message sent pertaining to a particular link.
type MemberModeDelta ¶
type Membership ¶
func (*Membership) Serialize ¶
func (m *Membership) Serialize(channel *Channel, client *Client) *SSMembership
type NameInUseError ¶
type NameInUseError struct{}
func (NameInUseError) Error ¶
func (_ NameInUseError) Error() string
type Node ¶
type Node struct { // Map of servers directly connected to this node. Local map[*Link]*Server // Map of all servers in the network. Network map[string]*Server NewLinks map[*Link]newLink Subnet map[string]*Subnet DefaultSubnet *Subnet Me *Server Handler EventHandler // contains filtered or unexported fields }
Represents a Gossamer distributed node's current state.
func (*Node) AttachChannel ¶
func (*Node) AttachClient ¶
func (*Node) BeginLink ¶
func (n *Node) BeginLink(reader io.ReadCloser, writer io.WriteCloser, logger io.Writer, name string)
func (*Node) ChangeChannelMode ¶
func (n *Node) ChangeChannelMode(client *Client, channel *Channel, channelModes ChannelModeDelta, memberModes []MemberModeDelta)
func (*Node) ChannelMessage ¶
func (*Node) JoinOrCreateChannel ¶
func (*Node) NetworkName ¶
func (*Node) PartChannel ¶
func (*Node) PrivateMessage ¶
func (*Node) SendAllSkip ¶
type ProxyEventHandler ¶
type ProxyEventHandler struct {
Delegate EventHandler
}
func (*ProxyEventHandler) OnChannelJoin ¶
func (peh *ProxyEventHandler) OnChannelJoin(channel *Channel, client *Client, membership *Membership)
func (*ProxyEventHandler) OnChannelMessage ¶
func (peh *ProxyEventHandler) OnChannelMessage(from *Client, to *Channel, message string)
func (*ProxyEventHandler) OnChannelModeChange ¶
func (peh *ProxyEventHandler) OnChannelModeChange(channel *Channel, by *Client, delta ChannelModeDelta, memberDelta []MemberModeDelta)
func (*ProxyEventHandler) OnChannelPart ¶
func (peh *ProxyEventHandler) OnChannelPart(channel *Channel, client *Client, reason string)
func (*ProxyEventHandler) OnPrivateMessage ¶
func (peh *ProxyEventHandler) OnPrivateMessage(from *Client, to *Client, message string)
func (*ProxyEventHandler) OnServerLink ¶
func (peh *ProxyEventHandler) OnServerLink(server *Server, hub *Server)
type ResolveClientFn ¶
type SSBurstComplete ¶
type SSBurstComplete struct {
Server string
}
func (SSBurstComplete) String ¶
func (msg SSBurstComplete) String() string
type SSChannel ¶
type SSChannel struct { Name string Subnet string Ts time.Time Members []*SSMembership }
type SSChannelId ¶
func (SSChannelId) String ¶
func (id SSChannelId) String() string
type SSChannelMessage ¶
type SSChannelMessage struct { From SSClientId To SSChannelId Message string }
func (SSChannelMessage) String ¶
func (msg SSChannelMessage) String() string
type SSChannelMode ¶
type SSChannelMode struct { From SSClientId Channel SSChannelId Mode SSChannelModeDelta MemberMode []SSMemberModeDelta }
func SerializeChannelModeChange ¶
func SerializeChannelModeChange(channel *Channel, actor *Client, channelMode ChannelModeDelta, memberDelta []MemberModeDelta) *SSChannelMode
func (SSChannelMode) String ¶
func (msg SSChannelMode) String() string
type SSChannelModeDelta ¶
type SSChannelModeDelta struct {
TopicProtected, NoExternalMessages, Moderated, Secret SSModeDelta
Limit, Key SSModeDelta
LimitValue uint32
KeyValue string
}
func ChannelModeDeltaToSSChannelModeDelta ¶
func ChannelModeDeltaToSSChannelModeDelta(value ChannelModeDelta) SSChannelModeDelta
func (SSChannelModeDelta) ToChannelModeDelta ¶
func (delta SSChannelModeDelta) ToChannelModeDelta() ChannelModeDelta
type SSClient ¶
type SSClientId ¶
TODO Why does SSClientId have Server?
func (SSClientId) String ¶
func (id SSClientId) String() string
type SSHello ¶
type SSHello struct { Protocol uint32 LocalTimeMs uint64 Name string Description string DefaultSubnet string }
/ Introduction message sent by one server to another at the beginning of link.
type SSKill ¶
type SSKill struct { // Id of the client being killed. Id SSClientId // Server doing the killing. Server string // Whether this kill message is instructional (server A telling server B to kill B's client) // or authoritative (server B broadcasting a kill of its own client) Authority bool // If this kill was initiated by another client, who it was. By SSClientId // Textual reason for the kill. Reason string // Numerical code indicating the reason for the kill (for statistics, etc). ReasonCode SSKillReason }
type SSKillReason ¶
type SSKillReason uint8
const ( SS_KILL_REASON_QUIT SSKillReason = iota SS_KILL_REASON_COLLISION SS_KILL_REASON_SENDQ SS_KILL_REASON_RECVQ )
type SSMemberModeDelta ¶
type SSMemberModeDelta struct { Client SSClientId IsOwner, IsAdmin, IsOp, IsHalfop, IsVoice SSModeDelta }
func SSMemberModeDeltaFromMemberModeDelta ¶
func SSMemberModeDeltaFromMemberModeDelta(value MemberModeDelta) SSMemberModeDelta
func (SSMemberModeDelta) ToMemberModeDelta ¶
func (delta SSMemberModeDelta) ToMemberModeDelta(n *Node) (MemberModeDelta, bool)
type SSMembership ¶
type SSMembership struct { Client SSClientId Channel SSChannelId Ts time.Time IsOwner, IsAdmin, IsOp, IsHalfop, IsVoice bool }
func (SSMembership) String ¶
func (msg SSMembership) String() string
type SSMembershipEnd ¶
type SSMembershipEnd struct { Channel SSChannelId Client SSClientId Reason string }
func (SSMembershipEnd) String ¶
func (msg SSMembershipEnd) String() string
type SSMessage ¶
type SSMessage interface { String() string // contains filtered or unexported methods }
A Gossamer server-to-server message.
type SSMessageHeader ¶
type SSMessageHeader struct {
Type uint32
}
Message header used to identify what message is being transmitted next.
type SSModeDelta ¶
type SSModeDelta uint8
const ( SS_MODE_UNCHANGED SSModeDelta = iota SS_MODE_ADDED SS_MODE_REMOVED )
func SSModeDeltaFromModeDelta ¶
func SSModeDeltaFromModeDelta(value ModeDelta) SSModeDelta
func (SSModeDelta) ToModeDelta ¶
func (value SSModeDelta) ToModeDelta() ModeDelta
type SSPrivateMessage ¶
type SSPrivateMessage struct { From SSClientId To SSClientId Message string }
func (SSPrivateMessage) String ¶
func (msg SSPrivateMessage) String() string
type SendQ ¶
type SendQ struct {
// contains filtered or unexported fields
}
A SendQ is an io.Writer that implements fixed buffering. Once the buffer buffer is exhausted, a QueueFull error is raised. Writing to the buffer always succeeds, though - any errors are delivered asynchronously. All errors are fatal - the queue shuts down and becomes a noop after an error is encountered.
func (*SendQ) FlushAndClose ¶
func (sq *SendQ) FlushAndClose()
Close the writer after all data has been flushed.
type SerializeClientFn ¶
type Server ¶
type Server struct { Name string Desc string Link *Link Route *Server Hub *Server Links map[string]*Server }
func NewRemoteServer ¶
type ServerProtocolFactory ¶
type ServerProtocolFactory interface { Reader(reader io.Reader) ServerProtocolReader Writer(writer io.Writer) ServerProtocolWriter }
var GobServerProtocolFactory ServerProtocolFactory = &gobServerProtocolFactory{}
type ServerProtocolReader ¶
A Gossamer server-to-server message reader.
func NewGobServerProtocolReader ¶
func NewGobServerProtocolReader(reader io.Reader) ServerProtocolReader
Construct a ServerProtcolReader from the underlying io.Reader which interprets incoming data using the gob encoding.
type ServerProtocolWriter ¶
A Gossamer server-to-server message writer.
func NewGobServerProtocolWriter ¶
func NewGobServerProtocolWriter(writer io.Writer) ServerProtocolWriter
Construct a ServerProtocolWriter from the underlying io.Writer which serializes outgoing messages using the gob encoding.