xmpp

package module
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: BSD-3-Clause Imports: 33 Imported by: 14

README

go-xmpp

go xmpp library (original was written by russ cox )

Documentation

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

View Source
const (
	// Version is current go-xmpp software version.
	Version = "0.3.4"

	// HT_SHA_256_ENDP used in XEP-0484: Fast Authentication Streamlining Tokens, https://xmpp.org/extensions/xep-0484.html
	HT_SHA_256_ENDP = "HT-SHA-256-ENDP"
	// HT_SHA_256_EXPR used in XEP-0484: Fast Authentication Streamlining Tokens, https://xmpp.org/extensions/xep-0484.html
	HT_SHA_256_EXPR = "HT-SHA-256-EXPR"
	// HT_SHA_256_NONE used in XEP-0484: Fast Authentication Streamlining Tokens, https://xmpp.org/extensions/xep-0484.html
	HT_SHA_256_NONE = "HT-SHA-256-NONE"
	// HT_SHA_256_UNIQ used in XEP-0484: Fast Authentication Streamlining Tokens, https://xmpp.org/extensions/xep-0484.html
	HT_SHA_256_UNIQ = "HT-SHA-256-UNIQ"

	// IQTypeError represents iq response type error.
	IQTypeError = "error"
	// IQTypeGet represents iq request type get.
	IQTypeGet = "get"
	// IQTypeResult represents iq response type result.
	IQTypeResult = "result"
	// IQTypeSet represents iq request type set.
	IQTypeSet = "set"

	// SCRAM_SHA_1_PLUS used in SASL auth process, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	SCRAM_SHA_1_PLUS = "SCRAM-SHA-1-PLUS"
	// SCRAM_SHA_1 used in SASL auth process, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	SCRAM_SHA_1 = "SCRAM-SHA-1"
	// SCRAM_SHA_256_PLUS used in SASL auth process, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	SCRAM_SHA_256_PLUS = "SCRAM-SHA-256-PLUS"
	// SCRAM_SHA_256 used in SASL auth process, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	SCRAM_SHA_256 = "SCRAM-SHA-256"
	// SCRAM_SHA_512_PLUS used in SASL auth process, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	SCRAM_SHA_512_PLUS = "SCRAM-SHA-512-PLUS"
	// SCRAM_SHA_512 used in SASL auth process, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	SCRAM_SHA_512 = "SCRAM-SHA-512"
	// UPGR_SCRAM_SHA_256 used in SASL auth process, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	UPGR_SCRAM_SHA_256 = "UPGR-SCRAM-SHA-256"
	// UPGR_SCRAM_SHA_512 used in SASL auth process, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	UPGR_SCRAM_SHA_512 = "UPGR-SCRAM-SHA-512"

	// XMPPNS_AVATAR_PEP_DATA represents xml namespace for https://xmpp.org/extensions/xep-0084.html#process-pubdata
	// (User Publishes Data).
	XMPPNS_AVATAR_PEP_DATA = "urn:xmpp:avatar:data"
	// XMPPNS_AVATAR_PEP_METADATA represents xml namespace for https://xmpp.org/extensions/xep-0084.html#process-pubmeta
	// (User Publishes Metadata Notification).
	XMPPNS_AVATAR_PEP_METADATA = "urn:xmpp:avatar:metadata"
	// XMPPNS_BIND_0 used in bunding resource identifier to a session as described in https://xmpp.org/extensions/xep-0386.html
	XMPPNS_BIND_0 = "urn:xmpp:bind:0"
	// XMPPNS_CLIENT namespace is a foundational XML namespace used in the Extensible Messaging and Presence Protocol
	// (XMPP) to scope the core client-to-server (C2S) communication stanzas.
	XMPPNS_CLIENT = "jabber:client"
	// XMPPNS_DISCO_INFO namespace used in Service Discovery protocol, https://xmpp.org/extensions/xep-0030.html
	XMPPNS_DISCO_INFO = "http://jabber.org/protocol/disco#info"
	// XMPPNS_DISCO_ITEMS namespace used in item discover queries, described https://xmpp.org/extensions/xep-0030.html#items
	XMPPNS_DISCO_ITEMS = "http://jabber.org/protocol/disco#items"
	// XMPPNS_FAST_0 namespace used in XEP-0484: Fast Authentication Streamlining Tokens, https://xmpp.org/extensions/xep-0484.html
	XMPPNS_FAST_0 = "urn:xmpp:fast:0"
	// XMPPNS_HTTP_UPLOAD_0 namespace used in XEP-0363: HTTP File Upload, https://xmpp.org/extensions/xep-0363.html
	XMPPNS_HTTP_UPLOAD_0 = "urn:xmpp:http:upload:0"
	// XMPPNS_IQ_VERSION namespace used in XEP-0092: Software Version, https://xmpp.org/extensions/xep-0092.html
	XMPPNS_IQ_VERSION = "jabber:iq:version"
	// XMPPNS_MUC namespace used in XEP-0045: Multi-User Chat, https://xmpp.org/extensions/xep-0045.html
	XMPPNS_MUC = "http://jabber.org/protocol/muc"
	// XMPPNS_MUC_USER namespace used in XEP-0045: Multi-User Chat, https://xmpp.org/extensions/xep-0045.html
	XMPPNS_MUC_USER = "http://jabber.org/protocol/muc#user"
	// XMPPNS_PING namespace used in XEP-0199: XMPP Ping, https://xmpp.org/extensions/xep-0199.html
	XMPPNS_PING = "urn:xmpp:ping"
	// XMPPNS_PUBSUB_EVENT namespace used in XEP-0060: Publish-Subscribe, https://xmpp.org/extensions/xep-0060.html
	XMPPNS_PUBSUB_EVENT = "http://jabber.org/protocol/pubsub#event"
	// XMPPNS_PUBSUB namespace used in XEP-0060: Publish-Subscribe, https://xmpp.org/extensions/xep-0060.html
	XMPPNS_PUBSUB = "http://jabber.org/protocol/pubsub"
	// XMPPNS_SASL_2 namespace used during SASL auth, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	XMPPNS_SASL_2 = "urn:xmpp:sasl:2"
	// XMPPNS_SASL_CB_0 namespace used during SASL auth, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	// and XEP-0440: SASL Channel-Binding Type Capability, https://xmpp.org/extensions/xep-0440.html
	XMPPNS_SASL_CB_0 = "urn:xmpp:sasl-cb:0"
	// XMPPNS_SASL_UPGRADE_0 namespace used during SASL auth, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	// and XEP-0480: SASL Upgrade Tasks, https://xmpp.org/extensions/xep-0480.html
	XMPPNS_SASL_UPGRADE_0 = "urn:xmpp:sasl:upgrade:0"
	// XMPPNS_XMPP_SASL namespace used during SASL auth, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	XMPPNS_XMPP_SASL = "urn:ietf:params:xml:ns:xmpp-sasl"
	// XMPPNS_SCRAM_UPGRADE_0 namespace used during SASL auth, as described in XEP-0388: Extensible SASL Profile, https://xmpp.org/extensions/xep-0388.html
	// and XEP-0480: SASL Upgrade Tasks, https://xmpp.org/extensions/xep-0480.html
	XMPPNS_SCRAM_UPGRADE_0 = "urn:xmpp:scram-upgrade:0"
	// XMPPNS_SID_0 namespace used in XEP-0359: Unique and Stable Stanza IDs, https://xmpp.org/extensions/xep-0359.html
	// to implement unique and relible id.
	XMPPNS_SID_0 = "urn:xmpp:sid:0"
	// XMPPNS_STREAM namespace used in description of clients xml data stream as described in XEP-0044: Full Namespace
	// Support for XML Streams, https://xmpp.org/extensions/xep-0044.html
	XMPPNS_STREAM = "http://etherx.jabber.org/streams"
	// XMPPNS_STREAM_LIMITS_0 namespace used during stream advertisement limits (on early connection init stage) as
	// described in XEP-0478: Stream Limits Advertisement, https://xmpp.org/extensions/xep-0478.html
	XMPPNS_STREAM_LIMITS_0 = "urn:xmpp:stream-limits:0"
	// XMPPNS_TIME namespace used in response to information query for client local time, as described in XEP-0202: Entity Time, https://xmpp.org/extensions/xep-0202.html
	XMPPNS_TIME = "urn:xmpp:time"
	// XMPPNS_XMPP_TLS namespace used during session initialization to start tls session, as described in https://www.ietf.org/rfc/rfc6120.txt
	XMPPNS_XMPP_TLS = "urn:ietf:params:xml:ns:xmpp-tls"
	// XMPPNS_XMPP_BIND namespace used during session initialization to start tls session, as described in https://www.ietf.org/rfc/rfc6120.txt
	XMPPNS_XMPP_BIND = "urn:ietf:params:xml:ns:xmpp-bind"
	// XMPPNS_XMPP_SESSION namespace used during xmpp session establisment process, as described in https://www.ietf.org/rfc/rfc6121.txt
	XMPPNS_XMPP_SESSION = "urn:ietf:params:xml:ns:xmpp-session"
)
View Source
const (
	NoHistory      = 0
	CharHistory    = 1
	StanzaHistory  = 2
	SecondsHistory = 3
	SinceHistory   = 4
)

Variables

View Source
var DefaultConfig = &tls.Config{} //nolint: gosec,G402 // In go1.25 TLS 1.2 used as default. Used by servers for older clients.

Default TLS configuration options

Functions

This section is empty.

Types

type AvatarData

type AvatarData struct {
	Data []byte
	From string
}

type AvatarMetadata

type AvatarMetadata struct {
	From   string
	Bytes  int
	Width  int
	Height int
	ID     string
	Type   string
	URL    string
}

type Chat

type Chat struct {
	Remote  string
	Type    string
	Text    string
	Subject string
	Thread  string
	// XEP-0066 Out-Of-Band url/desc
	Oob Oob
	// Deprecated Oob settings, use Oob.Url and Oob.Desc (above) instead.
	Ooburl  string
	Oobdesc string
	Lang    string
	// Only for incoming messages, ID for outgoing messages will be generated.
	OriginID string
	// Only for incoming messages, ID for outgoing messages will be generated.
	StanzaID  StanzaID
	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.
	Options          *Options // Connection Options, including reported software versions
	// contains filtered or unexported fields
}

Client holds XMPP connection options

func NewClient

func NewClient(host, user, passwd string, debug bool) (*Client, error)

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

func NewClientNoTLS(host, user, passwd string, debug bool) (*Client, error)

NewClientNoTLS creates a new client without TLS

func (*Client) ApproveSubscription

func (c *Client) ApproveSubscription(jid string)

func (*Client) AvatarRequestData

func (c *Client) AvatarRequestData(jid string) error

func (*Client) AvatarRequestDataByID

func (c *Client) AvatarRequestDataByID(jid, id string) error

func (*Client) AvatarRequestMetadata

func (c *Client) AvatarRequestMetadata(jid string) error

func (*Client) AvatarSubscribeMetadata

func (c *Client) AvatarSubscribeMetadata(jid string) error

func (*Client) AvatarUnsubscribeMetadata

func (c *Client) AvatarUnsubscribeMetadata(jid string) error

func (*Client) Close

func (c *Client) Close() error

Close closes the XMPP connection

func (*Client) DiscoverEntityItems

func (c *Client) DiscoverEntityItems(jid string) (string, error)

DiscoverEntityItems discovers items that an entity exposes.

func (*Client) DiscoverInfo added in v0.2.5

func (c *Client) DiscoverInfo(to string) (string, error)

DiscoverInfo discovers information about given item from given jid. Discovery query performed according to https://xmpp.org/extensions/xep-0030.html#info (Discovering Information About a Jabber Entity). The only difference between DiscoverInfo() and DiscoverNodeInfo() is that DiscoverInfo() does not supply From field, which is useful in very limited amount use cases.

func (*Client) DiscoverNodeInfo

func (c *Client) DiscoverNodeInfo(node string) (string, error)

DiscoverNodeInfo discovers information about a node. Empty node queries info about server itself. Discovery query performed according to https://xmpp.org/extensions/xep-0030.html#info (Discovering Information About a Jabber Entity).

func (*Client) DiscoverServerItems

func (c *Client) DiscoverServerItems() (string, error)

DiscoverServerItems discovers items that the server exposes. It is actually thin wrapper for DiscoverEntityItems().

func (*Client) Discovery

func (c *Client) Discovery() (string, error)

Discovery discovers items information according https://xmpp.org/extensions/xep-0030.html#items (Discovering the Items Associated with a Jabber Entity).

func (*Client) ErrorNotImplemented added in v0.2.15

func (c *Client) ErrorNotImplemented(v IQ, xmlns, feature string) (string, error)

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

func (c *Client) ErrorServiceUnavailable(v IQ, queryXmlns, node string) (string, error)

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) IqVersionResponse added in v0.3.0

func (c *Client) IqVersionResponse(v IQ, name string, version string, os string) (string, error)

IqVersionResponse responding with software version, according to example described in https://xmpp.org/extensions/xep-0092.html#example-2 (Receiving a Reply Regarding Software Version).

func (*Client) IsEncrypted

func (c *Client) IsEncrypted() bool

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

func (c *Client) JID() string

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 (c *Client) JoinMUCNoHistory(jid, nick string) (n int, err error)

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

func (c *Client) LeaveMUC(jid string) (n int, err error)

xep-0045 7.14

func (*Client) PingC2S

func (c *Client) PingC2S(jid, server string) error

func (*Client) PingS2S

func (c *Client) PingS2S(fromServer, toServer string) error

func (*Client) PubsubRequestItem

func (c *Client) PubsubRequestItem(node, jid, id string) error

func (*Client) PubsubRequestLastItems

func (c *Client) PubsubRequestLastItems(node, jid string) error

func (*Client) PubsubSubscribeNode

func (c *Client) PubsubSubscribeNode(node, jid string) error

func (*Client) PubsubUnsubscribeNode

func (c *Client) PubsubUnsubscribeNode(node, jid string) error

func (*Client) RawInformation

func (c *Client) RawInformation(from, to, id, iqType, body string) (string, error)

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

func (c *Client) Recv() (stanza interface{}, err error)

Recv waits to receive the next XMPP stanza.

func (*Client) RequestSubscription

func (c *Client) RequestSubscription(jid string)

func (*Client) RetrieveSubscription deprecated

func (c *Client) RetrieveSubscription(jid string)

Deprecated: Use RevertSubscription instead.

func (*Client) RevertSubscription added in v0.2.15

func (c *Client) RevertSubscription(jid string)

func (*Client) RevokeSubscription

func (c *Client) RevokeSubscription(jid string)

func (*Client) Roster

func (c *Client) Roster() error

Roster asks for the chat roster.

func (*Client) Send

func (c *Client) Send(chat Chat) (n int, err error)

Send sends the message wrapped inside an XMPP message stanza body.

func (*Client) SendHtml

func (c *Client) SendHtml(chat Chat) (n int, err error)

SendHtml sends the message as HTML as defined by XEP-0071

func (*Client) SendKeepAlive

func (c *Client) SendKeepAlive() (n int, err error)

SendKeepAlive sends a "whitespace keepalive" as described in chapter 4.6.1 of RFC6120.

func (*Client) SendOOB

func (c *Client) SendOOB(chat Chat) (n int, err error)

SendOOB sends OOB data wrapped inside an XMPP message stanza. Any message body will be discarded and replaced by the OOB URL..

func (*Client) SendOrg

func (c *Client) SendOrg(org string) (n int, err error)

SendOrg sends the original text without being wrapped in an XMPP message stanza.

func (*Client) SendPresence

func (c *Client) SendPresence(presence Presence) (n int, err error)

SendPresence sends Presence wrapped inside XMPP presence stanza.

func (*Client) SendResultPing

func (c *Client) SendResultPing(id, toServer string) error

func (*Client) SendTopic

func (c *Client) SendTopic(chat Chat) (n int, err error)

Send sends room topic wrapped inside an XMPP message stanza body.

func (*Client) UrnXMPPTimeResponse added in v0.3.0

func (c *Client) UrnXMPPTimeResponse(v IQ, timezoneOffset string) (string, error)

UrnXMPPTimeResponse implements response to query entity's current time accodring to https://xmpp.org/extensions/xep-0202.html#example-2 (A Response to the Query).

type Contact

type Contact struct {
	Remote string
	Name   string
	Group  []string
}
type Cookie uint64

Cookie is a unique XMPP session identifier

type Delay

type Delay struct {
	Stamp string `xml:"stamp,attr"`
}

type DiscoIdentity

type DiscoIdentity struct {
	Category string
	Type     string
	Name     string
}

type DiscoItem

type DiscoItem struct {
	Jid  string
	Name string
	Node string
}

type DiscoItems

type DiscoItems struct {
	Jid   string
	Items []DiscoItem
}

type DiscoResult

type DiscoResult struct {
	ID         string
	From       string
	To         string
	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 DiscoXField struct {
	Type  string   `xml:"type,attr"`
	Var   string   `xml:"var,attr"`
	Value []string `xml:"value"`
}

type Fast added in v0.2.0

type Fast struct {
	Token     string
	Mechanism string
	Expiry    time.Time
}

Fast holds the XEP-0484 fast token, mechanism and expiry date

type Get added in v0.3.0

type Get struct {
	XMLName xml.Name `xml:"get"`
	Url     string   `xml:"url,attr"`
}
type Header struct {
	XMLName xml.Name `xml:"header"`
	Name    string   `xml:"name,attr"`
	Value   string   `xml:",innerxml"`
}

type IQ

type IQ struct {
	ID    string
	From  string
	To    string
	Type  string
	Query []byte
}

type Oob added in v0.3.0

type Oob struct {
	XMLName xml.Name `xml:"x,xmlns:jabber:x:oob"`
	Url     string   `xml:"url"`
	Desc    string   `xml:"desc"`
}

Oob is an out-of-band url/description, used in file uploads. See https://xmpp.org/extensions/xep-0066.html

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

	// Timeout for ping replies. If no reply is received in this time period, the
	// connection is considered broken and gets closed. Specified in milliseconds,
	// defaults to 5.000 (5 seconds).
	PeriodicServerPingsTimeout int

	// ReportSoftwareVersion if set to true iq response will be generated
	// according to xep-0092. If set to false all iq version queries will be
	// silently ignored. By default set to false.
	ReportSoftwareVersion bool

	// SoftwareName is client software name (UserAgent in web browsers terms),
	// reported in response to information query as described in xep-0092.
	// By default it is "go-xmpp" (no quotes), and can be overridden here.
	// Responses can be enabled via ReportSoftwareVersion.
	SoftwareName string

	// SoftwareVersion reported in response to iq version as described in
	// xep-0092. If SoftwareName is not overridden in SoftwareName option go-xmpp
	// version will be reported. Otherwise set as "undefined" if not overridden
	// here.
	SoftwareVersion string

	// ReportSoftwareOS if set to true information about os go-xmpp being built
	// for will be reported. It considered not safe (secure) enough in xep-0092
	// for some unknown reasons, so by default this option set to false.
	ReportSoftwareOS bool
}

Options are used to specify additional options for new clients, such as a Resource.

func (Options) NewClient

func (o Options) NewClient() (*Client, error)

NewClient establishes a new Client connection based on a set of Options.

type Presence

type Presence struct {
	From        string
	To          string
	Type        string
	Show        string
	Status      string
	Priority    string
	ID          string
	Affiliation string
	Role        string
	JID         string
}

Presence is an XMPP presence notification.

type PubsubEvent

type PubsubEvent struct {
	Node  string
	Items []PubsubItem
}

type PubsubItem

type PubsubItem struct {
	ID       string
	InnerXML []byte
}

type PubsubItems

type PubsubItems struct {
	Node  string
	Items []PubsubItem
}

type PubsubSubscription

type PubsubSubscription struct {
	SubID  string
	JID    string
	Node   string
	Errors []string
}

type PubsubUnsubscription

type PubsubUnsubscription PubsubSubscription

type Put added in v0.3.0

type Put struct {
	XMLName xml.Name `xml:"put"`
	Url     string   `xml:"url,attr"`
	Headers []Header `xml:"header"`
}

type Roster

type Roster []Contact

type Slot added in v0.3.0

type Slot struct {
	// TODO: Maybe this doesn't belong here
	ID      string
	XMLName xml.Name `xml:"slot"`
	Put     Put
	Get     Get
}

type StanzaID added in v0.2.18

type StanzaID struct {
	XMLName xml.Name `xml:"stanza-id"`
	Text    string   `xml:",chardata"`
	Xmlns   string   `xml:"xmlns,attr"`
	ID      string   `xml:"id,attr"`
	By      string   `xml:"by,attr"`
}

XEP-0359 Stanza ID

type XMLElement

type XMLElement struct {
	XMLName  xml.Name
	Attr     []xml.Attr `xml:",any,attr"` // Save the attributes of the xml element
	InnerXML string     `xml:",innerxml"`
}

func (*XMLElement) String

func (e *XMLElement) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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