config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: BSD-3-Clause Imports: 24 Imported by: ? modules, 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

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultRoot            = "/tb"
	DefaultP2PListenFormat = "/ip4/0.0.0.0/tcp/%d"
	DefaultHTTPListen      = "0.0.0.0:443"
)
View Source
var WaitForSwamDuration = 10 * time.Second

Functions

func EnterpriseConfig

func EnterpriseConfig(c Config, service string) (yaml.Node, bool)

EnterpriseConfig returns the raw enterprise.<service> config node when present. tau/spore-drive treat the enterprise config opaquely; an ee service decodes its own block from this node, so no service schema lives in the public tree.

func NewLiteNode

func NewLiteNode(ctx context.Context, c Config, storagePath string) (peer.Node, error)

func NewNode

func NewNode(ctx context.Context, c Config, storagePath string) (peer.Node, error)

Types

type Accounts

type Accounts struct {
	SessionTTL string        `yaml:"session-ttl,omitempty"`
	Email      AccountsEmail `yaml:"email"`
}

Accounts holds runtime configuration for the Accounts subsystem.

AccountsURL and WebAuthn are derived from NetworkFqdn at runtime (core/services/accounts/url.go). VerifyOnAuth is a package-level global, not a config field.

type AccountsEmail

type AccountsEmail struct {
	SMTP SMTP `yaml:"smtp,omitempty"`
}

AccountsEmail configures the magic-link sender. Stdout fallback auto- enables in DevMode; rate limits are hardcoded.

type AcmeCAConfig

type AcmeCAConfig struct {
	RootCA     string `yaml:"root-ca"`
	CAARecord  string `yaml:"caa-record"`
	SkipVerify bool   `yaml:"skip"`
}

type AcmeConfig

type AcmeConfig struct {
	Url string        `yaml:"url"`
	CA  *AcmeCAConfig `yaml:"ca,omitempty"`
	Key string        `yaml:"key"`
}

type Bundle

type Bundle struct {
	Origin BundleOrigin `yaml:"origin"`
	Source
}

type BundleOrigin

type BundleOrigin struct {
	Shape     string    `yaml:"shape"`
	Host      string    `yaml:"host"`
	Creation  time.Time `yaml:"time"`
	Version   *string   `yaml:"version,omitempty"`
	Protected bool      `yaml:"protected,omitempty"`
}

type Config

type Config interface {
	Root() string
	Shape() string
	Services() []string
	Cluster() string
	Peers() []string
	P2PListen() []string
	P2PAnnounce() []string
	Ports() map[string]int
	Location() *seerIface.Location
	NetworkFqdn() string
	GeneratedDomain() string
	AliasDomains() []string
	HttpListen() string
	AliasDomainsRegExp() []*regexp.Regexp
	GeneratedDomainRegExp() *regexp.Regexp
	ServicesDomainRegExp() *regexp.Regexp
	ServicesDomainMatch(s string) bool
	AliasDomainsMatch(dom string) bool
	GeneratedDomainMatch(s string) bool
	// Hosts: custom domain -> service bindings (domains.hosts).
	Hosts() map[string]string
	ServiceForHost(host string) (string, bool)
	HostsForService(service string) []string
	RouteHosts(service string) []string
	CustomAcme() bool
	AcmeUrl() string
	AcmeCAARecord() string
	AcmeKey() crypto.Signer
	AcmeCAInsecureSkipVerify() bool
	AcmeRootCA() *x509.CertPool
	Node() peer.Node
	PrivateKey() []byte
	Databases() kvdb.Factory
	RaftCluster() raft.Cluster
	ClientNode() peer.Node
	SwarmKey() []byte
	Http() http.Service
	Sensors() *sensors.Service
	EnableHTTPS() bool
	Verbose() bool
	DevMode() bool
	Plugins() Plugins
	DomainValidation() DomainValidation
	SensorsRegistry() *sensors.Registry
	Accounts() Accounts
	Tenancy() Tenancy

	SetNode(peer.Node)
	SetRaftCluster(raft.Cluster)
	SetClientNode(peer.Node)
	SetDatabases(kvdb.Factory)
	SetHttp(http.Service)
	SetSensors(*sensors.Service)
}

Config is the validated node configuration. Created via New; mutable fields can be set by bootstrap (e.g. SetNode, SetRaftCluster).

func New

func New(opts ...Option) (Config, error)

New returns a validated config. Defaults are dev-friendly; override with options.

type DVKey

type DVKey struct {
	Private string `yaml:"private"`
	Public  string `yaml:"public"`
}

type DomainValidation

type DomainValidation struct {
	PrivateKey []byte
	PublicKey  []byte
}

type Domains

type Domains struct {
	Key       DVKey       `yaml:"key"`
	Acme      *AcmeConfig `yaml:"acme,omitempty"`
	Aliases   []string    `yaml:"aliases"`
	Generated string      `yaml:"generated"`
	// Hosts binds a custom domain to the service that serves it, e.g.
	// {"console.example.com": "gateway"}. seer resolves the domain to that service's
	// nodes, the shared http server accepts + autocerts it, and the service
	// registers its routes under it. Distinct from Aliases (generic
	// <svc>.<alias> base domains resolved by first label).
	Hosts map[string]string `yaml:"hosts,omitempty"`
}

type Option

type Option func(*config) error

Option applies a setting during construction and may validate it.

func WithAccounts

func WithAccounts(a Accounts) Option

WithAccounts sets the Accounts subsystem configuration.

func WithAcmeKey

func WithAcmeKey(key crypto.Signer) Option

WithAcmeKey sets the ACME account key (crypto.Signer).

func WithAcmeUrl

func WithAcmeUrl(url string) Option

WithAcmeUrl sets the ACME directory URL.

func WithAliasDomainsRegExp

func WithAliasDomainsRegExp(r []*regexp.Regexp) Option

WithAliasDomainsRegExp sets the alias domains regex list.

func WithCluster

func WithCluster(cluster string) Option

WithCluster sets the cluster name.

func WithCustomAcme

func WithCustomAcme(v bool) Option

WithCustomAcme sets custom ACME mode.

func WithDevMode

func WithDevMode(dev bool) Option

WithDevMode sets dev mode (default true when using New).

func WithDomainValidation

func WithDomainValidation(dv DomainValidation) Option

WithDomainValidation sets domain validation keys.

func WithEnableHTTPS

func WithEnableHTTPS(v bool) Option

WithEnableHTTPS sets HTTPS mode.

func WithGeneratedDomainRegExp

func WithGeneratedDomainRegExp(r *regexp.Regexp) Option

WithGeneratedDomainRegExp sets the generated domain regex.

func WithHosts

func WithHosts(h map[string]string) Option

WithHosts sets the domain -> service host bindings.

func WithHttpListen

func WithHttpListen(addr string) Option

WithHttpListen sets the HTTP listen address.

func WithLocation

func WithLocation(loc *seerIface.Location) Option

WithLocation sets the location.

func WithNetworkFqdn

func WithNetworkFqdn(fqdn string) Option

WithNetworkFqdn sets the network FQDN.

func WithP2PAnnounce

func WithP2PAnnounce(addrs []string) Option

WithP2PAnnounce sets the p2p announce addresses. Validates at least one address.

func WithP2PListen

func WithP2PListen(addrs []string) Option

WithP2PListen sets the p2p listen addresses. Validates at least one address.

func WithPeers

func WithPeers(peers []string) Option

WithPeers sets the bootstrap peers.

func WithPlugins

func WithPlugins(p Plugins) Option

WithPlugins sets the plugins.

func WithPorts

func WithPorts(ports map[string]int) Option

WithPorts sets the ports map.

func WithPrivateKey

func WithPrivateKey(key []byte) Option

WithPrivateKey sets the node private key. Validates non-empty when DevMode is false.

func WithRoot

func WithRoot(root string) Option

WithRoot sets the node root directory. Validates root is non-empty.

func WithServicesDomainRegExp

func WithServicesDomainRegExp(r *regexp.Regexp) Option

WithServicesDomainRegExp sets the services domain regex.

func WithSource

func WithSource(src *Source, opts SourceOptions) Option

WithSource builds config from a Source (e.g. YAML). Resolves paths under root/config and loads keys from disk.

func WithSwarmKey

func WithSwarmKey(key []byte) Option

WithSwarmKey sets the swarm key.

func WithTenancy

func WithTenancy(t Tenancy) Option

WithTenancy sets the owning namespace for this cloud.

func WithVerbose

func WithVerbose(v bool) Option

WithVerbose sets verbose mode.

type Plugin

type Plugin string

type Plugins

type Plugins struct {
	Plugins []Plugin `yaml:"plugins,omitempty"`
}

type Ports

type Ports struct {
	Main int `yaml:"main"`
	Lite int `yaml:"lite,omitempty"`
	Ipfs int `yaml:"ipfs,omitempty"`
}

func (Ports) ToMap

func (p Ports) ToMap() map[string]int

type ProtoCommandIface

type ProtoCommandIface interface {
	New(context.Context, Config) (serviceIface.Service, error)
}

type SMTP

type SMTP struct {
	Host string `yaml:"host,omitempty"`
	Port int    `yaml:"port,omitempty"`
	User string `yaml:"user,omitempty"`
	Pass string `yaml:"pass,omitempty"`
	From string `yaml:"from,omitempty"`
}

SMTP minimal config. Empty Host = not configured (refused in production, stdout fallback in DevMode). Empty From defaults to `noreply@<NetworkFqdn>`.

type Source

type Source struct {
	Privatekey  string              `yaml:"privatekey"`
	Swarmkey    string              `yaml:"swarmkey"`
	Services    []string            `yaml:"services,omitempty"`
	P2PListen   []string            `yaml:"p2p-listen"`
	P2PAnnounce []string            `yaml:"p2p-announce"`
	Ports       Ports               `yaml:"ports"`
	Location    *seerIface.Location `yaml:"location,omitempty"`
	Peers       []string            `yaml:"peers,omitempty"`
	NetworkFqdn string              `yaml:"network-fqdn"`
	Domains     Domains             `yaml:"domains"`
	Cluster     string              `yaml:"cluster,omitempty"`
	// Accounts subsystem config (session-ttl, email/SMTP). Optional —
	// community / dream installs can omit. AccountsURL + WebAuthn are
	// derived from NetworkFqdn at runtime.
	Accounts Accounts `yaml:"accounts,omitempty"`
	// Tenancy names the git namespace that owns this cloud. Unlike Accounts it
	// is emitted to every shape, so any service can compare a repository's
	// owner against it without a client or an API call.
	Tenancy Tenancy `yaml:"tenancy,omitempty"`
	// Enterprise namespaces raw config for enterprise-only services under
	// `enterprise:` in the shape config. Community builds carry it opaquely;
	// `//go:build ee` code decodes each service's entry into its own typed
	// config (via EnterpriseConfig).
	Enterprise map[string]yaml.Node `yaml:"enterprise,omitempty"`
	Plugins
}

type SourceOptions

type SourceOptions struct {
	Root    string
	Shape   string
	DevMode bool
}

SourceOptions configures how a Source is applied when using WithSource.

type Tenancy

type Tenancy struct {
	Provider string     `yaml:"provider,omitempty"`
	Owner    string     `yaml:"owner,omitempty"`
	App      TenancyApp `yaml:"app,omitempty"`
}

Tenancy names the git namespace (GitHub org, GitLab group, Bitbucket workspace) that owns this cloud. Owner is the owning segment of `owner/repo`, which is what a repository URI yields on every provider.

An empty Owner means no namespace is configured. Registration refuses in that state rather than falling open, so a cloud is never accidentally open to anyone holding a valid provider token.

func (Tenancy) Configured

func (t Tenancy) Configured() bool

Configured reports whether an owning namespace was set.

func (Tenancy) Owns

func (t Tenancy) Owns(fullName string) bool

Owns reports whether fullName ("owner/repo") belongs to the configured namespace. Provider names are case-insensitive, so the comparison is too.

type TenancyApp

type TenancyApp struct {
	ClientId string `yaml:"client-id,omitempty"`
	Key      string `yaml:"key,omitempty"`
}

TenancyApp is the credential the namespace itself granted. The caller's own token cannot answer questions about other users or private repositories, so membership is checked with an installation token minted from this key.

Key is the PEM inline, matching how Privatekey and Swarmkey already travel.

Jump to

Keyboard shortcuts

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