Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT-0 Imports: 7 Imported by: 0

Documentation

Overview

Package config loads and validates the perch configuration file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save

func Save(path string, cfg Config) error

Save writes cfg to path with owner-only permissions.

Types

type ACMEConfig

type ACMEConfig struct {
	Enabled  bool     `yaml:"enabled"`
	Email    string   `yaml:"email"`
	Domains  []string `yaml:"domains"`
	CacheDir string   `yaml:"cache_dir"`
	HTTPAddr string   `yaml:"http_addr"`
}

ACMEConfig configures built-in Let's Encrypt issuance.

type Config

type Config struct {
	DataDir  string        `yaml:"data_dir"`
	Hostname string        `yaml:"hostname"`
	Log      LogConfig     `yaml:"log"`
	IMAP     IMAPConfig    `yaml:"imap"`
	SMTP     SMTPConfig    `yaml:"submission"`
	TLS      TLSConfig     `yaml:"tls"`
	Storage  StorageConfig `yaml:"storage"`
	MXRaVen  MXRaVenConfig `yaml:"mxraven"`
	Limits   LimitsConfig  `yaml:"limits"`
	Setup    SetupConfig   `yaml:"setup"`
}

Config is the top-level perch configuration.

func Default

func Default() Config

Default returns the configuration used by a fresh local installation.

func Load

func Load(path string) (Config, error)

Load reads path into a Config, applies environment overrides, and validates it. A missing file is an error: perch never starts with an implicit config.

func (Config) DBPath

func (c Config) DBPath() string

DBPath returns the SQLite database path.

func (Config) EnsureDataDir

func (c Config) EnsureDataDir() error

EnsureDataDir creates the private data directory.

func (Config) Listener

func (c Config) Listener(kind string) (ListenerConfig, bool)

Listener returns the first configured listener of kind, if any.

func (Config) Validate

func (c Config) Validate() error

Validate checks the invariants that would otherwise fail at runtime.

type IMAPConfig

type IMAPConfig struct {
	Addr                   string `yaml:"addr"`
	IMAPSAddr              string `yaml:"imaps_addr"`
	AllowPlaintextLoopback bool   `yaml:"allow_plaintext_loopback"`
}

IMAPConfig configures the IMAP listeners.

type LimitsConfig

type LimitsConfig struct {
	MaxMessageBytes   int64 `yaml:"max_message_bytes"`
	MaxRecipients     int   `yaml:"max_recipients"`
	MaxConnections    int   `yaml:"max_connections"`
	IngestConcurrency int   `yaml:"ingest_concurrency"`
	SearchMaxMessages int   `yaml:"search_max_messages"`
	BlobCacheBytes    int64 `yaml:"blob_cache_bytes"`
}

LimitsConfig bounds resource use.

type ListenerConfig

type ListenerConfig struct {
	ID           string `yaml:"id"`
	Kind         string `yaml:"kind"` // mta or submission
	KeyPrefix    string `yaml:"key_prefix"`
	KeySecret    string `yaml:"key_secret"`
	KeySecretEnv string `yaml:"key_secret_env"`
	Consumer     string `yaml:"consumer"`
}

ListenerConfig identifies one mxRaven listener and its API key.

func (ListenerConfig) Secret

func (l ListenerConfig) Secret() string

Secret returns the listener secret from the environment when configured.

type LogConfig

type LogConfig struct {
	Level  string `yaml:"level"`  // debug, info, warn, error
	Format string `yaml:"format"` // json or text
}

LogConfig controls structured logging.

type MXRaVenConfig

type MXRaVenConfig struct {
	SubmissionHost  string           `yaml:"submission_host"`
	SubmissionPort  int              `yaml:"submission_port"`
	NotificationURL string           `yaml:"notification_url"`
	FeedbackURL     string           `yaml:"feedback_url"`
	Listeners       []ListenerConfig `yaml:"listeners"`
}

MXRaVenConfig configures the upstream mail transport.

type S3Config

type S3Config struct {
	Endpoint       string        `yaml:"endpoint"`
	Region         string        `yaml:"region"`
	Bucket         string        `yaml:"bucket"`
	Prefix         string        `yaml:"prefix"`
	AccessKey      string        `yaml:"access_key"`
	SecretKey      string        `yaml:"secret_key"`
	SecretKeyEnv   string        `yaml:"secret_key_env"`
	ForcePathStyle bool          `yaml:"force_path_style"`
	KeyTemplate    string        `yaml:"key_template"`
	ReconcileEvery time.Duration `yaml:"reconcile_every"`
	Spool          bool          `yaml:"spool"`
	SpoolMaxBytes  int64         `yaml:"spool_max_bytes"`
}

S3Config describes the bucket mxRaven writes to and perch reads from.

func (S3Config) Secret

func (c S3Config) Secret() string

Secret returns the S3 secret from the environment when configured.

type SMTPConfig

type SMTPConfig struct {
	Addr    string `yaml:"addr"`
	TLSAddr string `yaml:"tls_addr"`
}

SMTPConfig configures the submission listeners.

type SetupConfig

type SetupConfig struct {
	Domain        string `yaml:"domain"`
	InboundDomain string `yaml:"inbound_domain"`
	SendingDomain string `yaml:"sending_domain"`
	MTAListenerID string `yaml:"mta_listener_id"`
	SubListenerID string `yaml:"submission_listener_id"`
	StorageRef    string `yaml:"storage_ref"`
}

SetupConfig records values written by the setup wizard for diagnostics.

type StorageConfig

type StorageConfig struct {
	Mode StorageMode `yaml:"mode"`
	S3   S3Config    `yaml:"s3"`
}

StorageConfig selects the raw-message store.

type StorageMode

type StorageMode string

StorageMode selects where raw messages are kept.

const (
	// StorageSQLite keeps compressed raw messages inside the SQLite database.
	StorageSQLite StorageMode = "sqlite"
	// StorageS3 keeps raw messages in an S3 bucket populated by mxRaven's
	// S3_STORE action while metadata and search indexes stay in SQLite.
	StorageS3 StorageMode = "s3"
)

type TLSConfig

type TLSConfig struct {
	CertFile string     `yaml:"cert_file"`
	KeyFile  string     `yaml:"key_file"`
	ACME     ACMEConfig `yaml:"acme"`
}

TLSConfig enables TLS for IMAP and submission.

Jump to

Keyboard shortcuts

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