catalogsync

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package catalogsync keeps the Controller's copy of the central catalog: it fetches the signed snapshot index, verifies it against the trusted keys, refuses anything not newer than what it has, checks every object's hash and size, and stores the snapshot in one transaction. A failed sync changes nothing: the last good snapshot stays in use.

Index

Constants

View Source
const DefaultURL = "https://catalog.shardkeep.gg/v1/"

DefaultURL is the central catalog.

Variables

View Source
var (
	// ErrNotNewer means the published snapshot is the one already stored:
	// nothing to do.
	ErrNotNewer = errors.New("the published catalog snapshot is the stored one")
	// ErrReplay means the published snapshot is older than the stored one:
	// an old snapshot replayed, or a stale mirror. It is refused.
	ErrReplay = errors.New("the published catalog snapshot is older than the stored one")
)
View Source
var TrustedKeys = []string{

	"ed25519:W6kFOkvxst2Hi83muQVc5vb+CVrrNbnrY4YjCpXOyyk=",

	"ed25519:YKn+mA9Gm8XiWChsFVBMgQqKR9WmhZPzdVtMzO6Xyw8=",
}

TrustedKeys are the public keys of the central catalog this release accepts snapshots from. A new key ships here before the catalog switches to it, and an old one is removed in the release after; see the catalog repository's deploy/README.md.

Functions

func CheckURL

func CheckURL(raw string) error

CheckURL accepts HTTPS catalog URLs only: the signature protects the content, TLS keeps a network attacker from withholding updates unseen.

func ParseKeys

func ParseKeys(keys []string) ([]format.PublicKey, error)

ParseKeys reads public keys written ed25519:<base64>.

Types

type Config

type Config struct {
	// URL is the snapshot directory, ending in /v1/ (a mirror works too).
	URL     string
	Trusted []format.PublicKey
	Store   *store.Store
	Client  *http.Client
	// UserAgent identifies the Controller (its version, nothing else).
	UserAgent string
	Logger    *slog.Logger
	// Interval between syncs (default an hour).
	Interval time.Duration
	Now      func() time.Time
}

Config wires the syncer.

type Status

type Status struct {
	LastAttempt time.Time
	LastSuccess time.Time
	// Error is the last attempt's error, empty after a success.
	Error string
}

Status is the outcome of the latest sync attempts.

type Syncer

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

Syncer syncs the catalog.

func New

func New(cfg Config) *Syncer

New returns a syncer.

func (*Syncer) Run

func (s *Syncer) Run(ctx context.Context)

Run syncs at once and then every interval until ctx ends.

func (*Syncer) Status

func (s *Syncer) Status() Status

Status returns the outcome of the latest sync attempts.

func (*Syncer) Sync

func (s *Syncer) Sync(ctx context.Context) (bool, error)

Sync fetches and stores the published snapshot if it is newer. It reports whether a new snapshot was stored.

Jump to

Keyboard shortcuts

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