Documentation
¶
Index ¶
- func AddToPermanentBlacklist(pubkey string) error
- func AddToTemporaryBlacklist(pubkey string, blacklistConfig cfgType.BlacklistConfig) error
- func CheckAndMigrateConfig(filename string) error
- func CheckBlacklistCached(pubkey, eventContent string) (bool, string)
- func CheckWhitelistCached(evt nostr.Event) (bool, string)
- func ClearTemporaryBans()
- func ConfigPath(filename string) string
- func EnsureAllConfigFiles() error
- func FetchGroupedMuteListPubkeys(localRelayURL string, muteListAuthors []string) (map[string][]string, error)
- func FetchPubkeysFromLocalMuteList(localRelayURL string, muteListAuthors []string) ([]string, error)
- func GetBlacklistConfig() *cfgType.BlacklistConfig
- func GetConfig() *cfgType.ServerConfig
- func GetDataDir() string
- func GetTemporaryBlacklist() []map[string]interface{}
- func GetWhitelistConfig() *cfgType.WhitelistConfig
- func InitializePubkeyCache()
- func IsKindWhitelisted(kind int) bool
- func IsPubKeyWhitelistedCached(pubKey string, skipEnabledCheck bool) bool
- func LoadBlacklistConfig(filename string) (*cfgType.BlacklistConfig, error)
- func LoadConfig(filename string) (*cfgType.ServerConfig, error)
- func LoadWhitelistConfig(filename string) (*cfgType.WhitelistConfig, error)
- func ResetBlacklistConfig()
- func ResetConfig()
- func ResetWhitelistConfig()
- func SetDataDir(dir string)
- func SetEmbeddedExamples(fs embed.FS)
- func SetRateLimit(cfg *cfgType.ServerConfig)
- func SetRateLimiter(rl *RateLimiter)
- func SetResourceLimit(cfg *cfgType.ResourceLimits)
- func SetSizeLimit(cfg *cfgType.ServerConfig)
- func SizeLimit(sl *SizeLimiter)
- func ValidateAndApplyDefaults(cfg *cfgType.ServerConfig) (warnings []string, err error)
- func WatchConfigFile(filePath string, restartChan chan<- struct{})
- type CategoryLimiter
- type KindLimiter
- type PubkeyCache
- func (pc *PubkeyCache) GetBlacklistedPubkeys() []string
- func (pc *PubkeyCache) GetDirectWhitelistedPubkeys() []string
- func (pc *PubkeyCache) GetDomainPubkeys(domain string) []string
- func (pc *PubkeyCache) GetPubkeyCacheStats() map[string]interface{}
- func (pc *PubkeyCache) GetWhitelistSourceBreakdown() map[string]interface{}
- func (pc *PubkeyCache) GetWhitelistedPubkeys() []string
- func (pc *PubkeyCache) IsBlacklisted(pubkey string) bool
- func (pc *PubkeyCache) IsBlacklistedForValidation(pubkey string) bool
- func (pc *PubkeyCache) IsWhitelisted(pubkey string) bool
- func (pc *PubkeyCache) IsWhitelistedForValidation(pubkey string) bool
- func (pc *PubkeyCache) RefreshBlacklist() error
- func (pc *PubkeyCache) RefreshWhitelist() error
- type RateLimiter
- func (rl *RateLimiter) AddCategoryLimit(category string, limit rate.Limit, burst int)
- func (rl *RateLimiter) AddKindLimit(kind int, limit rate.Limit, burst int)
- func (rl *RateLimiter) AllowEvent(kind int, category string) (bool, string)
- func (rl *RateLimiter) AllowReq() (bool, string)
- func (rl *RateLimiter) AllowWs() (bool, string)
- type SizeLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddToPermanentBlacklist ¶
func AddToTemporaryBlacklist ¶
func AddToTemporaryBlacklist(pubkey string, blacklistConfig cfgType.BlacklistConfig) error
Adds a pubkey to the temporary blacklist
func CheckAndMigrateConfig ¶ added in v0.5.0
CheckAndMigrateConfig reads the raw YAML file and checks for outdated config formats (e.g., the old mongodb section from before the nostrdb migration). It prints warnings to stderr since this runs before loggers are initialized.
func CheckBlacklistCached ¶
CheckBlacklistCached uses cached pubkey lists and respects enabled state for validation
func CheckWhitelistCached ¶
CheckWhitelistCached uses cached pubkey lists and respects enabled state for validation
func ClearTemporaryBans ¶
func ClearTemporaryBans()
func ConfigPath ¶ added in v0.5.0
ConfigPath returns the full path for a file within the data directory.
func EnsureAllConfigFiles ¶ added in v0.4.1
func EnsureAllConfigFiles() error
EnsureAllConfigFiles creates all default config files from embedded examples if they don't exist. Files are created in the resolved data directory.
func FetchGroupedMuteListPubkeys ¶ added in v0.4.1
func FetchGroupedMuteListPubkeys(localRelayURL string, muteListAuthors []string) (map[string][]string, error)
FetchGroupedMuteListPubkeys fetches mutelist pubkeys grouped by author
func FetchPubkeysFromLocalMuteList ¶
func FetchPubkeysFromLocalMuteList(localRelayURL string, muteListAuthors []string) ([]string, error)
FetchPubkeysFromLocalMuteList sends a REQ to the local relay for mute list events.
func GetBlacklistConfig ¶
func GetBlacklistConfig() *cfgType.BlacklistConfig
GetBlacklistConfig returns the blacklist configuration.
func GetDataDir ¶ added in v0.5.0
func GetDataDir() string
GetDataDir returns the resolved data directory path.
func GetTemporaryBlacklist ¶
func GetTemporaryBlacklist() []map[string]interface{}
GetTemporaryBlacklist fetches all currently active temporary bans
func GetWhitelistConfig ¶
func GetWhitelistConfig() *cfgType.WhitelistConfig
GetWhitelistConfig returns the whitelist configuration.
func InitializePubkeyCache ¶
func InitializePubkeyCache()
InitializePubkeyCache starts the cache system with initial refresh and background updates
func IsPubKeyWhitelistedCached ¶
IsPubKeyWhitelistedCached for purging operations - always uses cache regardless of enabled state
func LoadBlacklistConfig ¶
func LoadBlacklistConfig(filename string) (*cfgType.BlacklistConfig, error)
LoadBlacklistConfig loads the blacklist configuration from blacklist.yml.
func LoadConfig ¶
func LoadConfig(filename string) (*cfgType.ServerConfig, error)
Update your LoadConfig function to call this:
func LoadWhitelistConfig ¶
func LoadWhitelistConfig(filename string) (*cfgType.WhitelistConfig, error)
LoadWhitelistConfig loads the whitelist configuration from whitelist.yml.
func ResetBlacklistConfig ¶
func ResetBlacklistConfig()
ResetBlacklistConfig clears the existing blacklist configuration.
func ResetWhitelistConfig ¶
func ResetWhitelistConfig()
ResetWhitelistConfig clears the existing whitelist configuration.
func SetDataDir ¶ added in v0.5.0
func SetDataDir(dir string)
SetDataDir sets the resolved data directory path for the application.
func SetEmbeddedExamples ¶ added in v0.4.1
SetEmbeddedExamples sets the embedded filesystem from main package
func SetRateLimit ¶
func SetRateLimit(cfg *cfgType.ServerConfig)
func SetRateLimiter ¶
func SetRateLimiter(rl *RateLimiter)
func SetResourceLimit ¶
func SetResourceLimit(cfg *cfgType.ResourceLimits)
func SetSizeLimit ¶
func SetSizeLimit(cfg *cfgType.ServerConfig)
func SizeLimit ¶
func SizeLimit(sl *SizeLimiter)
func ValidateAndApplyDefaults ¶ added in v0.5.0
func ValidateAndApplyDefaults(cfg *cfgType.ServerConfig) (warnings []string, err error)
ValidateAndApplyDefaults checks the config for zero-valued fields and applies sensible defaults. It returns a list of warnings for each default applied and an error if the config is truly broken.
func WatchConfigFile ¶
func WatchConfigFile(filePath string, restartChan chan<- struct{})
Types ¶
type CategoryLimiter ¶
type PubkeyCache ¶
type PubkeyCache struct {
// contains filtered or unexported fields
}
PubkeyCache manages cached pubkey lists with source tracking for whitelist and blacklist operations
func GetPubkeyCache ¶
func GetPubkeyCache() *PubkeyCache
GetPubkeyCache returns the global cache instance
func (*PubkeyCache) GetBlacklistedPubkeys ¶
func (pc *PubkeyCache) GetBlacklistedPubkeys() []string
func (*PubkeyCache) GetDirectWhitelistedPubkeys ¶ added in v0.4.1
func (pc *PubkeyCache) GetDirectWhitelistedPubkeys() []string
GetDirectWhitelistedPubkeys returns only direct config pubkeys (excluding domain pubkeys) Use this for API endpoints that want to show only directly configured pubkeys
func (*PubkeyCache) GetDomainPubkeys ¶ added in v0.4.1
func (pc *PubkeyCache) GetDomainPubkeys(domain string) []string
GetDomainPubkeys returns pubkeys for a specific domain from cache
func (*PubkeyCache) GetPubkeyCacheStats ¶
func (pc *PubkeyCache) GetPubkeyCacheStats() map[string]interface{}
GetPubkeyCacheStats returns enhanced cache statistics for monitoring
func (*PubkeyCache) GetWhitelistSourceBreakdown ¶ added in v0.4.1
func (pc *PubkeyCache) GetWhitelistSourceBreakdown() map[string]interface{}
GetWhitelistSourceBreakdown returns detailed source breakdown for API endpoints
func (*PubkeyCache) GetWhitelistedPubkeys ¶
func (pc *PubkeyCache) GetWhitelistedPubkeys() []string
GetWhitelistedPubkeys returns a copy of all whitelisted pubkeys for bulk operations Maintains backward compatibility
func (*PubkeyCache) IsBlacklisted ¶
func (pc *PubkeyCache) IsBlacklisted(pubkey string) bool
Blacklist functions remain unchanged
func (*PubkeyCache) IsBlacklistedForValidation ¶
func (pc *PubkeyCache) IsBlacklistedForValidation(pubkey string) bool
func (*PubkeyCache) IsWhitelisted ¶
func (pc *PubkeyCache) IsWhitelisted(pubkey string) bool
IsWhitelisted checks if a pubkey is in ANY whitelist source (fast lookup) Maintains backward compatibility
func (*PubkeyCache) IsWhitelistedForValidation ¶
func (pc *PubkeyCache) IsWhitelistedForValidation(pubkey string) bool
IsWhitelistedForValidation checks if a pubkey is whitelisted AND whitelist is enabled Maintains backward compatibility
func (*PubkeyCache) RefreshBlacklist ¶
func (pc *PubkeyCache) RefreshBlacklist() error
Blacklist functions remain unchanged for backward compatibility
func (*PubkeyCache) RefreshWhitelist ¶
func (pc *PubkeyCache) RefreshWhitelist() error
RefreshWhitelist rebuilds the whitelist cache with source tracking Always caches all sources regardless of enabled state for sync/purge operations
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
func GetRateLimiter ¶
func GetRateLimiter() *RateLimiter
func NewRateLimiter ¶
func (*RateLimiter) AddCategoryLimit ¶
func (rl *RateLimiter) AddCategoryLimit(category string, limit rate.Limit, burst int)
func (*RateLimiter) AddKindLimit ¶
func (rl *RateLimiter) AddKindLimit(kind int, limit rate.Limit, burst int)
func (*RateLimiter) AllowEvent ¶
func (rl *RateLimiter) AllowEvent(kind int, category string) (bool, string)
func (*RateLimiter) AllowReq ¶
func (rl *RateLimiter) AllowReq() (bool, string)
func (*RateLimiter) AllowWs ¶
func (rl *RateLimiter) AllowWs() (bool, string)
type SizeLimiter ¶
type SizeLimiter struct {
// contains filtered or unexported fields
}
func GetSizeLimiter ¶
func GetSizeLimiter() *SizeLimiter
func NewSizeLimiter ¶
func NewSizeLimiter(globalMaxSize int) *SizeLimiter
func (*SizeLimiter) AddKindSizeLimit ¶
func (sl *SizeLimiter) AddKindSizeLimit(kind int, maxSize int)
func (*SizeLimiter) SetGlobalMaxSize ¶
func (sl *SizeLimiter) SetGlobalMaxSize(maxSize int)