Documentation
¶
Index ¶
- Constants
- Variables
- func HasDriver(name string) bool
- func ListDrivers() []string
- func RegisterDriver(name, description string, factory DriverFactory)
- type A
- type Curating
- func (c *Curating) BlacklistPubkey(pubkeyHex, reason string) error
- func (c *Curating) CheckPolicy(ev *event.E) (allowed bool, err error)
- func (c *Curating) Configure(cfg ...any) (err error)
- func (c *Curating) Context() context.Context
- func (c *Curating) FilterVisibleEvents(events []*event.E, accessLevel string) []*event.E
- func (c *Curating) GetACLInfo() (name, description, documentation string)
- func (c *Curating) GetAccessLevel(pub []byte, address string) (level string)
- func (c *Curating) GetConfig() (database.CuratingConfig, error)
- func (c *Curating) GetCuratingACL() *database.CuratingACL
- func (c *Curating) IsBlacklisted(pubkeyHex string) bool
- func (c *Curating) IsConfigured() (bool, error)
- func (c *Curating) IsEventVisible(ev *event.E, accessLevel string) bool
- func (c *Curating) IsTrusted(pubkeyHex string) bool
- func (c *Curating) ProcessConfigEvent(ev *event.E) error
- func (c *Curating) RateLimitCheck(pubkeyHex, ip string) (allowed bool, message string, err error)
- func (c *Curating) RefreshCaches() error
- func (c *Curating) Syncer()
- func (c *Curating) TrustPubkey(pubkeyHex, note string) error
- func (c *Curating) Type() string
- func (c *Curating) UnblacklistPubkey(pubkeyHex string) error
- func (c *Curating) UntrustPubkey(pubkeyHex string) error
- type DriverConfig
- type DriverFactory
- type DriverInfo
- type Follows
- func (f *Follows) AddFollow(pub []byte)
- func (f *Follows) AdminRelays() []string
- func (f *Follows) Configure(cfg ...any) (err error)
- func (f *Follows) Context() context.Context
- func (f *Follows) GetACLInfo() (name, description, documentation string)
- func (f *Follows) GetAccessLevel(pub []byte, address string) (level string)
- func (f *Follows) GetFollowedPubkeys() [][]byte
- func (f *Follows) GetThrottleDelay(pubkey []byte, ip string) time.Duration
- func (f *Follows) SetFollowListUpdateCallback(callback func())
- func (f *Follows) Syncer()
- func (f *Follows) Type() string
- type I
- type Managed
- func (m *Managed) CheckPolicy(ev *event.E) (allowed bool, err error)
- func (m *Managed) Configure(cfg ...any) (err error)
- func (m *Managed) Context() context.Context
- func (m *Managed) GetACLInfo() (name, description, documentation string)
- func (m *Managed) GetAccessLevel(pub []byte, address string) (level string)
- func (m *Managed) GetManagedACL() *database.ManagedACL
- func (m *Managed) IsIPBlocked(ip string) bool
- func (m *Managed) Syncer()
- func (m *Managed) Type() string
- func (m *Managed) UpdatePeerAdmins(peerPubkeys [][]byte)
- type None
- func (n None) CheckPolicy(ev *event.E) (allowed bool, err error)
- func (n *None) Configure(cfg ...any) (err error)
- func (n None) GetACLInfo() (name, description, documentation string)
- func (n *None) GetAccessLevel(pub []byte, address string) (level string)
- func (n None) Syncer()
- func (n None) Type() string
- type ProgressiveThrottle
- type S
- func (s *S) ACLs() []acliface.I
- func (s *S) AddFollow(pub []byte)
- func (s *S) CheckPolicy(ev *event.E) (allowed bool, err error)
- func (s *S) Configure(cfg ...any) (err error)
- func (s *S) GetACLByType(typ string) acliface.I
- func (s *S) GetACLInfo() (name, description, documentation string)
- func (s *S) GetAccessLevel(pub []byte, address string) (level string)
- func (s *S) GetActiveACL() acliface.I
- func (s *S) GetMode() string
- func (s *S) IsRegistered(typ string) bool
- func (s *S) ListRegisteredACLs() []string
- func (s *S) Register(i acliface.I)
- func (s *S) RegisterAndActivate(i acliface.I)
- func (s *S) SetMode(m string)
- func (s *S) Syncer()
- func (s *S) Type() (typ string)
- type ThrottleState
Constants ¶
const ( DefaultDailyLimit = 50 DefaultIPDailyLimit = 500 // Max events per IP per day (flood protection) DefaultFirstBanHours = 1 DefaultSecondBanHours = 168 // 1 week CuratingConfigKind = 30078 CuratingConfigDTag = "curating-config" )
Default values for curating mode
Variables ¶
var Registry = &S{}
Functions ¶
func ListDrivers ¶ added in v0.55.4
func ListDrivers() []string
ListDrivers returns a sorted list of registered driver names.
func RegisterDriver ¶ added in v0.55.4
func RegisterDriver(name, description string, factory DriverFactory)
RegisterDriver registers an ACL driver with the given name and factory. This is typically called from init() in the driver package.
Types ¶
type Curating ¶ added in v0.47.0
type Curating struct {
// Ctx holds the context for the ACL.
// Deprecated: Use Context() method instead of accessing directly.
Ctx context.Context
// contains filtered or unexported fields
}
Curating implements the curating ACL mode with three-tier publisher classification: - Trusted: Unlimited publishing - Blacklisted: Cannot publish - Unclassified: Rate-limited publishing (default 50/day)
func (*Curating) BlacklistPubkey ¶ added in v0.47.0
BlacklistPubkey adds a pubkey to the blacklist
func (*Curating) CheckPolicy ¶ added in v0.47.0
CheckPolicy implements the PolicyChecker interface for event-level filtering
func (*Curating) FilterVisibleEvents ¶ added in v0.47.0
FilterVisibleEvents filters a list of events, removing those from blacklisted pubkeys. Returns only events visible to the given access level.
func (*Curating) GetACLInfo ¶ added in v0.47.0
func (*Curating) GetAccessLevel ¶ added in v0.47.0
func (*Curating) GetConfig ¶ added in v0.47.0
func (c *Curating) GetConfig() (database.CuratingConfig, error)
GetConfig returns the current configuration
func (*Curating) GetCuratingACL ¶ added in v0.47.0
func (c *Curating) GetCuratingACL() *database.CuratingACL
GetCuratingACL returns the database ACL instance for direct access
func (*Curating) IsBlacklisted ¶ added in v0.47.0
IsBlacklisted checks if a pubkey is blacklisted
func (*Curating) IsConfigured ¶ added in v0.47.0
IsConfigured returns true if the relay has been configured
func (*Curating) IsEventVisible ¶ added in v0.47.0
IsEventVisible checks if an event should be visible to the given access level. Events from blacklisted pubkeys are only visible to admin/owner.
func (*Curating) ProcessConfigEvent ¶ added in v0.47.0
ProcessConfigEvent processes a kind 30078 event to extract curating configuration
func (*Curating) RateLimitCheck ¶ added in v0.47.0
RateLimitCheck checks if an unclassified user can publish and handles IP tracking This is called separately when we have access to the IP address
func (*Curating) RefreshCaches ¶ added in v0.47.0
RefreshCaches refreshes all in-memory caches from the database
func (*Curating) TrustPubkey ¶ added in v0.47.0
TrustPubkey adds a pubkey to the trusted list
func (*Curating) UnblacklistPubkey ¶ added in v0.47.0
UnblacklistPubkey removes a pubkey from the blacklist
func (*Curating) UntrustPubkey ¶ added in v0.47.0
UntrustPubkey removes a pubkey from the trusted list
type DriverConfig ¶ added in v0.55.4
type DriverConfig struct {
// Common settings
LogLevel string
Owners []string
Admins []string
BootstrapRelays []string
RelayAddresses []string
// Follows-specific settings
FollowListFrequency string
FollowsThrottleEnabled bool
FollowsThrottlePerEvent string
FollowsThrottleMaxDelay string
}
DriverConfig holds configuration for ACL drivers.
type DriverFactory ¶ added in v0.55.4
DriverFactory is the signature for ACL driver factory functions.
func GetDriver ¶ added in v0.55.4
func GetDriver(name string) DriverFactory
GetDriver returns the factory for the named driver, or nil if not found.
type DriverInfo ¶ added in v0.55.4
type DriverInfo struct {
Name string
Description string
Factory DriverFactory
}
DriverInfo contains metadata about a registered ACL driver.
func ListDriversWithInfo ¶ added in v0.55.4
func ListDriversWithInfo() []*DriverInfo
ListDriversWithInfo returns information about all registered drivers.
type Follows ¶
type Follows struct {
// Ctx holds the context for the ACL.
// Deprecated: Use Context() method instead of accessing directly.
Ctx context.Context
// contains filtered or unexported fields
}
func (*Follows) AddFollow ¶ added in v0.8.0
AddFollow appends a pubkey to the in-memory follows list if not already present and signals the syncer to refresh subscriptions.
func (*Follows) AdminRelays ¶ added in v0.17.14
AdminRelays returns the admin relay URLs
func (*Follows) GetACLInfo ¶
func (*Follows) GetAccessLevel ¶
func (*Follows) GetFollowedPubkeys ¶ added in v0.6.0
GetFollowedPubkeys returns a copy of the followed pubkeys list
func (*Follows) GetThrottleDelay ¶ added in v0.48.10
GetThrottleDelay returns the progressive throttle delay for this event. Returns 0 if throttle is disabled or if the user is exempt (owner/admin/followed).
func (*Follows) SetFollowListUpdateCallback ¶ added in v0.29.0
func (f *Follows) SetFollowListUpdateCallback(callback func())
SetFollowListUpdateCallback sets a callback to be called when the follow list is updated
type I ¶ added in v0.55.4
type I interface {
Configure(cfg ...any) (err error)
GetAccessLevel(pub []byte, address string) (level string)
GetACLInfo() (name, description, documentation string)
Syncer()
Type() string
}
I is the ACL interface that drivers must implement. This is re-exported from the interfaces package for convenience.
func NewFromDriver ¶ added in v0.55.4
func NewFromDriver(ctx context.Context, driverName string, db database.Database, cfg *DriverConfig) (I, error)
NewFromDriver creates an ACL using the named driver. Returns an error if the driver is not registered.
type Managed ¶ added in v0.17.0
type Managed struct {
// Ctx holds the context for the ACL.
// Deprecated: Use Context() method instead of accessing directly.
Ctx context.Context
// contains filtered or unexported fields
}
func (*Managed) CheckPolicy ¶ added in v0.17.0
func (*Managed) GetACLInfo ¶ added in v0.17.0
func (*Managed) GetAccessLevel ¶ added in v0.17.0
func (*Managed) GetManagedACL ¶ added in v0.17.0
func (m *Managed) GetManagedACL() *database.ManagedACL
GetManagedACL returns the managed ACL database instance
func (*Managed) IsIPBlocked ¶ added in v0.17.0
IsIPBlocked checks if an IP address is blocked
func (*Managed) UpdatePeerAdmins ¶ added in v0.24.1
UpdatePeerAdmins updates the list of peer relay identity pubkeys that have admin access
type None ¶
type None struct {
// contains filtered or unexported fields
}
func (None) CheckPolicy ¶ added in v0.16.0
func (None) GetACLInfo ¶
func (*None) GetAccessLevel ¶
type ProgressiveThrottle ¶ added in v0.48.10
type ProgressiveThrottle struct {
// contains filtered or unexported fields
}
ProgressiveThrottle implements linear delay with time decay. Each event adds perEvent delay, and delay decays at 1:1 ratio with elapsed time. This creates a natural rate limit that averages to 1 event per perEvent interval.
func NewProgressiveThrottle ¶ added in v0.48.10
func NewProgressiveThrottle(perEvent, maxDelay time.Duration) *ProgressiveThrottle
NewProgressiveThrottle creates a new throttle with the given parameters. perEvent is the delay added per event (e.g., 200ms). maxDelay is the maximum accumulated delay cap (e.g., 60s).
func (*ProgressiveThrottle) Cleanup ¶ added in v0.48.10
func (pt *ProgressiveThrottle) Cleanup()
Cleanup removes entries that have fully decayed (no remaining delay). This should be called periodically to prevent unbounded memory growth.
func (*ProgressiveThrottle) GetDelay ¶ added in v0.48.10
func (pt *ProgressiveThrottle) GetDelay(ip, pubkeyHex string) time.Duration
GetDelay returns accumulated delay for this identity and updates state. It tracks both IP and pubkey independently and returns the maximum of both. This prevents evasion via different pubkeys from same IP or vice versa.
func (*ProgressiveThrottle) Stats ¶ added in v0.48.10
func (pt *ProgressiveThrottle) Stats() (ipCount, pubkeyCount int)
Stats returns the current number of tracked IPs and pubkeys (for monitoring)
type S ¶
type S struct {
// contains filtered or unexported fields
}
func (*S) ACLs ¶ added in v0.56.8
ACLs returns the registered ACL implementations for iteration. Prefer using GetActiveACL() or GetACLByType() when possible.
func (*S) AddFollow ¶ added in v0.8.0
AddFollow forwards a pubkey to the active ACL if it supports dynamic follows
func (*S) CheckPolicy ¶ added in v0.17.0
CheckPolicy checks if an event is allowed by the active ACL policy
func (*S) GetACLByType ¶ added in v0.56.5
GetACLByType returns the ACL implementation with the given type name, or nil if not found.
func (*S) GetACLInfo ¶
func (*S) GetActiveACL ¶ added in v0.56.5
GetActiveACL returns the currently active ACL implementation, or nil if none is active.
func (*S) IsRegistered ¶ added in v0.56.5
IsRegistered returns true if an ACL with the given type is registered.
func (*S) ListRegisteredACLs ¶ added in v0.56.5
ListRegisteredACLs returns the type names of all registered ACL implementations.
func (*S) RegisterAndActivate ¶ added in v0.54.0
RegisterAndActivate registers an ACL implementation and sets it as the active one. This is used for gRPC clients where the mode is determined by the remote server.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package grpc provides a gRPC client that implements the acl.I interface.
|
Package grpc provides a gRPC client that implements the acl.I interface. |
|
Package server provides a shared gRPC ACL server implementation.
|
Package server provides a shared gRPC ACL server implementation. |