mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-26 13:59:44 +01:00
review feedback: rename a key
This commit is contained in:
parent
41497c1b51
commit
2d456c2106
@ -33,7 +33,7 @@ type customLimit struct {
|
|||||||
// rawLimiterConfig contains all the YAML-visible fields;
|
// rawLimiterConfig contains all the YAML-visible fields;
|
||||||
// LimiterConfig contains additional denormalized private fields
|
// LimiterConfig contains additional denormalized private fields
|
||||||
type rawLimiterConfig struct {
|
type rawLimiterConfig struct {
|
||||||
Limit bool
|
Count bool
|
||||||
MaxConcurrent int `yaml:"max-concurrent-connections"`
|
MaxConcurrent int `yaml:"max-concurrent-connections"`
|
||||||
|
|
||||||
Throttle bool
|
Throttle bool
|
||||||
@ -156,7 +156,7 @@ func (cl *Limiter) AddClient(addr net.IP) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now check limiter
|
// now check limiter
|
||||||
if cl.config.Limit {
|
if cl.config.Count {
|
||||||
count := cl.limiter[addrString] + 1
|
count := cl.limiter[addrString] + 1
|
||||||
if count > maxConcurrent {
|
if count > maxConcurrent {
|
||||||
return ErrLimitExceeded
|
return ErrLimitExceeded
|
||||||
@ -172,7 +172,7 @@ func (cl *Limiter) RemoveClient(addr net.IP) {
|
|||||||
cl.Lock()
|
cl.Lock()
|
||||||
defer cl.Unlock()
|
defer cl.Unlock()
|
||||||
|
|
||||||
if !cl.config.Limit || utils.IPInNets(addr, cl.config.exemptedNets) {
|
if !cl.config.Count || utils.IPInNets(addr, cl.config.exemptedNets) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ func easyParseIP(ipstr string) (result net.IP) {
|
|||||||
|
|
||||||
var baseConfig = LimiterConfig{
|
var baseConfig = LimiterConfig{
|
||||||
rawLimiterConfig: rawLimiterConfig{
|
rawLimiterConfig: rawLimiterConfig{
|
||||||
Limit: true,
|
Count: true,
|
||||||
MaxConcurrent: 4,
|
MaxConcurrent: 4,
|
||||||
|
|
||||||
Throttle: true,
|
Throttle: true,
|
||||||
|
@ -67,7 +67,7 @@ func makeTestThrottler(v4len, v6len int) *Limiter {
|
|||||||
maxConnections := 3
|
maxConnections := 3
|
||||||
config := LimiterConfig{
|
config := LimiterConfig{
|
||||||
rawLimiterConfig: rawLimiterConfig{
|
rawLimiterConfig: rawLimiterConfig{
|
||||||
Limit: false,
|
Count: false,
|
||||||
Throttle: true,
|
Throttle: true,
|
||||||
CidrLenIPv4: v4len,
|
CidrLenIPv4: v4len,
|
||||||
CidrLenIPv6: v6len,
|
CidrLenIPv6: v6len,
|
||||||
|
@ -146,8 +146,8 @@ server:
|
|||||||
|
|
||||||
# IP-based DoS protection
|
# IP-based DoS protection
|
||||||
ip-limits:
|
ip-limits:
|
||||||
# whether to enforce limits on the total number of concurrent connections per IP/CIDR
|
# whether to limit the total count of concurrent connections per IP/CIDR
|
||||||
limit: true
|
count: true
|
||||||
# maximum concurrent connections per IP/CIDR
|
# maximum concurrent connections per IP/CIDR
|
||||||
max-concurrent-connections: 16
|
max-concurrent-connections: 16
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user