Warn about banning a single IPv6 address
This commit is contained in:
Shivaram Lingamneni 2021-11-30 03:27:40 -05:00
parent eef9753912
commit fd45529d94
3 changed files with 54 additions and 1 deletions

View file

@ -366,7 +366,14 @@ func ubanInfoHandler(client *Client, target ubanTarget, params []string, rb *Res
}
func ubanInfoCIDR(client *Client, target ubanTarget, rb *ResponseBuffer) {
if target.cidr.PrefixLen == 128 {
config := client.server.Config()
// show connection limiter/throttler state if this CIDR is entirely
// contained in a single limiter/throttler bucket:
ones, bits := target.cidr.Size()
showLimiter := (bits == 32 && ones >= config.Server.IPLimits.CidrLenIPv4) ||
(bits == 128 && ones >= config.Server.IPLimits.CidrLenIPv6)
sendMaskWarning := (bits == 128 && ones > config.Server.IPLimits.CidrLenIPv6)
if showLimiter {
netName, status := client.server.connectionLimiter.Status(target.cidr.IP)
if status.Exempt {
rb.Notice(fmt.Sprintf(client.t("IP %s is exempt from connection limits"), target.cidr.IP.String()))
@ -391,6 +398,10 @@ func ubanInfoCIDR(client *Client, target ubanTarget, rb *ResponseBuffer) {
rb.Notice(line)
}
}
if sendMaskWarning {
rb.Notice(fmt.Sprintf(client.t("Note: try evaluating a wider IPv6 CIDR like %s/%d"),
target.cidr.IP.String(), config.Server.IPLimits.CidrLenIPv6))
}
}
func ubanInfoNickmask(client *Client, target ubanTarget, rb *ResponseBuffer) {