config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToPermanentBlacklist

func AddToPermanentBlacklist(pubkey string) error

func AddToTemporaryBlacklist

func AddToTemporaryBlacklist(pubkey string, blacklistConfig cfgType.BlacklistConfig) error

Adds a pubkey to the temporary blacklist

func CheckBlacklistCached

func CheckBlacklistCached(pubkey, eventContent string) (bool, string)

CheckBlacklistCached uses cached pubkey lists and respects enabled state for validation

func CheckWhitelistCached

func CheckWhitelistCached(evt nostr.Event) (bool, string)

CheckWhitelistCached uses cached pubkey lists and respects enabled state for validation

func ClearTemporaryBans

func ClearTemporaryBans()

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 GetConfig

func GetConfig() *cfgType.ServerConfig

GetConfig returns the server configuration.

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 IsKindWhitelisted

func IsKindWhitelisted(kind int) bool

Check if a kind is whitelisted

func IsPubKeyWhitelistedCached

func IsPubKeyWhitelistedCached(pubKey string, skipEnabledCheck bool) bool

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)

LoadConfig loads the server configuration from config.yml.

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 ResetConfig

func ResetConfig()

ResetConfig clears the existing server configuration.

func ResetWhitelistConfig

func ResetWhitelistConfig()

ResetWhitelistConfig clears the existing whitelist configuration.

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 WatchConfigFile

func WatchConfigFile(filePath string, restartChan chan<- struct{})

Types

type CategoryLimiter

type CategoryLimiter struct {
	Limiter *rate.Limiter
	Limit   rate.Limit
	Burst   int
}

type KindLimiter

type KindLimiter struct {
	Limiter *rate.Limiter
	Limit   rate.Limit
	Burst   int
}

type PubkeyCache

type PubkeyCache struct {
	// contains filtered or unexported fields
}

PubkeyCache manages cached pubkey lists for whitelist and blacklist operations

func GetPubkeyCache

func GetPubkeyCache() *PubkeyCache

GetPubkeyCache returns the global cache instance

func (*PubkeyCache) GetBlacklistedPubkeys

func (pc *PubkeyCache) GetBlacklistedPubkeys() []string

GetBlacklistedPubkeys returns a copy of all blacklisted pubkeys for bulk operations

func (*PubkeyCache) GetPubkeyCacheStats

func (pc *PubkeyCache) GetPubkeyCacheStats() map[string]interface{}

GetPubkeyCacheStats returns cache statistics for monitoring

func (*PubkeyCache) GetWhitelistedPubkeys

func (pc *PubkeyCache) GetWhitelistedPubkeys() []string

GetWhitelistedPubkeys returns a copy of all whitelisted pubkeys for bulk operations

func (*PubkeyCache) IsBlacklisted

func (pc *PubkeyCache) IsBlacklisted(pubkey string) bool

IsBlacklisted checks if a pubkey is in the blacklist cache Use this for sync/purge operations that need all cached pubkeys regardless of enabled state

func (*PubkeyCache) IsBlacklistedForValidation

func (pc *PubkeyCache) IsBlacklistedForValidation(pubkey string) bool

IsBlacklistedForValidation checks if a pubkey is blacklisted AND blacklist is enabled Use this for event validation that should respect enabled state

func (*PubkeyCache) IsWhitelisted

func (pc *PubkeyCache) IsWhitelisted(pubkey string) bool

IsWhitelisted checks if a pubkey is in the whitelist cache Use this for sync/purge operations that need all cached pubkeys regardless of enabled state

func (*PubkeyCache) IsWhitelistedForValidation

func (pc *PubkeyCache) IsWhitelistedForValidation(pubkey string) bool

IsWhitelistedForValidation checks if a pubkey is whitelisted AND whitelist is enabled Use this for event validation that should respect enabled state

func (*PubkeyCache) RefreshBlacklist

func (pc *PubkeyCache) RefreshBlacklist() error

RefreshBlacklist rebuilds the blacklist cache from configuration Always caches all sources regardless of enabled state for sync/purge operations

func (*PubkeyCache) RefreshWhitelist

func (pc *PubkeyCache) RefreshWhitelist() error

RefreshWhitelist rebuilds the whitelist cache from configuration 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 NewRateLimiter(wsLimit rate.Limit, wsBurst int, eventLimit rate.Limit, eventBurst int, reqLimit rate.Limit, reqBurst int) *RateLimiter

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) AllowSize

func (sl *SizeLimiter) AllowSize(kind int, size int) (bool, string)

func (*SizeLimiter) SetGlobalMaxSize

func (sl *SizeLimiter) SetGlobalMaxSize(maxSize int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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