Mercurial > prosody-modules
comparison mod_limits/mod_limits.lua @ 3542:1bb2a90398d3
mod_limits: log throttled JID
author | Georg Lukas <georg@op-co.de> |
---|---|
date | Tue, 02 Apr 2019 16:27:14 +0200 |
parents | 88b16084eda7 |
children |
comparison
equal
deleted
inserted
replaced
3541:4d8a68557941 | 3542:1bb2a90398d3 |
---|---|
57 function default_filter_set.bytes_in(bytes, session) | 57 function default_filter_set.bytes_in(bytes, session) |
58 local throttle = session.throttle; | 58 local throttle = session.throttle; |
59 if throttle then | 59 if throttle then |
60 local ok, balance, outstanding = throttle:poll(#bytes, true); | 60 local ok, balance, outstanding = throttle:poll(#bytes, true); |
61 if not ok then | 61 if not ok then |
62 session.log("debug", "Session over rate limit (%d) with %d (by %d), pausing", throttle.max, #bytes, outstanding); | 62 session.log("debug", "Session %q over rate limit (%d) with %d (by %d), pausing", session.full_jid or session.from_host or session.to_host, throttle.max, #bytes, outstanding); |
63 outstanding = ceil(outstanding); | 63 outstanding = ceil(outstanding); |
64 session.conn:pause(); -- Read no more data from the connection until there is no outstanding data | 64 session.conn:pause(); -- Read no more data from the connection until there is no outstanding data |
65 local outstanding_data = bytes:sub(-outstanding); | 65 local outstanding_data = bytes:sub(-outstanding); |
66 bytes = bytes:sub(1, #bytes-outstanding); | 66 bytes = bytes:sub(1, #bytes-outstanding); |
67 timer.add_task(limits_resolution, function () | 67 timer.add_task(limits_resolution, function () |