Documentation ¶
Index ¶
- Variables
- func Initialize(cfg *Config)
- func Shutdown()
- type Config
- type Manager
- func (m *Manager) AuthenticateStream(stm Stream) error
- func (m *Manager) DefaultLocalDomain() string
- func (m *Manager) IsBlockedJID(jid *xml.JID, username string) bool
- func (m *Manager) IsLocalDomain(domain string) bool
- func (m *Manager) MustRoute(elem xml.Stanza) error
- func (m *Manager) RegisterStream(stm Stream) error
- func (m *Manager) ReloadBlockList(username string)
- func (m *Manager) Route(elem xml.Stanza) error
- func (m *Manager) StreamsMatchingJID(jid *xml.JID) []Stream
- func (m *Manager) UnregisterStream(stm Stream) error
- type MockStream
- func (m *MockStream) Context() *stream.Context
- func (m *MockStream) Disconnect(err error)
- func (m *MockStream) Domain() string
- func (m *MockStream) FetchElement() xml.XElement
- func (m *MockStream) ID() string
- func (m *MockStream) IsAuthenticated() bool
- func (m *MockStream) IsCompressed() bool
- func (m *MockStream) IsDisconnected() bool
- func (m *MockStream) IsSecured() bool
- func (m *MockStream) JID() *xml.JID
- func (m *MockStream) Presence() *xml.Presence
- func (m *MockStream) Resource() string
- func (m *MockStream) SendElement(element xml.XElement)
- func (m *MockStream) SetAuthenticated(authenticated bool)
- func (m *MockStream) SetCompressed(compressed bool)
- func (m *MockStream) SetDomain(domain string)
- func (m *MockStream) SetJID(jid *xml.JID)
- func (m *MockStream) SetPresence(presence *xml.Presence)
- func (m *MockStream) SetResource(resource string)
- func (m *MockStream) SetSecured(secured bool)
- func (m *MockStream) SetUsername(username string)
- func (m *MockStream) Username() string
- func (m *MockStream) WaitDisconnection() error
- type Stream
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotExistingAccount will be returned by Route method // if destination user does not exist. ErrNotExistingAccount = errors.New("c2s: account does not exist") // ErrResourceNotFound will be returned by Route method // if destination resource does not match any of user's available resources. ErrResourceNotFound = errors.New("c2s: resource not found") // ErrNotAuthenticated will be returned by Route method if // destination user is not available at this moment. ErrNotAuthenticated = errors.New("c2s: user not authenticated") // ErrBlockedJID will be returned by Route method if // destination JID matches any of the user's blocked JID. ErrBlockedJID = errors.New("c2s: destination jid is blocked") )
Functions ¶
Types ¶
type Config ¶ added in v0.2.0
type Config struct {
Domains []string
}
Config represents a client-to-server manager configuration.
func (*Config) UnmarshalYAML ¶ added in v0.2.0
UnmarshalYAML satisfies Unmarshaler interface.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages the sessions associated with an account.
func (*Manager) AuthenticateStream ¶
AuthenticateStream sets a previously registered stream as authenticated. An error will be returned in case no assigned resource is found.
func (*Manager) DefaultLocalDomain ¶
DefaultLocalDomain returns default local domain.
func (*Manager) IsBlockedJID ¶ added in v0.2.0
IsBlockedJID returns whether or not the passed jid matches any of a user's blocking list JID.
func (*Manager) IsLocalDomain ¶
IsLocalDomain returns true if domain is a local server domain.
func (*Manager) MustRoute ¶ added in v0.2.0
MustRoute routes a stanza applying server rules for handling XML stanzas and ignoring blocking lists.
func (*Manager) RegisterStream ¶
RegisterStream registers the specified client stream. An error will be returned in case the stream has been previously registered.
func (*Manager) ReloadBlockList ¶ added in v0.2.0
ReloadBlockList reloads in-memstorage block list for a given user and starts applying it for future stanza routing.
func (*Manager) Route ¶ added in v0.2.0
Route routes a stanza applying server rules for handling XML stanzas. (https://xmpp.org/rfcs/rfc3921.html#rules)
func (*Manager) StreamsMatchingJID ¶ added in v0.2.0
StreamsMatchingJID returns all available streams that match a given JID.
func (*Manager) UnregisterStream ¶
UnregisterStream unregisters the specified client stream removing associated resource from the manager. An error will be returned in case the stream has not been previously registered.
type MockStream ¶
type MockStream struct {
// contains filtered or unexported fields
}
MockStream represents a mocked c2s stream.
func NewMockStream ¶
func NewMockStream(id string, jid *xml.JID) *MockStream
NewMockStream returns a new mocked stream instance.
func (*MockStream) Context ¶ added in v0.2.0
func (m *MockStream) Context() *stream.Context
Context returns mocked stream associated context.
func (*MockStream) Disconnect ¶
func (m *MockStream) Disconnect(err error)
Disconnect disconnects mocked stream.
func (*MockStream) Domain ¶
func (m *MockStream) Domain() string
Domain returns current mocked stream domain.
func (*MockStream) FetchElement ¶
func (m *MockStream) FetchElement() xml.XElement
FetchElement waits until a new XML element is sent to the mocked stream and returns it.
func (*MockStream) IsAuthenticated ¶
func (m *MockStream) IsAuthenticated() bool
IsAuthenticated returns whether or not the mocked stream has successfully authenticated.
func (*MockStream) IsCompressed ¶
func (m *MockStream) IsCompressed() bool
IsCompressed returns whether or not the mocked stream has enabled a compression method.
func (*MockStream) IsDisconnected ¶
func (m *MockStream) IsDisconnected() bool
IsDisconnected returns whether or not the mocked stream has been disconnected.
func (*MockStream) IsSecured ¶
func (m *MockStream) IsSecured() bool
IsSecured returns whether or not the mocked stream has been secured.
func (*MockStream) Presence ¶ added in v0.2.0
func (m *MockStream) Presence() *xml.Presence
Presence returns last sent presence element.
func (*MockStream) Resource ¶
func (m *MockStream) Resource() string
Resource returns current mocked stream resource.
func (*MockStream) SendElement ¶
func (m *MockStream) SendElement(element xml.XElement)
SendElement sends the given XML element.
func (*MockStream) SetAuthenticated ¶
func (m *MockStream) SetAuthenticated(authenticated bool)
SetAuthenticated sets whether or not the a mocked stream has been authenticated.
func (*MockStream) SetCompressed ¶
func (m *MockStream) SetCompressed(compressed bool)
SetCompressed sets whether or not the a mocked stream has been compressed.
func (*MockStream) SetDomain ¶
func (m *MockStream) SetDomain(domain string)
SetDomain sets the mocked stream domain value.
func (*MockStream) SetJID ¶
func (m *MockStream) SetJID(jid *xml.JID)
SetJID sets the mocked stream JID value.
func (*MockStream) SetPresence ¶ added in v0.2.0
func (m *MockStream) SetPresence(presence *xml.Presence)
SetPresence sets the mocked stream last received presence element.
func (*MockStream) SetResource ¶
func (m *MockStream) SetResource(resource string)
SetResource sets the mocked stream resource value.
func (*MockStream) SetSecured ¶
func (m *MockStream) SetSecured(secured bool)
SetSecured sets whether or not the a mocked stream has been secured.
func (*MockStream) SetUsername ¶
func (m *MockStream) SetUsername(username string)
SetUsername sets the mocked stream username value.
func (*MockStream) Username ¶
func (m *MockStream) Username() string
Username returns current mocked stream username.
func (*MockStream) WaitDisconnection ¶
func (m *MockStream) WaitDisconnection() error
WaitDisconnection waits until the mocked stream disconnects.
type Stream ¶
type Stream interface { ID() string Context() *stream.Context Username() string Domain() string Resource() string JID() *xml.JID IsSecured() bool IsAuthenticated() bool IsCompressed() bool Presence() *xml.Presence SendElement(element xml.XElement) Disconnect(err error) }
Stream represents a client-to-server XMPP stream.