cluster

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package cluster defines the shared-secret membership primitive used by r1s transports.

Index

Constants

View Source
const (
	KeySize = realm.KeySize

	DestinationSize          = 16
	MaxBootstrapDestinations = 32
	DefaultRelPath           = ".config/r1s/realms"
)

Variables

View Source
var (
	ErrInvalidKey   = errors.New("invalid cluster key")
	ErrInvalidToken = errors.New("invalid cluster join token")
	ErrInvalidState = errors.New("invalid cluster state")
	ErrStateExists  = errors.New("cluster state already exists")
	ErrNotFound     = errors.New("cluster credential not found")
	ErrAmbiguous    = errors.New("ambiguous cluster identifier")
)

Functions

func CredentialToken added in v0.5.1

func CredentialToken(credential Credential) (string, error)

CredentialToken serializes a membership for transfer. Key-only credentials encode directly; credentials with routing hints serialize a versioned payload under the same r1s1 prefix. The hints remain public, non-authoritative data.

func DefaultDirectory added in v0.4.0

func DefaultDirectory() (string, error)

DefaultDirectory returns the per-user credential directory shared by both clients and allocators.

func Generate

func Generate() ([]byte, error)

func ID

func ID(key []byte) ([]byte, error)

func List added in v0.4.0

func List(directory string) ([]string, error)

List returns valid credential IDs in lexical order. Unrelated files and the legacy single-file store outside directory are ignored.

func Load

func Load(path string) ([]byte, error)

func NormalizeBootstrapDestinations added in v0.5.1

func NormalizeBootstrapDestinations(destinations []string) ([]string, error)

NormalizeBootstrapDestinations validates, lower-cases, deduplicates, sorts, and bounds 16-byte RNS destination hashes.

func OpenRealm added in v0.5.0

func OpenRealm(key []byte) (*realm.Realm, error)

OpenRealm uses the standard meshbus realm profile. r1s keeps cluster as its product-facing name, but no longer maintains separate ID or authentication domains below that API.

func ParseToken

func ParseToken(value string) ([]byte, error)

func RecordBootstrapDestination added in v0.5.1

func RecordBootstrapDestination(path, destination string) error

RecordBootstrapDestination durably adds one public allocator destination to an existing credential without changing its realm key.

func Resolve added in v0.4.0

func Resolve(directory, selector string) ([]byte, string, error)

Resolve loads the credential selected by a unique public-ID prefix.

func RunCommand

func RunCommand(arguments []string, directory string, stdout, stderr io.Writer) error

RunCommand implements the shared `cluster init|join|list|token` command surface.

func SaveCredential added in v0.4.0

func SaveCredential(directory string, key []byte) (string, error)

SaveCredential atomically stores key under its full derived public ID. An existing credential for the same cluster is an idempotent success.

func SaveMembership added in v0.5.1

func SaveMembership(directory string, credential Credential) (string, error)

SaveMembership persists a transferred credential and merges its validated public routing hints with any hints already learned locally.

func SaveNew

func SaveNew(path string, key []byte) error

SaveNew creates state without replacing an existing membership. Rejoining the same cluster is idempotent; changing membership requires an explicit future rotation operation.

func Token

func Token(key []byte) (string, error)

Types

type Credential added in v0.5.1

type Credential struct {
	Key                   []byte
	BootstrapDestinations []string
}

Credential keeps the realm membership secret separate from public RNS routing hints. Bootstrap destinations grant no authority; every connection still has to prove possession of Key before an r1s envelope is delivered.

func LoadCredential added in v0.5.1

func LoadCredential(path string) (Credential, error)

LoadCredential reads the cluster state and its bounded public bootstrap destinations.

func ParseCredentialToken added in v0.5.1

func ParseCredentialToken(value string) (Credential, error)

ParseCredentialToken parses a membership token carrying a realm key and optional bounded public allocator destinations.

func ResolveCredential added in v0.5.1

func ResolveCredential(directory, selector string) (Credential, string, error)

ResolveCredential loads the selected membership and its durable public bootstrap hints.

type State

type State struct {
	Version               int      `json:"version"`
	Key                   string   `json:"key"`
	BootstrapDestinations []string `json:"bootstrapDestinations,omitempty"`
}

Jump to

Keyboard shortcuts

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