node

package
v0.1.0-preview.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxStoredItems             = 1_000_000
	MaxItemsPerRoute           = 1024
	PerItemAccountingOverhead  = 4 * 1024
	MaxStoredItemEncodingBytes = protocol.DefaultMaxItemBytes*2 + 64*1024
	MaxDeleteTombstoneBytes    = 16 * 1024
)

Variables

View Source
var (
	ErrNotFound      = errors.New("item not found")
	ErrMailboxQuota  = errors.New("route-tag quota exceeded")
	ErrStorageFull   = errors.New("node storage capacity exceeded")
	ErrStoreClosed   = errors.New("node store is closed")
	ErrInvalidItemID = errors.New("invalid item id")
	ErrInvalidLimits = errors.New("invalid store limits")
	ErrItemDeleted   = errors.New("item is covered by a delete tombstone")
	ErrCorruptStore  = errors.New("node store contains an invalid or unmanaged record")
	ErrStoreIdentity = errors.New("node store identity does not match the signing key")
	ErrUnboundStore  = errors.New("non-empty node store has no identity binding")
)
View Source
var (
	ErrNodeSigningKeyMissing = errors.New("node signing key is missing")
)

Functions

func LoadOrCreateSigner

func LoadOrCreateSigner(path string) (*pqcrypto.HybridSigner, error)

LoadOrCreateSigner is a one-shot provisioning helper. A running node must use AcquireNodeSigner so the identity cannot be active in two processes.

func RandomChallenge

func RandomChallenge() ([]byte, error)

func ValidateServerTransport

func ValidateServerTransport(listenAddress string, tlsEnabled, allowPrivateHTTP bool) error

ValidateServerTransport prevents accidental public cleartext operation. Plain HTTP is permitted by default only on loopback and, with an explicit development switch, on literal private addresses. Unspecified/wildcard and public listeners always require TLS.

Types

type Config

type Config struct {
	ListenAddress         string
	DataDir               string
	KeyFile               string
	BaseDifficulty        uint8
	EpochSeconds          int64
	MaxItemBytes          int
	StorageCapacity       int64
	MailboxQuota          int64
	MaxFetchItems         int
	MaxFetchBytes         int64
	SweepInterval         time.Duration
	MaxConcurrentRequests int
}

func DefaultConfig

func DefaultConfig() Config

func (Config) EffectiveDifficulty

func (c Config) EffectiveDifficulty(used int64) uint8

func (Config) Validate

func (c Config) Validate() error

type DiskStore

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

func NewDiskStore

func NewDiskStore(dir string, capacity, routeQuota int64) (*DiskStore, error)

func (*DiskStore) BindIdentity

func (s *DiskStore) BindIdentity(signer *pqcrypto.HybridSigner) error

BindIdentity permanently ties this store directory to the node's hybrid signing identity. Existing pre-binding stores must be empty so accidentally replacing a lost key can never make old retained data appear under a new node identity.

func (*DiskStore) BoundIdentity

func (s *DiskStore) BoundIdentity() (protocol.NodePublicIdentity, bool)

BoundIdentity returns the authenticated identity persisted in this store.

func (*DiskStore) Close

func (s *DiskStore) Close() error

func (*DiskStore) FetchLimited

func (s *DiskStore) FetchLimited(routeTags []string, maxItems int, maxBytes int64) ([]protocol.StoredItem, bool)

func (*DiskStore) Get

func (s *DiskStore) Get(itemID string) (protocol.StoredItem, error)

func (*DiskStore) IdentityInitializationAllowed

func (s *DiskStore) IdentityInitializationAllowed() bool

IdentityInitializationAllowed reports whether a fresh identity binding can be created without orphaning retained items or tombstones.

func (*DiskStore) Put

func (s *DiskStore) Put(item protocol.StoredItem) error

func (*DiskStore) Sweep

func (s *DiskStore) Sweep(now time.Time) error

func (*DiskStore) SweepContext

func (s *DiskStore) SweepContext(ctx context.Context, now time.Time) error

SweepContext removes expired records in bounded batches. The store mutex is released between batches so shutdown never waits behind up to MaxStoredItems filesystem mutations.

func (*DiskStore) Used

func (s *DiskStore) Used() int64

type NodeSignerLease

type NodeSignerLease struct {
	Signer  *pqcrypto.HybridSigner
	Created bool
	// contains filtered or unexported fields
}

NodeSignerLease keeps exclusive ownership of a node identity for the whole server lifetime. Closing it allows a later process to acquire the identity.

func AcquireNodeSigner

func AcquireNodeSigner(path string, allowCreate bool) (*NodeSignerLease, error)

AcquireNodeSigner loads a node signer under a nonblocking lifetime lease. When allowCreate is false, a missing key fails closed instead of silently changing an identity already bound to retained node data.

func (*NodeSignerLease) Close

func (lease *NodeSignerLease) Close() error

type Server

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

func NewServer

func NewServer(config Config, store *DiskStore, signer *pqcrypto.HybridSigner) (*Server, error)

func (*Server) EnableDirectory

func (s *Server) EnableDirectory(agent *nodedir.Agent) error

EnableDirectory installs the signed node-directory endpoints. It must be called during startup, before Handler is served.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Jump to

Keyboard shortcuts

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