Documentation
¶
Overview ¶
Package xmpp implements a simple Google Talk client using the XMPP protocol described in RFC 3920 and RFC 3921.
TODO(flo):
- support password protected MUC rooms
- cleanup signatures of join/leave functions
Index ¶
- Constants
- Variables
- type AvatarData
- type AvatarMetadata
- type Chat
- type Client
- func (c *Client) ApproveSubscription(jid string)
- func (c *Client) AvatarRequestData(jid string) error
- func (c *Client) AvatarRequestDataByID(jid, id string) error
- func (c *Client) AvatarRequestMetadata(jid string) error
- func (c *Client) AvatarSubscribeMetadata(jid string) error
- func (c *Client) AvatarUnsubscribeMetadata(jid string) error
- func (c *Client) Close() error
- func (c *Client) DiscoverEntityItems(jid string) (string, error)
- func (c *Client) DiscoverInfo(to string) (string, error)
- func (c *Client) DiscoverNodeInfo(node string) (string, error)
- func (c *Client) DiscoverServerItems() (string, error)
- func (c *Client) Discovery() (string, error)
- func (c *Client) ErrorNotImplemented(v IQ, xmlns, feature string) (string, error)
- func (c *Client) ErrorServiceUnavailable(v IQ, queryXmlns, node string) (string, error)
- func (c *Client) IsEncrypted() bool
- func (c *Client) JID() string
- func (c *Client) JoinMUC(jid, nick string, history_type, history int, history_date *time.Time) (n int, err error)
- func (c *Client) JoinMUCNoHistory(jid, nick string) (n int, err error)
- func (c *Client) JoinProtectedMUC(jid, nick string, password string, history_type, history int, ...) (n int, err error)
- func (c *Client) LeaveMUC(jid string) (n int, err error)
- func (c *Client) PingC2S(jid, server string) error
- func (c *Client) PingS2S(fromServer, toServer string) error
- func (c *Client) PubsubRequestItem(node, jid, id string) error
- func (c *Client) PubsubRequestLastItems(node, jid string) error
- func (c *Client) PubsubSubscribeNode(node, jid string) error
- func (c *Client) PubsubUnsubscribeNode(node, jid string) error
- func (c *Client) RawInformation(from, to, id, iqType, body string) (string, error)
- func (c *Client) RawInformationQuery(from, to, id, iqType, requestNamespace, body string) (string, error)
- func (c *Client) Recv() (stanza interface{}, err error)
- func (c *Client) RequestSubscription(jid string)
- func (c *Client) RetrieveSubscription(jid string)
- func (c *Client) RevertSubscription(jid string)
- func (c *Client) RevokeSubscription(jid string)
- func (c *Client) Roster() error
- func (c *Client) Send(chat Chat) (n int, err error)
- func (c *Client) SendHtml(chat Chat) (n int, err error)
- func (c *Client) SendKeepAlive() (n int, err error)
- func (c *Client) SendOOB(chat Chat) (n int, err error)
- func (c *Client) SendOrg(org string) (n int, err error)
- func (c *Client) SendPresence(presence Presence) (n int, err error)
- func (c *Client) SendResultPing(id, toServer string) error
- func (c *Client) SendTopic(chat Chat) (n int, err error)
- type Contact
- type Cookie
- type Delay
- type DiscoIdentity
- type DiscoItem
- type DiscoItems
- type DiscoResult
- type DiscoX
- type DiscoXField
- type Fast
- type IQ
- type Options
- type Presence
- type PubsubEvent
- type PubsubItem
- type PubsubItems
- type PubsubSubscription
- type PubsubUnsubscription
- type Roster
- type XMLElement
Constants ¶
const ( XMPPNS_AVATAR_PEP_DATA = "urn:xmpp:avatar:data" XMPPNS_AVATAR_PEP_METADATA = "urn:xmpp:avatar:metadata" )
const ( XMPPNS_DISCO_ITEMS = "http://jabber.org/protocol/disco#items" XMPPNS_DISCO_INFO = "http://jabber.org/protocol/disco#info" )
const ( IQTypeGet = "get" IQTypeSet = "set" IQTypeResult = "result" IQTypeError = "error" )
const ( NoHistory = 0 CharHistory = 1 StanzaHistory = 2 SecondsHistory = 3 SinceHistory = 4 )
const ( XMPPNS_PUBSUB = "http://jabber.org/protocol/pubsub" XMPPNS_PUBSUB_EVENT = "http://jabber.org/protocol/pubsub#event" )
const (
Version = "0.2.17"
)
Variables ¶
var DefaultConfig = &tls.Config{}
Default TLS configuration options
Functions ¶
This section is empty.
Types ¶
type AvatarData ¶
type AvatarMetadata ¶
type Chat ¶
type Chat struct { Remote string Type string Text string Subject string Thread string Ooburl string Oobdesc string Lang string Roster Roster Other []string OtherElem []XMLElement Stamp time.Time }
Chat is an incoming or outgoing XMPP chat message.
type Client ¶
type Client struct { LimitMaxBytes int // Maximum stanza size (XEP-0478: Stream Limits Advertisement) LimitIdleSeconds int // Maximum idle seconds (XEP-0478: Stream Limits Advertisement) Mechanism string // SCRAM mechanism used. Fast Fast // XEP-0484 FAST Token, mechanism and expiry. // contains filtered or unexported fields }
Client holds XMPP connection options
func NewClient ¶
NewClient creates a new connection to a host given as "hostname" or "hostname:port". If host is not specified, the DNS SRV should be used to find the host from the domainpart of the JID. Default the port to 5222.
func NewClientNoTLS ¶
NewClientNoTLS creates a new client without TLS
func (*Client) ApproveSubscription ¶
func (*Client) AvatarRequestData ¶
func (*Client) AvatarRequestDataByID ¶
func (*Client) AvatarRequestMetadata ¶
func (*Client) AvatarSubscribeMetadata ¶
func (*Client) AvatarUnsubscribeMetadata ¶
func (*Client) DiscoverEntityItems ¶
Discover items that an entity exposes
func (*Client) DiscoverInfo ¶ added in v0.2.5
Discover information about given item from given jid.
func (*Client) DiscoverNodeInfo ¶
Discover information about a node. Empty node queries info about server itself.
func (*Client) DiscoverServerItems ¶
Discover items that the server exposes
func (*Client) ErrorNotImplemented ¶ added in v0.2.15
ErrorNotImplemented implements error response about a feature that is not (yet?) implemented. Xmlns is about not implemented feature.
If queried feature is not here because of it under development or for similar reasons, standards suggest to answer with this stanza.
func (*Client) ErrorServiceUnavailable ¶ added in v0.2.15
ErrorServiceUnavailable implements error response about a feature that is not available. Currently implemented for xep-0030. QueryXmlns is about incoming xmlns attribute in query tag. Node is about incoming node attribute in query tag (looks like it used only in disco#commands).
If queried feature is not here on purpose, standards suggest to answer with this stanza.
func (*Client) IsEncrypted ¶
IsEncrypted will return true if the client is connected using a TLS transport, either because it used. TLS to connect from the outset, or because it successfully used STARTTLS to promote a TCP connection to TLS.
func (*Client) JoinMUC ¶
func (c *Client) JoinMUC(jid, nick string, history_type, history int, history_date *time.Time) (n int, err error)
xep-0045 7.2
func (*Client) JoinMUCNoHistory ¶
func (*Client) JoinProtectedMUC ¶
func (c *Client) JoinProtectedMUC(jid, nick string, password string, history_type, history int, history_date *time.Time) (n int, err error)
xep-0045 7.2.6
func (*Client) PubsubRequestItem ¶
func (*Client) PubsubRequestLastItems ¶
func (*Client) PubsubSubscribeNode ¶
func (*Client) PubsubUnsubscribeNode ¶
func (*Client) RawInformation ¶
rawInformation send a IQ request with the payload body to the server
func (*Client) RawInformationQuery ¶
func (c *Client) RawInformationQuery(from, to, id, iqType, requestNamespace, body string) (string, error)
RawInformationQuery sends an information query request to the server.
func (*Client) RequestSubscription ¶
func (*Client) RetrieveSubscription ¶
DEPRECATED: Use RevertSubscription instead.
func (*Client) RevertSubscription ¶ added in v0.2.15
func (*Client) RevokeSubscription ¶
func (*Client) SendKeepAlive ¶
SendKeepAlive sends a "whitespace keepalive" as described in chapter 4.6.1 of RFC6120.
func (*Client) SendOOB ¶
SendOOB sends OOB data wrapped inside an XMPP message stanza, without actual body.
func (*Client) SendOrg ¶
SendOrg sends the original text without being wrapped in an XMPP message stanza.
func (*Client) SendPresence ¶
SendPresence sends Presence wrapped inside XMPP presence stanza.
func (*Client) SendResultPing ¶
type DiscoIdentity ¶
type DiscoItems ¶
type DiscoResult ¶
type DiscoResult struct { Features []string Identities []DiscoIdentity X []DiscoX }
type DiscoX ¶ added in v0.2.14
type DiscoX struct { XMLName xml.Name `xml:"x"` Field []DiscoXField `xml:"field"` }
type DiscoXField ¶ added in v0.2.15
type Options ¶
type Options struct { // Host specifies what host to connect to, as either "hostname" or "hostname:port" // If host is not specified, the DNS SRV should be used to find the host from the domainpart of the JID. // Default the port to 5222. Host string // User specifies what user to authenticate to the remote server. User string // Password supplies the password to use for authentication with the remote server. Password string // DialTimeout is the time limit for establishing a connection. A // DialTimeout of zero means no timeout. DialTimeout time.Duration // Resource specifies an XMPP client resource, like "bot", instead of accepting one // from the server. Use "" to let the server generate one for your client. Resource string // OAuthScope provides go-xmpp the required scope for OAuth2 authentication. OAuthScope string // OAuthToken provides go-xmpp with the required OAuth2 token used to authenticate OAuthToken string // OAuthXmlNs provides go-xmpp with the required namespaced used for OAuth2 authentication. This is // provided to the server as the xmlns:auth attribute of the OAuth2 authentication request. OAuthXmlNs string // TLS Config TLSConfig *tls.Config // InsecureAllowUnencryptedAuth permits authentication over a TCP connection that has not been promoted to // TLS by STARTTLS; this could leak authentication information over the network, or permit man in the middle // attacks. InsecureAllowUnencryptedAuth bool // NoTLS directs go-xmpp to not use TLS initially to contact the server; instead, a plain old unencrypted // TCP connection should be used. (Can be combined with StartTLS to support STARTTLS-based servers.) NoTLS bool // StartTLS directs go-xmpp to STARTTLS if the server supports it; go-xmpp will automatically STARTTLS // if the server requires it regardless of this option. StartTLS bool // Debug output Debug bool // DebugWriter specifies where the debug output is written to DebugWriter io.Writer // Use server sessions Session bool // Presence Status Status string // Status message StatusMessage string // Auth mechanism to use Mechanism string // XEP-0474: SASL SCRAM Downgrade Protection SSDP bool // XEP-0388: Extensible SASL Profile // Value for software UserAgentSW string // XEP-0388: XEP-0388: Extensible SASL Profile // Value for device UserAgentDev string // XEP-0388: Extensible SASL Profile // Unique stable identifier for the client installation // MUST be a valid UUIDv4 UserAgentID string // Enable XEP-0484: Fast Authentication Streamlining Tokens Fast bool // XEP-0484: Fast Authentication Streamlining Tokens // Fast Token FastToken string // XEP-0484: Fast Authentication Streamlining Tokens // Fast Mechanism FastMechanism string // XEP-0484: Fast Authentication Streamlining Tokens // Invalidate the current token FastInvalidate bool // NoPLAIN forbids authentication using plain passwords NoPLAIN bool // NoSASLUpgrade disables XEP-0480 upgrades. NoSASLUpgrade bool // Send periodic XEP-0199 pings to the server. PeriodicServerPings bool // Period of inactivity after which the client sends a XEP-0199 ping // to the server. Specified in milliseconds, defaults to 20.000 (20 seconds). PeriodicServerPingsPeriod int }
Options are used to specify additional options for new clients, such as a Resource.
type PubsubEvent ¶
type PubsubEvent struct { Node string Items []PubsubItem }
type PubsubItem ¶
type PubsubItems ¶
type PubsubItems struct { Node string Items []PubsubItem }
type PubsubSubscription ¶
type PubsubUnsubscription ¶
type PubsubUnsubscription PubsubSubscription