Documentation ¶
Overview ¶
Package internal provides non-exported functionality used by xmpp and its child packages.
Index ¶
- Constants
- Variables
- func GetAttr(attr []xml.Attr, local string) string
- func LookupBOSH(ctx context.Context, client *http.Client, addr *jid.JID) (urls []string, err error)
- func LookupPort(network, service string) (int, error)
- func LookupService(service, network string, addr net.Addr) (addrs []*net.SRV, err error)
- func LookupWebsocket(ctx context.Context, client *http.Client, addr *jid.JID) (urls []string, err error)
- func RandomID() string
- type Link
- type StreamInfo
- type Version
- type XRD
Constants ¶
const IDLen = 16
IDLen is the standard length of stanza identifiers in bytes.
const (
XMLHeader = `<?xml version="1.0" encoding="UTF-8"?>`
)
Variables ¶
var ( DefaultVersion = Version{1, 0} // The default version to send. EmptyVersion = Version{0, 9} // The value of a missing version attribute. )
Common XMPP versions.
var (
ErrNoServiceAtAddress = errors.New("This address does not offer the requested service")
)
Errors related to address and service lookups.
Functions ¶
func GetAttr ¶
GetAttr returns the value of the first attribute with the provided local name from a list of attributes or an empty string if no such attribute exists.
func LookupBOSH ¶
LookupBOSH discovers BOSH endpoints that are valid for the given address using DNS TXT records and Web Host Metadata as described in XEP-0156. If client is nil, only DNS is queried.
func LookupPort ¶
LookupPort returns the default port for the provided network and service using net.LookupPort. If the provided service is one of xmpp-client, xmpp-server, or xmpp-bosh and it is not found by net.LookupPort, a default value is returned.
func LookupService ¶
LookupService looks for an XMPP service hosted by the given address. It returns addresses from SRV records or the default domain (as a fake SRV record) if no real records exist. Service should be one of "xmpp-client" or "xmpp-server".
func LookupWebsocket ¶
func LookupWebsocket(ctx context.Context, client *http.Client, addr *jid.JID) (urls []string, err error)
LookupWebsocket discovers websocket endpoints that are valid for the given address using DNS TXT records and Web Host Metadata as described in XEP-0156. If client is nil, only DNS is queried.
Types ¶
type StreamInfo ¶ added in v0.1.0
type StreamInfo struct {
// contains filtered or unexported fields
}
func ExpectNewStream ¶ added in v0.1.0
func ExpectNewStream(ctx context.Context, d xml.TokenReader, recv bool) (streamData StreamInfo, err error)
func SendNewStream ¶ added in v0.1.0
func SendNewStream(rw io.ReadWriter, s2s bool, version Version, lang language.Tag, location, origin, id string) (StreamInfo, error)
Sends a new XML header followed by a stream start element on the given io.Writer. We don't use an xml.Encoder both because Go's standard library xml package really doesn't like the namespaced stream:stream attribute and because we can guarantee well-formedness of the XML with a print in this case and printing is much faster than encoding. Afterwards, clear the StreamRestartRequired bit and set the output stream information.
type Version ¶
Version is a version of XMPP.
func MustParseVersion ¶
MustParseVersion parses a version string and panics if an error is returned.
func ParseVersion ¶
ParseVersion parses a string of the form "Major.Minor" into a Version struct or returns an error.
func (Version) Less ¶
Less compares the major and minor version numbers, returning true if a is less than b.
func (Version) MarshalXMLAttr ¶
MarshalXMLAttr satisfies the MarshalerAttr interface and marshals the version as an XML attribute using its string representation.
type XRD ¶
type XRD struct { XMLName xml.Name `xml:"http://docs.oasis-open.org/ns/xri/xrd-1.0 XRD"` Links []Link `xml:"Link"` }
XRD represents an Extensible Resource Descriptor document of the form:
<?xml version='1.0' encoding=utf-9'?> <XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'> … <Link rel="urn:xmpp:alt-connections:xbosh" href="https://web.example.com:5280/bosh" /> <Link rel="urn:xmpp:alt-connections:websocket" href="wss://web.example.com:443/ws" /> … </XRD>
as defined by RFC 6415 and OASIS.XRD-1.0.
Directories ¶
Path | Synopsis |
---|---|
Package ns provides namespace constants that are used by the xmpp package and other internal packages.
|
Package ns provides namespace constants that are used by the xmpp package and other internal packages. |
Package saslerr provides error conditions for the XMPP profile of SASL as defined by RFC 6120 §6.5.
|
Package saslerr provides error conditions for the XMPP profile of SASL as defined by RFC 6120 §6.5. |