transport

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGETSigner added in v0.3.4

func NewGETSigner(expiresIn int64) (httpsig.SignerWithOptions, error)

NewGETSigner returns a new httpsig.Signer instance initialized with GTS GET preferences.

func NewPOSTSigner added in v0.3.4

func NewPOSTSigner(expiresIn int64) (httpsig.SignerWithOptions, error)

NewPOSTSigner returns a new httpsig.Signer instance initialized with GTS POST preferences.

Types

type Controller

type Controller interface {
	// NewTransport returns an http signature transport with the given public key ID (URL location of pubkey), and the given private key.
	NewTransport(pubKeyID string, privkey *rsa.PrivateKey) (Transport, error)

	// NewTransportForUsername searches for account with username, and returns result of .NewTransport().
	NewTransportForUsername(ctx context.Context, username string) (Transport, error)
}

Controller generates transports for use in making federation requests to other servers.

func NewController

func NewController(state *state.State, federatingDB federatingdb.DB, clock pub.Clock, client pub.HttpClient) Controller

NewController returns an implementation of the Controller interface for creating new transports

type Transport

type Transport interface {

	// POST will perform given the http request using
	// transport client, retrying on certain preset errors.
	POST(*http.Request, []byte) (*http.Response, error)

	// Deliver sends an ActivityStreams object.
	Deliver(ctx context.Context, b []byte, to *url.URL) error

	// BatchDeliver sends an ActivityStreams object to multiple recipients.
	BatchDeliver(ctx context.Context, b []byte, recipients []*url.URL) error

	// GET will perform the given http request using
	// transport client, retrying on certain preset errors.
	GET(*http.Request) (*http.Response, error)

	// Dereference fetches the ActivityStreams object located at this IRI with a GET request.
	Dereference(ctx context.Context, iri *url.URL) (*http.Response, error)

	// DereferenceMedia fetches the given media attachment IRI, returning the reader and filesize.
	DereferenceMedia(ctx context.Context, iri *url.URL) (io.ReadCloser, int64, error)

	// DereferenceInstance dereferences remote instance information, first by checking /api/v1/instance, and then by checking /.well-known/nodeinfo.
	DereferenceInstance(ctx context.Context, iri *url.URL) (*gtsmodel.Instance, error)

	// Finger performs a webfinger request with the given username and domain, and returns the bytes from the response body.
	Finger(ctx context.Context, targetUsername string, targetDomain string) ([]byte, error)
}

Transport implements the pub.Transport interface with some additional functionality for fetching remote media.

Since the transport has the concept of 'shortcuts' for fetching data locally rather than remotely, it is not *always* the case that calling a Transport function does an http call, but it usually will for remote hosts or resources for which a shortcut isn't provided by the transport controller (also in this package).

For any of the transport functions, if a Fastfail context is passed in as the first parameter, the function will return after the first transport failure, instead of retrying + backing off.

Jump to

Keyboard shortcuts

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