discover

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

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

Errors returned by this package.

Functions

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 LookupService

func LookupService(ctx context.Context, resolver *net.Resolver, service string, addr jid.JID) (addrs []*net.SRV, notPresent bool, 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 an empty list and a nil error (it does not pass through a "not found" error). If notPresent is true it indicates that the server explicitly does not support this service (ie. we shouldn't try fallbacks or defaults). Service should be one of "xmpp[s]-client" or "xmpp[s]-server".

func LookupServiceByDomain added in v0.22.0

func LookupServiceByDomain(ctx context.Context, resolver *net.Resolver, service string, domain string) (addrs []*net.SRV, notPresent bool, err error)

LookupServiceByDomain behaves exactly the same as LookupService, besides that the domain it tries to connect to is given as argument instead of using the domainpart of the JID.

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.

Types

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:"http://docs.oasis-open.org/ns/xri/xrd-1.0 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='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.

Jump to

Keyboard shortcuts

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