Documentation
¶
Index ¶
- func AddToPermanentBlacklist(pubkey string) error
- func AddToTemporaryBlacklist(pubkey string, blacklistConfig types.BlacklistConfig) error
- func CheckBlacklist(pubkey, eventContent string) (bool, string)
- func CheckWhitelist(evt nostr.Event) (bool, string)
- func ClearTemporaryBans()
- func FetchPubkeysFromLocalMuteList(localRelayURL string, muteListAuthors []string) ([]string, error)
- func GetBlacklistConfig() *configTypes.BlacklistConfig
- func GetConfig() *configTypes.ServerConfig
- func GetTemporaryBlacklist() []map[string]interface{}
- func GetWhitelistConfig() *configTypes.WhitelistConfig
- func IsKindWhitelisted(kind int) bool
- func IsPubKeyWhitelisted(pubKey string, skipEnabledCheck bool) bool
- func LoadBlacklistConfig(filename string) (*configTypes.BlacklistConfig, error)
- func LoadConfig(filename string) (*configTypes.ServerConfig, error)
- func LoadWhitelistConfig(filename string) (*configTypes.WhitelistConfig, error)
- func ResetBlacklistConfig()
- func ResetConfig()
- func ResetWhitelistConfig()
- func SetRateLimit(cfg *config.ServerConfig)
- func SetRateLimiter(rl *RateLimiter)
- func SetResourceLimit(cfg *configTypes.ResourceLimits)
- func SetSizeLimit(cfg *config.ServerConfig)
- func SizeLimit(sl *SizeLimiter)
- func WatchConfigFile(filePath string, restartChan chan<- struct{})
- type CategoryLimiter
- type KindLimiter
- 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 types.BlacklistConfig) error
Adds a pubkey to the temporary blacklist
func CheckBlacklist ¶
CheckBlacklist checks if a pubkey is in the blacklist based on event content
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 IsPubKeyWhitelisted ¶
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 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 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)