Browse Source

fix #197

tags/v1.2.0-rc1
Shivaram Lingamneni 4 years ago
parent
commit
f6eb8fa5a1
2 changed files with 5 additions and 7 deletions
  1. 2
    7
      irc/connection_limits/limiter.go
  2. 3
    0
      irc/gateways.go

+ 2
- 7
irc/connection_limits/limiter.go View File

@@ -58,13 +58,8 @@ func (cl *Limiter) AddClient(addr net.IP, force bool) error {
58 58
 	cl.Lock()
59 59
 	defer cl.Unlock()
60 60
 
61
-	if !cl.enabled {
62
-		return nil
63
-	}
64
-
65
-	// check exempted lists
66 61
 	// we don't track populations for exempted addresses or nets - this is by design
67
-	if utils.IPInNets(addr, cl.exemptedNets) {
62
+	if !cl.enabled || utils.IPInNets(addr, cl.exemptedNets) {
68 63
 		return nil
69 64
 	}
70 65
 
@@ -85,7 +80,7 @@ func (cl *Limiter) RemoveClient(addr net.IP) {
85 80
 	cl.Lock()
86 81
 	defer cl.Unlock()
87 82
 
88
-	if !cl.enabled {
83
+	if !cl.enabled || utils.IPInNets(addr, cl.exemptedNets) {
89 84
 		return
90 85
 	}
91 86
 

+ 3
- 0
irc/gateways.go View File

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

Loading…
Cancel
Save