Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type GenericThrottle ¶ added in v1.0.0
type GenericThrottle struct { ThrottleDetails // variable state: what events have been seen // these are constant after creation: Duration time.Duration // window length to consider Limit int // number of events allowed per window }
GenericThrottle allows enforcing limits of the form "at most X events per time window of duration Y"
func (*GenericThrottle) Touch ¶ added in v1.0.0
func (g *GenericThrottle) Touch() (throttled bool, remainingTime time.Duration)
Touch checks whether an additional event is allowed: it either denies it (by returning false) or allows it (by returning true) and records it
type Limiter ¶
Limiter manages the automated client connection limits.
func (*Limiter) AddClient ¶
AddClient adds a client to our population if possible. If we can't, throws an error instead. 'force' is used to add already-existing clients (i.e. ones that are already on the network).
func (*Limiter) ApplyConfig ¶
func (cl *Limiter) ApplyConfig(config LimiterConfig) error
ApplyConfig atomically applies a config update to a connection limit handler
type LimiterConfig ¶
type LimiterConfig struct { Enabled bool CidrLenIPv4 int `yaml:"cidr-len-ipv4"` CidrLenIPv6 int `yaml:"cidr-len-ipv6"` ConnsPerSubnet int `yaml:"connections-per-subnet"` IPsPerSubnet int `yaml:"ips-per-subnet"` // legacy name for ConnsPerSubnet Exempted []string }
LimiterConfig controls the automated connection limits.
type ThrottleDetails ¶
ThrottleDetails holds the connection-throttling details for a subnet/IP.
type Throttler ¶
Throttler manages automated client connection throttling.
func (*Throttler) AddClient ¶
AddClient introduces a new client connection if possible. If we can't, throws an error instead.
func (*Throttler) ApplyConfig ¶
func (ct *Throttler) ApplyConfig(config ThrottlerConfig) error
ApplyConfig atomically applies a config update to a throttler
type ThrottlerConfig ¶
type ThrottlerConfig struct { Enabled bool CidrLenIPv4 int `yaml:"cidr-len-ipv4"` CidrLenIPv6 int `yaml:"cidr-len-ipv6"` ConnectionsPerCidr int `yaml:"max-connections"` DurationString string `yaml:"duration"` Duration time.Duration `yaml:"duration-time"` BanDurationString string `yaml:"ban-duration"` BanDuration time.Duration BanMessage string `yaml:"ban-message"` Exempted []string }
ThrottlerConfig controls the automated connection throttling.
type TorLimiter ¶ added in v1.1.0
TorLimiter is a combined limiter and throttler for use on connections proxied from a Tor hidden service (so we don't have meaningful IPs, a notion of CIDR width, etc.)
func (*TorLimiter) AddClient ¶ added in v1.1.0
func (tl *TorLimiter) AddClient() error
func (*TorLimiter) Configure ¶ added in v1.1.0
func (tl *TorLimiter) Configure(maxConnections int, duration time.Duration, maxConnectionsPerDuration int)
func (*TorLimiter) RemoveClient ¶ added in v1.1.0
func (tl *TorLimiter) RemoveClient()