nodedirectory

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package nodedirectory verifies deployment configuration without performing I/O.

Index

Constants

View Source
const (
	Format                     = 1
	MaximumEnvelopeBytes       = 512 << 10
	MaximumNodes               = 256
	MaximumPublicSTUN          = 128
	MaximumCounter             = 1<<53 - 1
	DefaultGrace               = 7 * 24 * time.Hour
	MaximumCertificateLifetime = 180 * 24 * time.Hour
	MaximumPayloadLifetime     = 90 * 24 * time.Hour
	ClockSkew                  = 5 * time.Minute
	CertificateDomain          = "windshare/network-certificate/v1\x00"
	PayloadDomain              = "windshare/network-directory/v1\x00"
)

Variables

View Source
var (
	ErrFormat          = errors.New("invalid network directory")
	ErrSignature       = errors.New("network directory signature rejected")
	ErrExpired         = errors.New("network directory temporarily unavailable")
	ErrRollback        = errors.New("network directory rollback or equivocation")
	ErrAliasReassigned = errors.New("network directory alias reassigned")
)

Functions

func Accept

func Accept(highest Cursor, next Snapshot, now time.Time, grace time.Duration) error

func Compare

func Compare(highest, cursor Cursor) error

func RetainAliases

func RetainAliases(previous map[string]string, snapshot Snapshot) (map[string]string, error)

RetainAliases carries tombstones across removals and signing generations. A familiar alias must never silently select a different relay authority.

func Sign

func Sign(payload Payload, certificate SignedCertificate, key ed25519.PrivateKey, roots []Root) ([]byte, error)

Sign verifies the complete chain before exporting it, catching mismatched keys and generations locally rather than publishing an unusable directory.

func ValidAlias

func ValidAlias(alias string) bool

func Validate

func Validate(payload Payload) error

Types

type Certificate

type Certificate struct {
	Format     int       `json:"format"`
	Network    string    `json:"network"`
	Generation uint64    `json:"generation"`
	Key        string    `json:"key"`
	NotBefore  time.Time `json:"not_before"`
	ExpiresAt  time.Time `json:"expires_at"`
}

type Cursor

type Cursor struct {
	Generation uint64            `json:"generation"`
	Serial     uint64            `json:"serial"`
	Digest     [sha256.Size]byte `json:"digest"`
}

type Envelope

type Envelope struct {
	Payload     string            `json:"payload"`
	Certificate SignedCertificate `json:"certificate"`
	Signature   string            `json:"signature"`
}

type History

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

History authenticates immutable publication history without granting admission. Old publications establish alias ownership and rollback barriers even when they lack the node identity now required by runtime snapshots.

func VerifyHistory

func VerifyHistory(data []byte, network string, roots []Root) (History, error)

func (History) Cursor

func (history History) Cursor() Cursor

func (History) RetainAliases

func (history History) RetainAliases(previous map[string]string) (map[string]string, error)

type Node

type Node struct {
	Alias        string   `json:"alias"`
	NodeKey      string   `json:"node_key"`
	Relay        string   `json:"relay"`
	STUN         []string `json:"stun"`
	Roles        []string `json:"roles"`
	Zone         string   `json:"zone"`
	Region       string   `json:"region"`
	Provider     string   `json:"provider"`
	Operator     string   `json:"operator"`
	CapacityMbps uint32   `json:"capacity_mbps"`
	Status       Status   `json:"status"`
}

func (Node) HasRole

func (node Node) HasRole(role string) bool

type Payload

type Payload struct {
	Format     int            `json:"format"`
	Network    string         `json:"network"`
	Generation uint64         `json:"generation"`
	Serial     uint64         `json:"serial"`
	IssuedAt   time.Time      `json:"issued_at"`
	ExpiresAt  time.Time      `json:"expires_at"`
	Nodes      []Node         `json:"nodes"`
	PublicSTUN []STUNEndpoint `json:"public_stun"`
}

type Root

type Root struct {
	ID  string            `json:"id"`
	Key ed25519.PublicKey `json:"-"`
}

type STUNEndpoint

type STUNEndpoint struct {
	URL           string `json:"url"`
	Region        string `json:"region"`
	Provider      string `json:"provider"`
	FailureDomain string `json:"failure_domain"`
}

type SignedCertificate

type SignedCertificate struct {
	Root      string `json:"root"`
	Payload   string `json:"payload"`
	Signature string `json:"signature"`
}

func Certify

func Certify(certificate Certificate, rootID string, root ed25519.PrivateKey) (SignedCertificate, error)

type Snapshot

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

Snapshot retains verified bytes privately. Callers cannot mutate trusted data.

func Verify

func Verify(data []byte, network string, roots []Root) (Snapshot, error)

Verify authenticates expired snapshots too, so persisted rollback protection survives offline time. Usable/Accept separately decide whether new use is allowed.

func (Snapshot) Cursor

func (snapshot Snapshot) Cursor() Cursor

func (Snapshot) Envelope

func (snapshot Snapshot) Envelope() []byte

func (Snapshot) Payload

func (snapshot Snapshot) Payload() Payload

func (Snapshot) Resolve

func (snapshot Snapshot) Resolve(alias string) (string, bool)

func (Snapshot) TrustedUntil

func (snapshot Snapshot) TrustedUntil(grace time.Duration) time.Time

func (Snapshot) Usable

func (snapshot Snapshot) Usable(now time.Time, grace time.Duration) bool

type Status

type Status string
const (
	Canary   Status = "canary"
	Active   Status = "active"
	Draining Status = "draining"
)

Jump to

Keyboard shortcuts

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