config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllPermissions = []string{
	"monitors.read", "monitors.write",
	"incidents.read", "incidents.write",
	"notifications.read", "notifications.write",
	"escalation_policies.read", "escalation_policies.write",
	"maintenance.read", "maintenance.write",
	"metrics.read",
}

Functions

func HashAPIKey

func HashAPIKey(key string) string

func NormalizeBasePath

func NormalizeBasePath(s string) string

Types

type APIKeyConfig

type APIKeyConfig struct {
	Name        string   `yaml:"name"`
	Hash        string   `yaml:"hash"`
	Role        string   `yaml:"role,omitempty"`
	SuperAdmin  bool     `yaml:"super_admin,omitempty"`
	Permissions []string `yaml:"permissions,omitempty"`
	TOTP        bool     `yaml:"totp,omitempty"`
}

func (*APIKeyConfig) HasPermission

func (k *APIKeyConfig) HasPermission(perm string) bool

func (*APIKeyConfig) PermissionMap

func (k *APIKeyConfig) PermissionMap() map[string]bool

type AuthConfig

type AuthConfig struct {
	APIKeys []APIKeyConfig `yaml:"api_keys"`
	Session SessionConfig  `yaml:"session"`
	Login   LoginConfig    `yaml:"login"`
	TOTP    TOTPConfig     `yaml:"totp"`
}

type Config

type Config struct {
	Server        ServerConfig        `yaml:"server"`
	Database      DatabaseConfig      `yaml:"database"`
	Auth          AuthConfig          `yaml:"auth"`
	Monitor       MonitorConfig       `yaml:"monitor"`
	Logging       LoggingConfig       `yaml:"logging"`
	Subscriptions SubscriptionsConfig `yaml:"subscriptions"`
	// contains filtered or unexported fields
}

func Defaults

func Defaults() *Config

func Load

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

func (*Config) IsTrustedProxy

func (c *Config) IsTrustedProxy(ip net.IP) bool

func (*Config) IsWebUIEnabled

func (c *Config) IsWebUIEnabled() bool

func (*Config) LookupAPIKey

func (c *Config) LookupAPIKey(key string) (*APIKeyConfig, bool)

LookupAPIKey checks if the given key matches any configured API key and returns the key config if found.

func (*Config) LookupAPIKeyByName

func (c *Config) LookupAPIKeyByName(name string) *APIKeyConfig

LookupAPIKeyByName finds an API key config by its name.

func (*Config) ResolvedExternalURL

func (c *Config) ResolvedExternalURL() string

func (*Config) TrustedNets

func (c *Config) TrustedNets() []net.IPNet

func (*Config) Validate

func (c *Config) Validate() error

type DatabaseConfig

type DatabaseConfig struct {
	Path                    string        `yaml:"path"`
	MaxReadConns            int           `yaml:"max_read_conns"`
	RetentionDays           int           `yaml:"retention_days"`
	RetentionPeriod         time.Duration `yaml:"retention_period"`
	RequestLogRetentionDays int           `yaml:"request_log_retention_days"`
	EncryptionKey           string        `yaml:"encryption_key"`
}

type LoggingConfig

type LoggingConfig struct {
	Level  string `yaml:"level"`
	Format string `yaml:"format"` // "text" or "json"
}

type LoginConfig

type LoginConfig struct {
	RateLimitPerSec float64 `yaml:"rate_limit_per_sec"`
	RateLimitBurst  int     `yaml:"rate_limit_burst"`
}

type MonitorConfig

type MonitorConfig struct {
	Workers                int           `yaml:"workers"`
	DefaultTimeout         time.Duration `yaml:"default_timeout"`
	DefaultInterval        time.Duration `yaml:"default_interval"`
	FailureThreshold       int           `yaml:"failure_threshold"`
	SuccessThreshold       int           `yaml:"success_threshold"`
	MaxConcurrentDNS       int           `yaml:"max_concurrent_dns"`
	CommandTimeout         time.Duration `yaml:"command_timeout"`
	CommandAllowlist       []string      `yaml:"command_allowlist"`
	HeartbeatCheckInterval time.Duration `yaml:"heartbeat_check_interval"`
	AllowPrivateTargets    bool          `yaml:"allow_private_targets"`
	AdaptiveIntervals      bool          `yaml:"adaptive_intervals"`
}

type SMTPConfig added in v1.2.0

type SMTPConfig struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	From     string `yaml:"from"`
	TLSMode  string `yaml:"tls_mode"`
}

type ServerConfig

type ServerConfig struct {
	Listen          string        `yaml:"listen"`
	TLSCert         string        `yaml:"tls_cert"`
	TLSKey          string        `yaml:"tls_key"`
	ReadTimeout     time.Duration `yaml:"read_timeout"`
	WriteTimeout    time.Duration `yaml:"write_timeout"`
	IdleTimeout     time.Duration `yaml:"idle_timeout"`
	MaxBodySize     int64         `yaml:"max_body_size"`
	CORSOrigins     []string      `yaml:"cors_origins"`
	RateLimitPerSec float64       `yaml:"rate_limit_per_sec"`
	RateLimitBurst  int           `yaml:"rate_limit_burst"`
	WebUIEnabled    *bool         `yaml:"web_ui_enabled"`
	FrameAncestors  []string      `yaml:"frame_ancestors"`
	BasePath        string        `yaml:"base_path"`
	ExternalURL     string        `yaml:"external_url"`
	TrustedProxies  []string      `yaml:"trusted_proxies"`
}

type SessionConfig

type SessionConfig struct {
	Lifetime     time.Duration `yaml:"lifetime"`
	CookieSecure bool          `yaml:"cookie_secure"`
}

type SubscriptionsConfig added in v1.2.0

type SubscriptionsConfig struct {
	Enabled bool       `yaml:"enabled"`
	SMTP    SMTPConfig `yaml:"smtp"`
}

type TOTPConfig

type TOTPConfig struct {
	Required bool `yaml:"required"`
}

Jump to

Keyboard shortcuts

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