config

package
v0.0.0-...-df0449a Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddKindToNIPMapping

func AddKindToNIPMapping(kind int, nip int) error

AddKindToNIPMapping adds or updates a kind-to-NIP mapping

func GenerateRandomAPIKey

func GenerateRandomAPIKey() (string, error)

GenerateRandomAPIKey generates a random 32-byte hexadecimal key

func GetAllSettingsAsMap

func GetAllSettingsAsMap() (map[string]interface{}, error)

GetAllSettingsAsMap returns all configuration settings as a map This is a thread-safe alternative to viper.AllSettings() which can cause concurrent map read/write errors when viper.WatchConfig() is enabled

func GetAllowedUsersSettings

func GetAllowedUsersSettings() (*types.AllowedUsersSettings, error)

GetAllowedUsersSettings returns the allowed users settings from cached config

func GetConfig

func GetConfig() (*types.Config, error)

GetConfig returns the cached configuration struct This is extremely fast as it only reads from atomic.Value

func GetDataDir

func GetDataDir() string

GetDataDir returns the data directory path

func GetExternalURL

func GetExternalURL(service string) string

GetExternalURL returns external service URLs

func GetNIPForKind

func GetNIPForKind(kind int) (int, error)

GetNIPForKind returns the NIP number for a given kind

func GetNIPMappings

func GetNIPMappings() map[string]string

GetNIPMappings returns the current NIP mappings from configuration

func GetPath

func GetPath(subPath string) string

GetPath returns a path relative to the data directory

func GetPort

func GetPort(service string) int

GetPort returns the port for a service from configuration Falls back to base port with offset calculation if service-specific port not configured

func GetSettingValue

func GetSettingValue(key string) (interface{}, error)

GetSettingValue returns a specific setting value by key path (e.g., "relay.name") This is a thread-safe alternative to viper.Get()

func GetSupportedNIPsFromKinds

func GetSupportedNIPsFromKinds(kinds []string) ([]int, error)

GetSupportedNIPsFromKinds returns unique NIP numbers for given kinds

func InitConfig

func InitConfig() error

InitConfig initializes the global viper configuration

func InitConfigForTesting

func InitConfigForTesting()

InitConfigForTesting initializes the configuration system for testing This should be called after setting up viper values manually in tests It loads the config into the cache without reading from a file

func IsEnabled

func IsEnabled(feature string) bool

IsEnabled checks if a service/feature is enabled

func RefreshConfig

func RefreshConfig() error

RefreshConfig forces a reload of the configuration cache This should be called after external changes to the configuration (e.g., via web UI)

func RemoveNIPMapping

func RemoveNIPMapping(kind string) error

RemoveNIPMapping removes a NIP mapping for a specific kind

func SaveConfig

func SaveConfig() error

SaveConfig saves the current configuration to file

func UpdateConfig

func UpdateConfig(key string, value interface{}, save bool) error

UpdateConfig updates a configuration value and optionally saves it Now with change detection to avoid unnecessary writes

func UpdateMultipleSections

func UpdateMultipleSections(settings map[string]interface{}) error

UpdateMultipleSections updates multiple configuration sections intelligently Only saves once at the end, and only if there were changes

func UpdateNIPMapping

func UpdateNIPMapping(kind, nip string) error

UpdateNIPMapping updates or adds a single NIP mapping

Types

This section is empty.

Jump to

Keyboard shortcuts

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