config

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	SessionTimeout  int         `mapstructure:"session_timeout" json:"session_timeout"`
	AnonymousAccess bool        `mapstructure:"anonymous_access" json:"anonymous_access"`
	JWTSecret       string      `mapstructure:"jwt_secret" json:"jwt_secret"`
	OIDC            OIDCConfig  `mapstructure:"oidc" json:"oidc"`
	Local           LocalConfig `mapstructure:"local" json:"local"`
	// AllowNoAuth permits running the panel with neither local auth nor OIDC
	// enabled. When false (default) every request is rejected instead of
	// being granted admin, and startup fails with a clear error.
	AllowNoAuth bool `mapstructure:"allow_no_auth" json:"allow_no_auth"`
	// RecoveryKeyFile is the on-disk break-glass key. Empty skips the file
	// and keeps the key only in the system setting. The panel sets this to
	// data/recovery.key at startup (MINE-209).
	RecoveryKeyFile string `mapstructure:"-" json:"-"`
}

type BackupEncryptionConfig added in v1.0.39

type BackupEncryptionConfig struct {
	KeyID string `mapstructure:"key_id" json:"key_id"`
	Key   string `mapstructure:"key" json:"-"`
}

BackupEncryptionConfig enables authenticated encryption of backup artifacts at rest and offsite (OSS-236). Encryption is explicitly disabled when no key material is configured. The key is 32 bytes encoded as hex or base64 and should come from the environment (CARBONPANEL_STORAGE_BACKUP_ENCRYPTION_KEY) rather than the config file; it is never serialized or logged. KeyID is a stable non-secret label recorded with every artifact for key rotation and recovery.

type Config

type Config struct {
	Server    ServerConfig    `mapstructure:"server" json:"server"`
	Database  DatabaseConfig  `mapstructure:"database" json:"database"`
	Docker    DockerConfig    `mapstructure:"docker" json:"docker"`
	Storage   StorageConfig   `mapstructure:"storage" json:"storage"`
	Proxy     ProxyConfig     `mapstructure:"proxy" json:"proxy"`
	Module    ModuleConfig    `mapstructure:"module" json:"module"`
	Minecraft MinecraftConfig `mapstructure:"minecraft" json:"minecraft"`
	Logging   LoggingConfig   `mapstructure:"logging" json:"logging"`
	Upload    UploadConfig    `mapstructure:"upload" json:"upload"`
	Auth      AuthConfig      `mapstructure:"auth" json:"auth"`
}

func Load

func Load(configPath string) (*Config, error)

func (*Config) Validate

func (c *Config) Validate() error

Validate performs semantic and boundary validation of the configuration (CFG-1).

type DatabaseConfig

type DatabaseConfig struct {
	Path            string `mapstructure:"path" json:"path"`
	MaxConnections  int    `mapstructure:"max_connections" json:"max_connections"`
	MaxIdleConns    int    `mapstructure:"max_idle_conns" json:"max_idle_conns"`
	ConnMaxLifetime int    `mapstructure:"conn_max_lifetime" json:"conn_max_lifetime"`
	AutoMigrate     bool   `mapstructure:"auto_migrate" json:"auto_migrate"`
	// PanelBackup is "daily" or "off". Daily writes a VACUUM INTO snapshot of
	// this database. It is not Litestream and it does not restore automatically.
	PanelBackup string `mapstructure:"panel_backup" json:"panel_backup"`
	// PanelBackupKeep is how many daily snapshots to retain. Older files are
	// removed only after a new snapshot passes integrity_check.
	PanelBackupKeep int `mapstructure:"panel_backup_keep" json:"panel_backup_keep"`
}

type DockerConfig

type DockerConfig struct {
	SyncInterval    int               `mapstructure:"sync_interval" json:"sync_interval"`
	Host            string            `mapstructure:"host" json:"host"`
	Version         string            `mapstructure:"version" json:"version"`
	NetworkName     string            `mapstructure:"network_name" json:"network_name"`
	NetworkMTU      int               `mapstructure:"network_mtu" json:"network_mtu"`
	RegistryURL     string            `mapstructure:"registry_url" json:"registry_url"`
	DNS             string            `mapstructure:"dns" json:"dns"`
	Labels          map[string]string `mapstructure:"labels" json:"labels"`
	EnableRateLimit bool              `mapstructure:"enable_rate_limit" json:"enable_rate_limit"`
	RateLimitPerMin int               `mapstructure:"rate_limit_per_min" json:"rate_limit_per_min"`
	RateLimitBurst  int               `mapstructure:"rate_limit_burst" json:"rate_limit_burst"`
	// ReconcilePurgeOrphans removes containers that this installation provably
	// created but the database no longer knows about. Disabled by default:
	// orphaned, legacy and foreign containers are quarantined and left running.
	ReconcilePurgeOrphans bool `mapstructure:"reconcile_purge_orphans" json:"reconcile_purge_orphans"`
}

type LocalConfig

type LocalConfig struct {
	Enabled           bool `mapstructure:"enabled" json:"enabled"`
	AllowRegistration bool `mapstructure:"allow_registration" json:"allow_registration"`
}

type LoggingConfig

type LoggingConfig struct {
	Enabled    bool   `mapstructure:"enabled" json:"enabled"`
	FilePath   string `mapstructure:"file_path" json:"file_path"`
	MaxSize    int    `mapstructure:"max_size" json:"max_size"`
	MaxBackups int    `mapstructure:"max_backups" json:"max_backups"`
	MaxAge     int    `mapstructure:"max_age" json:"max_age"`
	Compress   bool   `mapstructure:"compress" json:"compress"`
}

type MinecraftConfig

type MinecraftConfig struct {
	ResetGlobal  bool           `mapstructure:"reset_global" json:"reset_global"`
	GlobalConfig map[string]any `mapstructure:"global_config" json:"global_config"`
}

type ModuleConfig

type ModuleConfig struct {
	Enabled      bool `mapstructure:"enabled" json:"enabled"`
	PortRangeMin int  `mapstructure:"port_range_min" json:"port_range_min"`
	PortRangeMax int  `mapstructure:"port_range_max" json:"port_range_max"`
}

type OIDCConfig

type OIDCConfig struct {
	Enabled         bool              `mapstructure:"enabled" json:"enabled"`
	IssuerURI       string            `mapstructure:"issuer_uri" json:"issuer_uri"`
	ClientID        string            `mapstructure:"client_id" json:"client_id"`
	ClientSecret    string            `mapstructure:"client_secret" json:"client_secret"`
	RedirectURL     string            `mapstructure:"redirect_url" json:"redirect_url"`
	Scopes          []string          `mapstructure:"scopes" json:"scopes"`
	RoleClaim       string            `mapstructure:"role_claim" json:"role_claim"`
	RoleMapping     map[string]string `mapstructure:"role_mapping" json:"role_mapping"`
	RejectUnmapped  bool              `mapstructure:"reject_unmapped" json:"reject_unmapped"`
	SkipTLSVerify   bool              `mapstructure:"skip_tls_verify" json:"skip_tls_verify"`
	ExtraClaimsURL  string            `mapstructure:"extra_claims_url" json:"extra_claims_url"`
	ExtraClaimsKey  string            `mapstructure:"extra_claims_key" json:"extra_claims_key"`
	ExtraClaimsName string            `mapstructure:"extra_claims_name" json:"extra_claims_name"`
	RequiredClaim   string            `mapstructure:"required_claim" json:"required_claim"`
	RequiredValues  []string          `mapstructure:"required_values" json:"required_values"`
}

type ProxyConfig

type ProxyConfig struct {
	Enabled      bool   `mapstructure:"enabled" json:"enabled"`
	BaseURL      string `mapstructure:"base_url" json:"base_url"`
	ListenPort   int    `mapstructure:"listen_port" json:"listen_port"`   // Primary listen port
	ListenPorts  []int  `mapstructure:"listen_ports" json:"listen_ports"` // Multiple listen ports
	PortRangeMin int    `mapstructure:"port_range_min" json:"port_range_min"`
	PortRangeMax int    `mapstructure:"port_range_max" json:"port_range_max"`
	ValkeyURL    string `mapstructure:"valkey_url" json:"valkey_url"` // Valkey / Dragonfly Redis KV URL (e.g. redis://127.0.0.1:6379)
	// AcceptsTransfers is handshake NextState=3. Nil and true both accept.
	// Velocity defaults this to false; Carbon defaults to true because a
	// rejected transfer is a player-visible outage on a hostname router (MINE-203).
	AcceptsTransfers *bool `mapstructure:"accepts_transfers" json:"accepts_transfers"`
	// LoginRateLimitMS is the per-IP gap between Gate handshakes. 0 disables.
	LoginRateLimitMS int `mapstructure:"login_ratelimit_ms" json:"login_ratelimit_ms"`
}

type S3Config

type S3Config struct {
	Enabled         bool   `mapstructure:"enabled" json:"enabled"`
	Endpoint        string `mapstructure:"endpoint" json:"endpoint"`
	Region          string `mapstructure:"region" json:"region"`
	Bucket          string `mapstructure:"bucket" json:"bucket"`
	Prefix          string `mapstructure:"prefix" json:"prefix"`
	AccessKey       string `mapstructure:"access_key" json:"access_key"`
	SecretKey       string `mapstructure:"secret_key" json:"secret_key"`
	ForcePathStyle  bool   `mapstructure:"force_path_style" json:"force_path_style"`
	DeleteLocalCopy bool   `mapstructure:"delete_local_copy" json:"delete_local_copy"`
}

S3Config enables S3-compatible offsite backup upload (MINE-138). Credentials should come from env (S3_ACCESS_KEY / S3_SECRET_KEY override) rather than the config file.

type ServerConfig

type ServerConfig struct {
	Port           string   `mapstructure:"port" json:"port"`
	Host           string   `mapstructure:"host" json:"host"`
	ReadTimeout    int      `mapstructure:"read_timeout" json:"read_timeout"`
	WriteTimeout   int      `mapstructure:"write_timeout" json:"write_timeout"`
	IdleTimeout    int      `mapstructure:"idle_timeout" json:"idle_timeout"`
	UserAgent      string   `mapstructure:"user_agent" json:"user_agent"`
	TrustProxy     bool     `mapstructure:"trust_proxy" json:"trust_proxy"`
	AllowedOrigins []string `mapstructure:"allowed_origins" json:"allowed_origins"`
}

type StorageConfig

type StorageConfig struct {
	DataDir               string                 `mapstructure:"data_dir" json:"data_dir"`
	BackupDir             string                 `mapstructure:"backup_dir" json:"backup_dir"`
	TempDir               string                 `mapstructure:"temp_dir" json:"temp_dir"`
	MaxUploadSize         int64                  `mapstructure:"max_upload_size" json:"max_upload_size"`
	MaxSnapshots          int                    `mapstructure:"max_snapshots" json:"max_snapshots"`
	SnapshotRetentionDays int                    `mapstructure:"snapshot_retention_days" json:"snapshot_retention_days"`
	BackupEncryption      BackupEncryptionConfig `mapstructure:"backup_encryption" json:"backup_encryption"`
	S3                    S3Config               `mapstructure:"s3" json:"s3"`
}

type UploadConfig

type UploadConfig struct {
	SessionTTL       int   `mapstructure:"session_ttl" json:"session_ttl"`               // Minutes, default 240 (4 hours)
	DefaultChunkSize int   `mapstructure:"default_chunk_size" json:"default_chunk_size"` // Bytes, default 5MB, client overriden
	MaxChunkSize     int   `mapstructure:"max_chunk_size" json:"max_chunk_size"`         // Bytes, default 10MB, server overriden
	MaxUploadSize    int64 `mapstructure:"max_upload_size" json:"max_upload_size"`       // Bytes, default 0 (unlimited)
}

Jump to

Keyboard shortcuts

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