router

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LowWaterMark    = 100
	HighWaterMark   = 400
	ConnGracePeriod = 1 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	ControlPlaneURL    string
	ListenAddrs        []string
	ExternalAddrs      []string
	KeysSyncInterval   time.Duration
	LeaseRenewInterval time.Duration
	OIDCProvider       string // For OIDC enrollment
	OIDCToken          string // OIDC JWT token for enrollment
	BootstrapToken     string // Pre-shared bootstrap token for enrollment
	BootstrapTokenPath string // File path containing pre-shared bootstrap token
	JWTPath            string // File path containing OIDC JWT token
	KeysDBPath         string // Path to save peer private key
	AllowLoopback      bool
	BiscuitTimeout     time.Duration
	LogVerbose         bool
	DHTProviderAddrTTL time.Duration
	DHTMaxRecordAge    time.Duration
	// RequiredRole restricts enrollment and startup to only accept tokens containing this role.
	RequiredRole string
}

Options holds configuration details for the sam-router.

func (*Options) Default

func (o *Options) Default()

Default sets default values for options.

func (*Options) Validate

func (o *Options) Validate() error

Validate ensures options are valid.

type Router

type Router struct {
	Host       host.Host
	DHT        *dht.IpfsDHT
	PubSub     *pubsub.PubSub
	EventTopic *pubsub.Topic
	// contains filtered or unexported fields
}

Router represents a libp2p bootstrap/relay node.

func NewRouter

func NewRouter(ctx context.Context, config Options) (*Router, error)

NewRouter initializes the router.

func (*Router) Close

func (r *Router) Close() error

Close closes the underlying p2p host and keyring db.

func (*Router) HandleAuthHandshake

func (r *Router) HandleAuthHandshake(s network.Stream)

HandleAuthHandshake processes incoming auth connections. It is part of mutual auth: 1. Receives client's Biscuit. 2. Verifies it against CP public keys. 3. Responds with success and the router's own Biscuit.

func (*Router) RefreshEnrollment

func (r *Router) RefreshEnrollment(ctx context.Context) error

RefreshEnrollment trades the expiring biscuit token for a new one using a cryptographic challenge.

func (*Router) Start

func (r *Router) Start() error

Start performs enrollment, syncs keys, launches libp2p host, and starts tasks.

Jump to

Keyboard shortcuts

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