router

package
Version: v0.0.0-...-aeec266 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotExistingAccount will be returned if destination user does not exist.
	ErrNotExistingAccount = errors.New("route: account does not exist")

	// ErrResourceNotFound will be returned if destination resource does not match any of user's available resource.
	ErrResourceNotFound = errors.New("route: resource not found")

	// ErrNotAuthenticated will be returned if destination user is not authenticated at this time.
	ErrNotAuthenticated = errors.New("route: user not authenticated")

	// ErrBlockedJID will be returned if destination user is not authenticated at this time.
	ErrBlockedJID = errors.New("route: destination JID is blocked")

	// ErrFailedRemoteConnect will be returned if it couldn't establish a connection to the remote server.
	ErrFailedRemoteConnect = errors.New("route: failed remote connection")
)

Functions

This section is empty.

Types

type C2SRouter

type C2SRouter interface {
	// Route routes a stanza applying server rules for handling XML stanzas.
	// (https://xmpp.org/rfcs/rfc3921.html#rules)
	Route(ctx context.Context, stanza xmpp.Stanza, validateStanza bool) error

	// Bind sets a c2s stream as bound.
	Bind(stm stream.C2S)

	// Unbind unbinds a previously bound c2s stream.
	Unbind(username, resource string)

	// Stream returns the stream associated to a given username and resource.
	Stream(username, resource string) stream.C2S

	// Streams returns all steams associated to a given username.
	Streams(username string) []stream.C2S
}

C2SRouter represents a router between client and server.

type Router

type Router interface {
	// Hosts returns router hosts container.
	Hosts() *host.Hosts

	// Route routes a stanza applying server rules for handling XML stanzas.
	// (https://xmpp.org/rfcs/rfc3921.html#rules)
	Route(ctx context.Context, stanza xmpp.Stanza) error

	// MustRoute forces stanza routing by ignoring user's blocking list.
	MustRoute(ctx context.Context, stanza xmpp.Stanza) error

	// Bind sets a c2s stream as bound.
	Bind(ctx context.Context, stm stream.C2S)

	// Unbind unbinds a previously bound c2s stream.
	Unbind(ctx context.Context, j *jid.JID)

	// LocalStream returns the steam associated to a given username and resource.
	LocalStream(username, resource string) stream.C2S

	// LocalStreams returns all steams associated to a given username.
	LocalStreams(username string) []stream.C2S
}

Router represents a router between two entities.

func New

func New(hosts *host.Hosts, c2sRouter C2SRouter, s2sRouter S2SRouter) (Router, error)

New creates a new router.

type S2SRouter

type S2SRouter interface {
	// Route routes a stanza applying server rules for handling XML stanzas.
	// (https://xmpp.org/rfcs/rfc3921.html#rules)
	Route(ctx context.Context, stanza xmpp.Stanza, localDomain string) error
}

S2SRouter represents a router between server and server.

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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