config

package
v0.3.3-nightly Latest Latest
Warning

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

Go to latest
Published: May 19, 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 types.BlacklistConfig) error

Adds a pubkey to the temporary blacklist

func CheckBlacklist

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

CheckBlacklist checks if a pubkey is in the blacklist based on event content

func CheckWhitelist

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

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() *configTypes.BlacklistConfig

GetBlacklistConfig returns the blacklist configuration.

func GetConfig

func GetConfig() *configTypes.ServerConfig

GetConfig returns the server configuration.

func GetTemporaryBlacklist

func GetTemporaryBlacklist() []map[string]interface{}

GetTemporaryBlacklist fetches all currently active temporary bans

func GetWhitelistConfig

func GetWhitelistConfig() *configTypes.WhitelistConfig

GetWhitelistConfig returns the whitelist configuration.

func IsKindWhitelisted

func IsKindWhitelisted(kind int) bool

Check if a kind is whitelisted

func IsPubKeyWhitelisted

func IsPubKeyWhitelisted(pubKey string, skipEnabledCheck bool) bool

IsPubKeyWhitelisted checks if a pubkey or npub is whitelisted, considering pubkeys from domains. The `skipEnabledCheck` flag indicates if the check should happen regardless of whether or not the whitelist is enabled.

func LoadBlacklistConfig

func LoadBlacklistConfig(filename string) (*configTypes.BlacklistConfig, error)

LoadBlacklistConfig loads the blacklist configuration from blacklist.yml.

func LoadConfig

func LoadConfig(filename string) (*configTypes.ServerConfig, error)

LoadConfig loads the server configuration from config.yml.

func LoadWhitelistConfig

func LoadWhitelistConfig(filename string) (*configTypes.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 *config.ServerConfig)

func SetRateLimiter

func SetRateLimiter(rl *RateLimiter)

func SetResourceLimit

func SetResourceLimit(cfg *configTypes.ResourceLimits)

func SetSizeLimit

func SetSizeLimit(cfg *config.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 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