trust

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package trust holds the server's peer allow-list and the two things built on it: a connection gater for enable_authentication, and the forwarding check for enable_forwarding.

The list is one list on purpose. "Peers this server trusts" means the same thing whichever feature consults it: with authentication on they are the only peers that may connect at all; with it off anyone may connect, and they are the only peers that may submit mail on someone else's behalf.

Index

Constants

View Source
const RegistryKey = "trust"

RegistryKey is the forge registry key under which the Peers are provided.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gater

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

Gater refuses inbound connections from peers outside the trusted set.

It decides at InterceptSecured, the first point at which the remote identity is authenticated by the Noise handshake, so an untrusted peer costs one handshake and never reaches the multiplexer. Outbound connections are not gated: the server dials on its own initiative — DHT, relay, push notifications — and a peer it chose to dial is not the exposure this guards against.

func NewGater

func NewGater(peers *Peers, logger *slog.Logger) *Gater

NewGater builds a gater over peers.

func (*Gater) InterceptAccept

func (g *Gater) InterceptAccept(network.ConnMultiaddrs) bool

func (*Gater) InterceptAddrDial

func (g *Gater) InterceptAddrDial(peer.ID, multiaddr.Multiaddr) bool

func (*Gater) InterceptPeerDial

func (g *Gater) InterceptPeerDial(peer.ID) bool

func (*Gater) InterceptSecured

func (g *Gater) InterceptSecured(dir network.Direction, id peer.ID, addrs network.ConnMultiaddrs) bool

func (*Gater) InterceptUpgraded

func (g *Gater) InterceptUpgraded(network.Conn) (bool, control.DisconnectReason)

type Peers

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

Peers is an immutable set of trusted peer identities.

func FromRegistry

func FromRegistry(reg *forge.Registry) *Peers

FromRegistry retrieves the configured set, or nil when none was provided.

func Parse

func Parse(ids []string) (*Peers, error)

Parse builds the set from encoded peer IDs. A malformed entry is an error rather than a skipped line: an operator who mistyped the one peer they meant to admit should find out at startup, not from a client that cannot connect.

func (*Peers) Contains

func (p *Peers) Contains(id peer.ID) bool

Contains reports whether id is trusted. A nil set trusts nobody.

func (*Peers) Len

func (p *Peers) Len() int

Len reports how many peers are trusted.

Jump to

Keyboard shortcuts

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