3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 03:49:27 +01:00

fix confusing ips-per-subnet name

This commit is contained in:
Shivaram Lingamneni 2018-02-25 05:17:39 -05:00
parent 0ea210c28c
commit 62581962a6
2 changed files with 13 additions and 8 deletions

View File

@ -12,11 +12,12 @@ import (
// LimiterConfig controls the automated connection limits. // LimiterConfig controls the automated connection limits.
type LimiterConfig struct { type LimiterConfig struct {
Enabled bool Enabled bool
CidrLenIPv4 int `yaml:"cidr-len-ipv4"` CidrLenIPv4 int `yaml:"cidr-len-ipv4"`
CidrLenIPv6 int `yaml:"cidr-len-ipv6"` CidrLenIPv6 int `yaml:"cidr-len-ipv6"`
IPsPerCidr int `yaml:"ips-per-subnet"` ConnsPerSubnet int `yaml:"connections-per-subnet"`
Exempted []string IPsPerSubnet int `yaml:"ips-per-subnet"` // legacy name for ConnsPerSubnet
Exempted []string
} }
var ( var (
@ -145,7 +146,11 @@ func (cl *Limiter) ApplyConfig(config LimiterConfig) error {
cl.ipv6Mask = net.CIDRMask(config.CidrLenIPv6, 128) cl.ipv6Mask = net.CIDRMask(config.CidrLenIPv6, 128)
// subnetLimit is explicitly NOT capped at a minimum of one. // subnetLimit is explicitly NOT capped at a minimum of one.
// this is so that CL config can be used to allow ONLY clients from exempted IPs/nets // this is so that CL config can be used to allow ONLY clients from exempted IPs/nets
cl.subnetLimit = config.IPsPerCidr cl.subnetLimit = config.ConnsPerSubnet
// but: check if the current key was left unset, but the legacy was set:
if cl.subnetLimit == 0 && config.IPsPerSubnet != 0 {
cl.subnetLimit = config.IPsPerSubnet
}
cl.exemptedIPs = exemptedIPs cl.exemptedIPs = exemptedIPs
cl.exemptedNets = exemptedNets cl.exemptedNets = exemptedNets

View File

@ -100,8 +100,8 @@ server:
# how wide the cidr should be for IPv6 # how wide the cidr should be for IPv6
cidr-len-ipv6: 64 cidr-len-ipv6: 64
# maximum number of IPs per subnet (defined above by the cird length) # maximum concurrent connections per subnet (defined above by the cidr length)
ips-per-subnet: 16 connections-per-subnet: 16
# IPs/networks which are exempted from connection limits # IPs/networks which are exempted from connection limits
exempted: exempted: