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: 8 Imported by: 9



Package dial contains methods and types for dialing XMPP connections.



This section is empty.


This section is empty.


func Client

func Client(ctx context.Context, network string, addr jid.JID) (net.Conn, error)

Client discovers and connects to the address on the named network with a client-to-server (c2s) connection.

For more information see the Dialer type.

func Server

func Server(ctx context.Context, network string, addr jid.JID) (net.Conn, error)

Server discovers and connects to the address on the named network with a server-to-server connection (s2s).

For more info see the Dialer type.


type Dialer

type Dialer struct {

	// NoLookup stops the dialer from looking up SRV or TXT records for the given
	// domain. It also prevents fetching of the host metadata file.
	// Instead, it will try to connect to the domain directly.
	NoLookup bool

	// S2S causes the server to attempt to dial a server-to-server connection.
	S2S bool

	// Disable TLS entirely (eg. when using StartTLS on a server that does not
	// support implicit TLS).
	NoTLS bool

	// Attempt to create a TLS connection by first looking up SRV records (unless
	// NoLookup is set) and then attempting to use the domains A or AAAA record.
	// The nil value is interpreted as a tls.Config with the expected host set to
	// that of the connection addresses domain part.
	TLSConfig *tls.Config

A Dialer contains options for connecting to an XMPP address. After a connection is established the Dial method does not attempt to create an XMPP session on the connection.

The zero value for each field is equivalent to dialing without that option. Dialing with the zero value of Dialer is equivalent to calling the Client function.

func (*Dialer) Dial

func (d *Dialer) Dial(ctx context.Context, network string, addr jid.JID) (net.Conn, error)

Dial discovers and connects to the address on the named network. It will attempt to look up SRV records for the JIDs domainpart or connect to the domainpart directly if dialing the SRV records fails or is disabled.

If the context expires before the connection is complete, an error is returned. Once successfully connected, any expiration of the context will not affect the connection.

Network may be any of the network types supported by net.Dial, but you most likely want to use one of the tcp connection types ("tcp", "tcp4", or "tcp6").

Jump to

Keyboard shortcuts

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