fed

package
v0.0.0-...-6ec6cac Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package fed implements federation (server-to-server requests).

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrActorGone      = errors.New("actor is gone")
	ErrNoLocalActor   = errors.New("no such local user")
	ErrActorNotCached = errors.New("actor is not cached")
	ErrBlockedDomain  = errors.New("domain is blocked")
	ErrInvalidScheme  = errors.New("invalid scheme")
	ErrInvalidHost    = errors.New("invalid host")
	ErrInvalidID      = errors.New("invalid actor ID")
	ErrSuspendedActor = errors.New("actor is suspended")
	ErrYoungActor     = errors.New("actor is too young")
)

Functions

This section is empty.

Types

type BlockList

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

BlockList is a list of blocked domains.

func NewBlockList

func NewBlockList(path string) (*BlockList, error)

func (*BlockList) Close

func (b *BlockList) Close()

Close frees resources.

func (*BlockList) Contains

func (b *BlockList) Contains(domain string) bool

Contains determines if a domain is blocked.

type Client

type Client interface {
	Do(*http.Request) (*http.Response, error)
}

Client is a HTTP client.

type Listener

type Listener struct {
	Domain   string
	Closed   bool
	Config   *cfg.Config
	DB       *sql.DB
	Resolver *Resolver
	ActorKey httpsig.Key
	Addr     string
	Cert     string
	Key      string
	Plain    bool
}

func (*Listener) ListenAndServe

func (l *Listener) ListenAndServe(ctx context.Context) error

ListenAndServe handles HTTP requests from other servers.

type Queue

type Queue struct {
	Domain   string
	Config   *cfg.Config
	DB       *sql.DB
	Resolver *Resolver
}

func (*Queue) Process

func (q *Queue) Process(ctx context.Context) error

Process polls the queue of outgoing activities and delivers them to other servers. Delivery happens in batches, with multiple workers, timeout and retries. The listing of additional activities and recipients runs in parallel with delivery. If possible, wide deliveries (e.g. public posts) are performed using the sharedInbox endpoint, greatly reducing the number of outgoing requests when many recipients share the same endpoint.

type Resolver

type Resolver struct {
	BlockedDomains *BlockList
	// contains filtered or unexported fields
}

Resolver retrieves actor objects given their ID. Actors are cached, updated periodically and deleted if gone from the remote server.

func NewResolver

func NewResolver(blockedDomains *BlockList, domain string, cfg *cfg.Config, client Client, db *sql.DB) *Resolver

NewResolver returns a new Resolver.

func (*Resolver) Get

func (s *Resolver) Get(ctx context.Context, key httpsig.Key, url string) (*http.Response, error)

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, key httpsig.Key, host, name string, flags ap.ResolverFlag) (*ap.Actor, error)

Resolve retrieves an actor object by host and name.

func (*Resolver) ResolveID

func (r *Resolver) ResolveID(ctx context.Context, key httpsig.Key, id string, flags ap.ResolverFlag) (*ap.Actor, error)

ResolveID retrieves an actor object by its ID.

type Syncer

type Syncer struct {
	Domain   string
	Config   *cfg.Config
	DB       *sql.DB
	Resolver *Resolver
	Key      httpsig.Key
}

func (*Syncer) Run

func (s *Syncer) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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