3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 18:52:41 +01:00
This commit is contained in:
Shivaram Lingamneni 2019-09-01 02:36:56 -04:00
parent 8a33d68cf1
commit f6eb8fa5a1
2 changed files with 5 additions and 7 deletions

View File

@ -58,13 +58,8 @@ func (cl *Limiter) AddClient(addr net.IP, force bool) error {
cl.Lock() cl.Lock()
defer cl.Unlock() defer cl.Unlock()
if !cl.enabled {
return nil
}
// check exempted lists
// we don't track populations for exempted addresses or nets - this is by design // we don't track populations for exempted addresses or nets - this is by design
if utils.IPInNets(addr, cl.exemptedNets) { if !cl.enabled || utils.IPInNets(addr, cl.exemptedNets) {
return nil return nil
} }
@ -85,7 +80,7 @@ func (cl *Limiter) RemoveClient(addr net.IP) {
cl.Lock() cl.Lock()
defer cl.Unlock() defer cl.Unlock()
if !cl.enabled { if !cl.enabled || utils.IPInNets(addr, cl.exemptedNets) {
return return
} }

View File

@ -63,6 +63,9 @@ func (client *Client) ApplyProxiedIP(session *Session, proxiedIP string, tls boo
if isBanned { if isBanned {
return errBanned, banMsg return errBanned, banMsg
} }
// successfully added a limiter entry for the proxied IP;
// remove the entry for the real IP if applicable (#197)
client.server.connectionLimiter.RemoveClient(session.realIP)
// given IP is sane! override the client's current IP // given IP is sane! override the client's current IP
ipstring := parsedProxiedIP.String() ipstring := parsedProxiedIP.String()