v0.21.4 Latest Latest

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

Go to latest
Published: Jan 11, 2023 License: BSD-2-Clause Imports: 9 Imported by: 0



Package discover is used to look up information about XMPP-based services.



This section is empty.


View Source
var (
	ErrInvalidService = errors.New("service must be one of xmpp[s]-client or xmpp[s]-server")

Errors returned by this package.


func FallbackRecords added in v0.18.0

func FallbackRecords(service, domain string) []*net.SRV

FallbackRecords returns fake SRV records based on the service that can be used if no actual SRV records can be found but we believe that an XMPP service exists at the given domain.

func LookupBOSH

func LookupBOSH(ctx context.Context, client *http.Client, addr jid.JID) (urls []string, err error)

LookupBOSH discovers BOSH endpoints that are valid for the given address using Web Host Metadata as described in XEP-0156.

func LookupPort

func LookupPort(network, service string) (uint16, error)

LookupPort returns the default port for the provided network and service using net.LookupPort. If the provided service is one of xmpp[s]-client, xmpp[s]-server, or xmpp-bosh and it is not found by net.LookupPort, a default value is returned.

func LookupService

func LookupService(ctx context.Context, resolver *net.Resolver, service string, addr jid.JID) (addrs []*net.SRV, err error)

LookupService looks for an XMPP service hosted by the given address. It returns addresses from SRV records and if none are found returns several fallback records using the default domain of the JID and common ports on which XMPP servers listen for implicit TLS connections. If the target of the first record is "." it is removed and an empty list is returned. Service should be one of "xmpp[s]-client" or "xmpp[s]-server".

func LookupWebSocket added in v0.18.0

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 Web Host Metadata as described in RFC7395.


type Link struct {
	Rel  string `xml:"rel,attr" json:"rel"`
	Href string `xml:"href,attr" json:"href"`

Link is an individual hyperlink in an XRD document.

type XRD

type XRD struct {
	XMLName xml.Name `xml:" XRD"`
	Links   []Link   `xml:"Link" json:"links"`

XRD represents an Extensible Resource Descriptor document of the form:

<?xml version='1.0' encoding=utf-9'?>
<XRD xmlns=''>
  <Link rel="urn:xmpp:alt-connections:xbosh"
        href="" />
  <Link rel="urn:xmpp:alt-connections:websocket"
        href="wss://" />

as defined by RFC 6415 and OASIS.XRD-1.0.

Jump to

Keyboard shortcuts

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