config

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeSubscribePath

func NormalizeSubscribePath(value string) (string, error)

NormalizeSubscribePath cleans the public subscription path and rejects values that could overlap the versioned API namespace.

func PrepareSubscribePath

func PrepareSubscribePath(c *Config) string

PrepareSubscribePath normalizes the configured public subscription path, updates the in-memory configuration when present, and fails before route registration if the path could overlap the versioned API namespace.

func Set

func Set(c *Config)

Set replaces the loaded config, mainly for tests.

Types

type AdminConfig

type AdminConfig struct {
	Email    string `yaml:"email"`
	Password string `yaml:"password"`
}

AdminConfig defines the bootstrap admin account.

type AppConfig

type AppConfig struct {
	Name             string `yaml:"name"`
	Version          string `yaml:"version"`
	APIToken         string `yaml:"api_token"`
	TrafficLogEnable bool   `yaml:"traffic_log_enable"`
	SubscribePath    string `yaml:"subscribe_path"`
}

AppConfig defines generic app settings.

type AuthConfig

type AuthConfig struct {
	LoginRateLimit    LoginRateLimitConfig   `yaml:"login_rate_limit"`
	RegisterRateLimit LoginRateLimitConfig   `yaml:"register_rate_limit"`
	Registration      RegistrationAuthConfig `yaml:"registration"`
}

AuthConfig defines authentication security settings.

type CORSConfig

type CORSConfig struct {
	AllowedOrigins   []string `yaml:"allowed_origins"`
	AllowedMethods   []string `yaml:"allowed_methods"`
	AllowedHeaders   []string `yaml:"allowed_headers"`
	AllowCredentials bool     `yaml:"allow_credentials"`
	MaxAge           int      `yaml:"max_age"` // preflight cache duration in seconds
}

CORSConfig defines Cross-Origin Resource Sharing settings.

type CacheConfig

type CacheConfig struct {
	Driver        string `yaml:"driver"`
	RedisHost     string `yaml:"redis_host"`
	RedisPort     int    `yaml:"redis_port"`
	RedisPassword string `yaml:"redis_password"`
	RedisDB       int    `yaml:"redis_db"`
}

CacheConfig defines cache settings.

type Config

type Config struct {
	Env            string               `yaml:"env"`
	Server         ServerConfig         `yaml:"server"`
	Frontend       FrontendConfig       `yaml:"frontend"`
	Database       DatabaseConfig       `yaml:"database"`
	Cache          CacheConfig          `yaml:"cache"`
	Log            LogConfig            `yaml:"log"`
	JWT            JWTConfig            `yaml:"jwt"`
	Auth           AuthConfig           `yaml:"auth"`
	App            AppConfig            `yaml:"app"`
	Admin          AdminConfig          `yaml:"admin"`
	TLS            TLSConfig            `yaml:"tls"`
	ForwardRuntime ForwardRuntimeConfig `yaml:"forward_runtime"`
	Plugins        PluginConfig         `yaml:"plugins"`
	GRPC           GRPCConfig           `yaml:"grpc"`
}

Config is the root application configuration loaded from config.yaml.

func Get

func Get() *Config

Get returns the loaded config.

func Load

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

Load reads a YAML config file once per process.

type DatabaseConfig

type DatabaseConfig struct {
	Driver          string `yaml:"driver"`
	Database        string `yaml:"database"`
	Host            string `yaml:"host"`
	Port            int    `yaml:"port"`
	Username        string `yaml:"username"`
	Password        string `yaml:"password"`
	LogLevel        string `yaml:"log_level"`
	MaxIdleConns    int    `yaml:"max_idle_conns"`
	MaxOpenConns    int    `yaml:"max_open_conns"`
	ConnMaxLifetime int    `yaml:"conn_max_lifetime"`
}

DatabaseConfig defines database connection settings.

type ForwardRuntimeAnsibleConfig

type ForwardRuntimeAnsibleConfig struct {
	Inventory      string            `yaml:"inventory"`
	ApplyPlaybook  string            `yaml:"apply_playbook"`
	RemovePlaybook string            `yaml:"remove_playbook"`
	Become         bool              `yaml:"become"`
	ExtraVars      map[string]any    `yaml:"extra_vars"`
	Command        string            `yaml:"command"`
	WorkingDir     string            `yaml:"working_dir"`
	TargetPattern  string            `yaml:"target_pattern"`
	Environment    map[string]string `yaml:"environment"`
	TimeoutSeconds int               `yaml:"timeout_seconds"`
}

ForwardRuntimeAnsibleConfig stores local ansible runtime settings.

type ForwardRuntimeCleanAgentConfig

type ForwardRuntimeCleanAgentConfig struct {
	PublicURL                string `yaml:"public_url"`
	HeartbeatIntervalSeconds int    `yaml:"heartbeat_interval_seconds"`
	ActionTimeoutSeconds     int    `yaml:"action_timeout_seconds"`
	TokenExpireSeconds       int    `yaml:"token_expire_seconds"`
	LegacyBridgeEnabled      bool   `yaml:"legacy_bridge_enabled"`
}

ForwardRuntimeCleanAgentConfig stores clean-room forward agent defaults.

type ForwardRuntimeConfig

type ForwardRuntimeConfig struct {
	NodeXMode       *bool                          `yaml:"nodex_mode"`
	Backend         string                         `yaml:"backend"`
	NodeX           ForwardRuntimeNodeXConfig      `yaml:"nodex"`
	CleanAgent      ForwardRuntimeCleanAgentConfig `yaml:"clean_agent"`
	NftablesAnsible ForwardRuntimeAnsibleConfig    `yaml:"nftables_ansible"`
	Jobs            ForwardRuntimeJobsConfig       `yaml:"jobs"`
	GostStats       ForwardRuntimeGostStatsConfig  `yaml:"gost_stats"`
	Latency         ForwardRuntimeLatencyConfig    `yaml:"latency"`
}

ForwardRuntimeConfig stores the canonical forward runtime settings from config.yaml.

type ForwardRuntimeGostStatsConfig

type ForwardRuntimeGostStatsConfig struct {
	PollInterval     string `yaml:"poll_interval"`
	IdlePollInterval string `yaml:"idle_poll_interval"`
	ErrorLogInterval string `yaml:"error_log_interval"`
}

ForwardRuntimeGostStatsConfig stores gost stats polling settings.

type ForwardRuntimeJobsConfig

type ForwardRuntimeJobsConfig struct {
	PollInterval     string `yaml:"poll_interval"`
	IdlePollInterval string `yaml:"idle_poll_interval"`
	ErrorLogInterval string `yaml:"error_log_interval"`
	BatchSize        int    `yaml:"batch_size"`
	TimeoutSeconds   int    `yaml:"timeout_seconds"`
}

ForwardRuntimeJobsConfig stores local ansible job executor polling settings.

type ForwardRuntimeLatencyConfig

type ForwardRuntimeLatencyConfig struct {
	PollInterval     string `yaml:"poll_interval"`
	IdlePollInterval string `yaml:"idle_poll_interval"`
	ErrorLogInterval string `yaml:"error_log_interval"`
	Dials            int    `yaml:"dials"`
	DialTimeout      string `yaml:"dial_timeout"`
	Concurrency      int    `yaml:"concurrency"`
	RetentionDays    int    `yaml:"retention_days"`
}

ForwardRuntimeLatencyConfig stores latency prober (TCPing) settings.

type ForwardRuntimeNodeXConfig

type ForwardRuntimeNodeXConfig struct {
	BaseURL        string `yaml:"base_url"`
	Token          string `yaml:"token"`
	TimeoutSeconds int    `yaml:"timeout_seconds"`
}

ForwardRuntimeNodeXConfig stores NodeX or gost runtime settings.

type FrontendConfig

type FrontendConfig struct {
	Enable bool   `yaml:"enable"`
	Port   int    `yaml:"port"`
	Path   string `yaml:"path"`
}

FrontendConfig defines static frontend serving settings.

type GRPCConfig

type GRPCConfig struct {
	Enable      bool   `yaml:"enabled"`
	Host        string `yaml:"host"`
	Port        int    `yaml:"port"`
	APIToken    string `yaml:"api_token"`
	TLSCertFile string `yaml:"tls_cert_file"`
	TLSKeyFile  string `yaml:"tls_key_file"`
}

GRPCConfig controls the node-facing gRPC server (AnixOps Agent nodes connect here).

type JWTConfig

type JWTConfig struct {
	Secret string `yaml:"secret"`
	Expire int    `yaml:"expire"`
}

JWTConfig defines JWT settings.

type LogConfig

type LogConfig struct {
	Level      string `yaml:"level"`
	Output     string `yaml:"output"`
	FilePath   string `yaml:"file_path"`
	MaxSize    int    `yaml:"max_size"`
	MaxBackups int    `yaml:"max_backups"`
	MaxAge     int    `yaml:"max_age"`
}

LogConfig defines log settings.

type LoginRateLimitConfig

type LoginRateLimitConfig struct {
	Enabled        *bool `yaml:"enabled"`
	MaxAttempts    int   `yaml:"max_attempts"`
	WindowSeconds  int   `yaml:"window_seconds"`
	LockoutSeconds int   `yaml:"lockout_seconds"`
}

LoginRateLimitConfig controls brute-force protection for login.

type PluginConfig

type PluginConfig struct {
	OfficialPublicKey                  string `yaml:"official_public_key"`
	IdentityBootstrapPackageDir        string `yaml:"identity_bootstrap_package_dir"`
	ControlExecutionEnabled            bool   `yaml:"control_execution_enabled"`
	ControlPollInterval                string `yaml:"control_poll_interval"`
	ControlHostRuntimeDir              string `yaml:"control_host_runtime_dir"`
	ControlHostArtifactDir             string `yaml:"control_host_artifact_dir"`
	ControlHostStartupTimeout          string `yaml:"control_host_startup_timeout"`
	ControlHostRequestTimeout          string `yaml:"control_host_request_timeout"`
	ControlHostWebSocketSessionTimeout string `yaml:"control_host_websocket_session_timeout"`
	DispatchEnabled                    bool   `yaml:"dispatch_enabled"`
	DispatchPollInterval               string `yaml:"dispatch_poll_interval"`
	TopologyExecutionEnabled           bool   `yaml:"topology_execution_enabled"`
	TopologyPollInterval               string `yaml:"topology_poll_interval"`
}

PluginConfig controls the official plugin trust root and the opt-in durable lifecycle dispatcher. Third-party plugin execution is intentionally unsupported by the control kernel.

type RegistrationAuthConfig

type RegistrationAuthConfig struct {
	Enabled             *bool    `yaml:"enabled"`
	RequireInvite       bool     `yaml:"require_invite"`
	AllowedEmailDomains []string `yaml:"allowed_email_domains"`
	BlockedEmailDomains []string `yaml:"blocked_email_domains"`
}

RegistrationAuthConfig controls public account registration policy.

type ServerConfig

type ServerConfig struct {
	Host           string     `yaml:"host"`
	Port           int        `yaml:"port"`
	Mode           string     `yaml:"mode"`
	ReadTimeout    int        `yaml:"read_timeout"`
	WriteTimeout   int        `yaml:"write_timeout"`
	TrustedProxies []string   `yaml:"trusted_proxies"`
	CORS           CORSConfig `yaml:"cors"`
}

ServerConfig defines backend server settings.

type TLSConfig

type TLSConfig struct {
	Enable   bool   `yaml:"enable"`
	CertFile string `yaml:"cert_file"`
	KeyFile  string `yaml:"key_file"`
	Domain   string `yaml:"domain"`
}

TLSConfig defines TLS settings.

Jump to

Keyboard shortcuts

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