Software /
code /
prosody
Comparison
plugins/mod_s2s/mod_s2s.lua @ 8763:67ecff7be011
mod_s2s: Add a counter for IPv6.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 09 Sep 2017 14:45:23 +0100 |
parent | 8545:248bab2bd0c9 |
child | 8920:2eaa442d81a6 |
comparison
equal
deleted
inserted
replaced
8762:2f8523bf7ff2 | 8763:67ecff7be011 |
---|---|
37 local secure_domains, insecure_domains = | 37 local secure_domains, insecure_domains = |
38 module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items; | 38 module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items; |
39 local require_encryption = module:get_option_boolean("s2s_require_encryption", false); | 39 local require_encryption = module:get_option_boolean("s2s_require_encryption", false); |
40 | 40 |
41 local measure_connections = module:measure("connections", "amount"); | 41 local measure_connections = module:measure("connections", "amount"); |
42 local measure_ipv6 = module:measure("ipv6", "amount"); | |
42 | 43 |
43 local sessions = module:shared("sessions"); | 44 local sessions = module:shared("sessions"); |
44 | 45 |
45 local runner_callbacks = {}; | 46 local runner_callbacks = {}; |
46 | 47 |
47 local log = module._log; | 48 local log = module._log; |
48 | 49 |
49 module:hook("stats-update", function () | 50 module:hook("stats-update", function () |
50 local count = 0; | 51 local count = 0; |
51 for _ in pairs(sessions) do | 52 local ipv6 = 0; |
53 for _, session in pairs(sessions) do | |
52 count = count + 1; | 54 count = count + 1; |
55 if session.ip and session.ip:match(":") then | |
56 ipv6 = ipv6 + 1; | |
57 end | |
53 end | 58 end |
54 measure_connections(count); | 59 measure_connections(count); |
60 measure_ipv6(ipv6); | |
55 end); | 61 end); |
56 | 62 |
57 --- Handle stanzas to remote domains | 63 --- Handle stanzas to remote domains |
58 | 64 |
59 local bouncy_stanzas = { message = true, presence = true, iq = true }; | 65 local bouncy_stanzas = { message = true, presence = true, iq = true }; |