clients

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Fed is a global federated matrix client. Safe for concurrent use.

Functions

func NewFederatedClient

func NewFederatedClient() *http.Client

NewFederatedClient returns a http.Client that uses the federated transport.

Types

type FederatedTripper

type FederatedTripper struct {
	// contains filtered or unexported fields
}

FederatedTripper implements http.RoundTripper interface with support for exponential backoff retries. This is used to talk to federated servers

func NewFederatedTripper

func NewFederatedTripper(maxRetries uint64) *FederatedTripper

func (*FederatedTripper) RoundTrip

func (tr *FederatedTripper) RoundTrip(req *http.Request) (*http.Response, error)

type RoutingInfo

type RoutingInfo struct {
	// The value we should assign to the Host header (host:port from the matrix
	// URI, or .well-known).
	HostHeader string
	// The server name we should set in the SNI (typically host, without port, from
	// the  matrix URI or .well-known)
	TLSServerName string
	// The hostname (or IP literal) we should route the TCP connection to (the
	// target of the  SRV record, or the hostname from the URL/.well-known)
	TargetHost string
	// The port we should route the TCP connection to (the target of the SRV
	// record, or the port from the URL/.well-known, or 8448)
	TargetPort uint16
}

RoutingInfo Contains the parameters needed to direct a federation connection to a particular server. Where a SRV record points to several servers, this object contains a single server chosen from the list.

func RouteMatrixURI

func RouteMatrixURI(resolve SRVResolveFunc, u *url.URL, lookupWellKnown bool) (*RoutingInfo, error)

RouteMatrixURI returns RoutingInfo that contains information about which server the request should be sent to.

resolve is used to resolve hostname for non IP hosts.

type SRVResolveFunc

type SRVResolveFunc func(address string) (*Server, error)

SRVResolveFunc is a function used to resolve srv records offederated matrix servers

func SrvResolver

func SrvResolver() SRVResolveFunc

SrvResolver returns a function that lookup for srv records of a host configured for matrix federation.

This caches the records, and the returned function is safe for concurrent use.

type Server

type Server struct {
	CName   string
	Records []*net.SRV
}

Server stores SRV records of a host that supports matrix federation.

func (*Server) Pick

func (s *Server) Pick() (*net.SRV, error)

Pick returns a random srv record.

type WellKnownResponse

type WellKnownResponse struct {
	Server string `json:"m.server"`
}

WellKnownResponse is a response returned from a federated matrix server for queries on /.well-known/matrix/server path.

func GetWellKnown

func GetWellKnown(address string) (*WellKnownResponse, error)

GetWellKnown sends a GET request to address looking for .well=known host address.

No caching is performed.

Jump to

Keyboard shortcuts

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