3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-01-03 00:22:34 +01:00

add loglines for IP limits

This commit is contained in:
Shivaram Lingamneni 2017-10-09 13:17:49 -04:00
parent ac9ac5ef19
commit 58faad90dd

View File

@ -298,6 +298,7 @@ func (server *Server) checkBans(ipaddr net.IP) (banned bool, message string) {
// check DLINEs // check DLINEs
isBanned, info := server.dlines.CheckIP(ipaddr) isBanned, info := server.dlines.CheckIP(ipaddr)
if isBanned { if isBanned {
server.logger.Info("localconnect-ip", fmt.Sprintf("Client from %v rejected by d-line", ipaddr))
return true, info.BanMessage("You are banned from this server (%s)") return true, info.BanMessage("You are banned from this server (%s)")
} }
@ -305,6 +306,7 @@ func (server *Server) checkBans(ipaddr net.IP) (banned bool, message string) {
err := server.connectionLimits.AddClient(ipaddr, false) err := server.connectionLimits.AddClient(ipaddr, false)
if err != nil { if err != nil {
// too many connections from one client, tell the client and close the connection // too many connections from one client, tell the client and close the connection
server.logger.Info("localconnect-ip", fmt.Sprintf("Client from %v rejected for connection limit", ipaddr))
return true, "Too many clients from your network" return true, "Too many clients from your network"
} }
@ -324,6 +326,9 @@ func (server *Server) checkBans(ipaddr net.IP) (banned bool, message string) {
server.connectionThrottle.ResetFor(ipaddr) server.connectionThrottle.ResetFor(ipaddr)
// this might not show up properly on some clients, but our objective here is just to close it out before it has a load impact on us // this might not show up properly on some clients, but our objective here is just to close it out before it has a load impact on us
server.logger.Info(
"localconnect-ip",
fmt.Sprintf("Client from %v exceeded connection throttle, d-lining for %v", ipaddr, duration))
return true, server.connectionThrottle.BanMessage() return true, server.connectionThrottle.BanMessage()
} }