config

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 0 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 {
	Required bool   `yaml:"required" json:"required"`
	RelayURL string `yaml:"relay_url" json:"relay_url"`
	// RelayURLMatch controls how the AUTH event's `relay` tag is
	// compared against RelayURL. "strict" (default) keeps the path
	// significant after canonicalization; "host" drops the path so any
	// AUTH addressed at the right host is accepted. Empty == "strict".
	// See server/utils/relayurl for the exact rules.
	RelayURLMatch string `yaml:"relay_url_match" json:"relay_url_match"`
}

type BackupRelayConfig added in v0.7.0

type BackupRelayConfig struct {
	Enabled bool     `yaml:"enabled" json:"enabled"`
	URLs    []string `yaml:"urls" json:"urls"`
}

BackupRelayConfig is the upstream-mirror destination. Same promotion reason — the NIP-86 update method needs a name to decode JSON into. BackupRelayConfig holds the upstream relays grain mirrors accepted events to. Renamed from a single-URL field as of the admin dashboard work — operators commonly want both a public blaster + a private archival relay simultaneously.

type BlacklistConfig

type BlacklistConfig struct {
	Enabled                     bool     `yaml:"enabled" json:"enabled"`
	PermanentBanWords           []string `yaml:"permanent_ban_words" json:"permanent_ban_words"`
	TempBanWords                []string `yaml:"temp_ban_words" json:"temp_ban_words"`
	MaxTempBans                 int      `yaml:"max_temp_bans" json:"max_temp_bans"`
	TempBanDuration             int      `yaml:"temp_ban_duration" json:"temp_ban_duration"`
	PermanentBlacklistPubkeys   []string `yaml:"permanent_blacklist_pubkeys" json:"permanent_blacklist_pubkeys"`
	PermanentBlacklistNpubs     []string `yaml:"permanent_blacklist_npubs" json:"permanent_blacklist_npubs"`
	MuteListAuthors             []string `yaml:"mutelist_authors" json:"mutelist_authors"`
	MutelistCacheRefreshMinutes int      `yaml:"mutelist_cache_refresh_minutes" json:"mutelist_cache_refresh_minutes"`

	// IP blacklist fields (#62). Mirror the pubkey escalation pattern at
	// the network layer. CIDR-aware so a single entry can cover a /24.
	PermanentBlockedIPs      []string `yaml:"permanent_blocked_ips" json:"permanent_blocked_ips"`             // CIDR ("203.0.113.0/24") or single IP (parsed as /32 or /128)
	IPMaxTempBans            int      `yaml:"ip_max_temp_bans" json:"ip_max_temp_bans"`                       // temp bans accumulated before promotion to permanent
	IPTempBanDuration        int      `yaml:"ip_temp_ban_duration" json:"ip_temp_ban_duration"`               // seconds; how long a temp ban lasts
	IPRateViolationThreshold int      `yaml:"ip_rate_violation_threshold" json:"ip_rate_violation_threshold"` // rate-limit violations before triggering one temp ban
}

BlacklistConfig — blacklist.yml shape, plus the IP-related fields that live in config.yml's blacklist: section (LoadIPBlocklist merges both sources at startup). JSON tags mirror the YAML names so NIP-86 grain_updateblacklistconfig can round-trip the struct without losing field names.

type CategoryLimitConfig

type CategoryLimitConfig struct {
	Regular     LimitBurst `yaml:"regular"`
	Replaceable LimitBurst `yaml:"replaceable"`
	Addressable LimitBurst `yaml:"addressable"`
	Ephemeral   LimitBurst `yaml:"ephemeral"`
}

type ClientConfig added in v0.4.11

type ClientConfig struct {
	// IndexRelays seed the client library's discovery: NIP-65 mailbox
	// lookups and profile metadata fetches go here first when no
	// per-user relay set is known. As the outbox-model pool work
	// progresses (#56), these become the bootstrap layer that
	// per-user mailbox/inbox sets are resolved through, rather than
	// the relay set used for every operation.
	IndexRelays       []string `yaml:"index_relays"`
	ConnectionTimeout int      `yaml:"connection_timeout"` // seconds
	ReadTimeout       int      `yaml:"read_timeout"`       // seconds
	WriteTimeout      int      `yaml:"write_timeout"`      // seconds
	MaxConnections    int      `yaml:"max_connections"`
	RetryAttempts     int      `yaml:"retry_attempts"`
	RetryDelay        int      `yaml:"retry_delay"` // seconds
	KeepAlive         bool     `yaml:"keep_alive"`
	UserAgent         string   `yaml:"user_agent"`
}

type DatabaseConfig added in v0.7.0

type DatabaseConfig struct {
	Path      string `yaml:"path" json:"path"`               // Directory for nostrdb data files (default: ./data)
	MapSizeMB int    `yaml:"map_size_mb" json:"map_size_mb"` // Max database size in MB (default: 4096 = 4GB)
}

DatabaseConfig captures the nostrdb settings on disk. Pulled out of the anonymous struct inside ServerConfig so the NIP-86 admin write helpers can name a type (anonymous struct fields can't cross package boundaries cleanly).

type EventPurgeConfig

type EventPurgeConfig struct {
	Enabled              bool            `yaml:"enabled" json:"enabled"`
	DisableAtStartup     bool            `yaml:"disable_at_startup" json:"disable_at_startup"`
	KeepIntervalHours    int             `yaml:"keep_interval_hours" json:"keep_interval_hours"`
	PurgeIntervalMinutes int             `yaml:"purge_interval_minutes" json:"purge_interval_minutes"`
	PurgeByCategory      map[string]bool `yaml:"purge_by_category" json:"purge_by_category"`
	PurgeByKindEnabled   bool            `yaml:"purge_by_kind_enabled" json:"purge_by_kind_enabled"`
	KindsToPurge         []int           `yaml:"kinds_to_purge" json:"kinds_to_purge"`
	ExcludeWhitelisted   bool            `yaml:"exclude_whitelisted" json:"exclude_whitelisted"`
}

type EventTimeConstraints

type EventTimeConstraints struct {
	MinCreatedAt       int64  `yaml:"min_created_at"`        // Minimum allowed timestamp
	MinCreatedAtString string `yaml:"min_created_at_string"` // Original string value for parsing (e.g., "now-5m")
	MaxCreatedAt       int64  `yaml:"max_created_at"`        // Maximum allowed timestamp
	MaxCreatedAtString string `yaml:"max_created_at_string"` // Original string value for parsing (e.g., "now+5m")
}

type KindLimitConfig

type KindLimitConfig struct {
	Kind  int     `yaml:"kind" json:"kind"`
	Limit float64 `yaml:"limit" json:"limit"`
	Burst int     `yaml:"burst" json:"burst"`
}

type KindSizeLimitConfig

type KindSizeLimitConfig struct {
	Kind    int `yaml:"kind" json:"kind"`
	MaxSize int `yaml:"max_size" json:"max_size"`
}

type LimitBurst

type LimitBurst struct {
	Limit float64 `yaml:"limit" json:"limit"`
	Burst int     `yaml:"burst" json:"burst"`
}

type LogConfig

type LogConfig struct {
	Level              string   `yaml:"level" json:"level"`
	File               string   `yaml:"file" json:"file"`
	MaxSizeMB          int      `yaml:"max_log_size_mb" json:"max_log_size_mb"`
	Structure          bool     `yaml:"structure" json:"structure"`
	Stdout             bool     `yaml:"stdout" json:"stdout"`                           // Mirror log records to stdout (pretty single-line format) so `docker logs` works without losing the file sink.
	CheckIntervalMin   int      `yaml:"check_interval_min" json:"check_interval_min"`   // How often the program checks the size of the current log file
	BackupCount        int      `yaml:"backup_count" json:"backup_count"`               // Number of backup logs to keep
	SuppressComponents []string `yaml:"suppress_components" json:"suppress_components"` // Components to suppress INFO/DEBUG logs from
}

type RateLimitConfig

type RateLimitConfig struct {
	WsLimit        float64                    `yaml:"ws_limit" json:"ws_limit"`
	WsBurst        int                        `yaml:"ws_burst" json:"ws_burst"`
	EventLimit     float64                    `yaml:"event_limit" json:"event_limit"`
	EventBurst     int                        `yaml:"event_burst" json:"event_burst"`
	ReqLimit       float64                    `yaml:"req_limit" json:"req_limit"`
	ReqBurst       int                        `yaml:"req_burst" json:"req_burst"`
	MaxEventSize   int                        `yaml:"max_event_size" json:"max_event_size"`
	KindSizeLimits []KindSizeLimitConfig      `yaml:"kind_size_limits" json:"kind_size_limits"`
	CategoryLimits map[string]KindLimitConfig `yaml:"category_limits" json:"category_limits"`
	KindLimits     []KindLimitConfig          `yaml:"kind_limits" json:"kind_limits"`
}

type ResourceLimits

type ResourceLimits struct {
	CPUCores   int `yaml:"cpu_cores" json:"cpu_cores"`
	MemoryMB   int `yaml:"memory_mb" json:"memory_mb"`
	HeapSizeMB int `yaml:"heap_size_mb" json:"heap_size_mb"`
}

type ServerConfig

type ServerConfig struct {
	Logging              LogConfig            `yaml:"logging" json:"logging"`
	Database             DatabaseConfig       `yaml:"database" json:"database"`
	Server               ServerSettings       `yaml:"server" json:"server"`
	Client               ClientConfig         `yaml:"client" json:"client"`
	RateLimit            RateLimitConfig      `yaml:"rate_limit" json:"rate_limit"`
	Blacklist            BlacklistConfig      `yaml:"blacklist" json:"blacklist"`
	ResourceLimits       ResourceLimits       `yaml:"resource_limits" json:"resource_limits"`
	Auth                 AuthConfig           `yaml:"auth" json:"auth"`
	EventPurge           EventPurgeConfig     `yaml:"event_purge" json:"event_purge"`
	EventTimeConstraints EventTimeConstraints `yaml:"event_time_constraints" json:"event_time_constraints"`
	BackupRelay          BackupRelayConfig    `yaml:"backup_relay" json:"backup_relay"`
}

type ServerSettings added in v0.7.0

type ServerSettings struct {
	Port                      string `yaml:"port" json:"port"`
	ReadTimeout               int    `yaml:"read_timeout" json:"read_timeout"`
	WriteTimeout              int    `yaml:"write_timeout" json:"write_timeout"`
	IdleTimeout               int    `yaml:"idle_timeout" json:"idle_timeout"`
	MaxConnections            int    `yaml:"max_connections" json:"max_connections"`
	MaxSubscriptionsPerClient int    `yaml:"max_subscriptions_per_client" json:"max_subscriptions_per_client"`
	ImplicitReqLimit          int    `yaml:"implicit_req_limit" json:"implicit_req_limit"`                     // New field for implicit REQ limit
	ConnectionRateLimitPerIP  int    `yaml:"connection_rate_limit_per_ip" json:"connection_rate_limit_per_ip"` // Per-IP connection attempts per minute (0 = disabled). See #61.
}

ServerSettings is the HTTP server block (timeouts, connection caps, max subscriptions). Promoted to a named type for the same reason as DatabaseConfig.

type WhitelistConfig

type WhitelistConfig struct {
	PubkeyWhitelist struct {
		Enabled             bool     `yaml:"enabled" json:"enabled"`
		Pubkeys             []string `yaml:"pubkeys" json:"pubkeys"`
		Npubs               []string `yaml:"npubs" json:"npubs"`
		CacheRefreshMinutes int      `yaml:"cache_refresh_minutes" json:"cache_refresh_minutes"`
	} `yaml:"pubkey_whitelist" json:"pubkey_whitelist"`

	KindWhitelist struct {
		Enabled bool     `yaml:"enabled" json:"enabled"`
		Kinds   []string `yaml:"kinds" json:"kinds"`
	} `yaml:"kind_whitelist" json:"kind_whitelist"`

	DomainWhitelist struct {
		Enabled             bool     `yaml:"enabled" json:"enabled"`
		Domains             []string `yaml:"domains" json:"domains"`
		CacheRefreshMinutes int      `yaml:"cache_refresh_minutes" json:"cache_refresh_minutes"`
	} `yaml:"domain_whitelist" json:"domain_whitelist"`
}

WhitelistConfig — whitelist.yml shape. JSON tags mirror the YAML ones so admin write methods (NIP-86 grain_updatewhitelistconfig) can round-trip the struct through JSON without losing snake_case field names.

Jump to

Keyboard shortcuts

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