Mercurial > prosody-modules
comparison mod_c2s_conn_throttle/mod_c2s_conn_throttle.lua @ 1343:7dbde05b48a9
all the things: Remove trailing whitespace
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Tue, 11 Mar 2014 18:44:01 +0100 |
| parents | 9eefbaba274d |
| children | e79f9dec35c0 |
comparison
equal
deleted
inserted
replaced
| 1342:0ae065453dc9 | 1343:7dbde05b48a9 |
|---|---|
| 11 | 11 |
| 12 if not in_count[session.ip] and session.type == "c2s_unauthed" then | 12 if not in_count[session.ip] and session.type == "c2s_unauthed" then |
| 13 in_count[session.ip] = { t = time(), c = 1 } | 13 in_count[session.ip] = { t = time(), c = 1 } |
| 14 elseif in_count[session.ip] and session.type == "c2s_unauthed" then | 14 elseif in_count[session.ip] and session.type == "c2s_unauthed" then |
| 15 if in_count[session.ip].starttls_c then in_count[session.ip].c = in_count[session.ip].starttls_c else in_count[session.ip].c = in_count[session.ip].c + 1 end | 15 if in_count[session.ip].starttls_c then in_count[session.ip].c = in_count[session.ip].starttls_c else in_count[session.ip].c = in_count[session.ip].c + 1 end |
| 16 | 16 |
| 17 if in_count[session.ip].c > logins_count and time() - in_count[session.ip].t < throttle_time then | 17 if in_count[session.ip].c > logins_count and time() - in_count[session.ip].t < throttle_time then |
| 18 module:log("error", "Exceeded login count for %s, closing connection", session.ip) | 18 module:log("error", "Exceeded login count for %s, closing connection", session.ip) |
| 19 session:close{ condition = "policy-violation", text = "You exceeded the number of connections/logins allowed in "..throttle_time.." seconds, good bye." } | 19 session:close{ condition = "policy-violation", text = "You exceeded the number of connections/logins allowed in "..throttle_time.." seconds, good bye." } |
| 20 return true | 20 return true |
| 21 elseif time() - in_count[session.ip].t > throttle_time then | 21 elseif time() - in_count[session.ip].t > throttle_time then |
| 22 in_count[session.ip] = nil ; return | 22 in_count[session.ip] = nil ; return |
| 23 end | 23 end |
| 24 end | 24 end |
| 25 end | 25 end |
| 26 | 26 |
| 27 local function check_starttls(event) | 27 local function check_starttls(event) |
| 28 local session = event.origin | 28 local session = event.origin |
| 29 | 29 |
