Comparison

plugins/mod_c2s.lua @ 8764:81d305bbe7bc

mod_c2s: Add a counter for IPv6.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 09 Sep 2017 14:45:23 +0100
parent 8390:4c629fde768c
child 8820:1348a931528a
comparison
equal deleted inserted replaced
8763:67ecff7be011 8764:81d305bbe7bc
26 local c2s_timeout = module:get_option_number("c2s_timeout", 300); 26 local c2s_timeout = module:get_option_number("c2s_timeout", 300);
27 local stream_close_timeout = module:get_option_number("c2s_close_timeout", 5); 27 local stream_close_timeout = module:get_option_number("c2s_close_timeout", 5);
28 local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true)); 28 local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true));
29 29
30 local measure_connections = module:measure("connections", "amount"); 30 local measure_connections = module:measure("connections", "amount");
31 local measure_ipv6 = module:measure("ipv6", "amount");
31 32
32 local sessions = module:shared("sessions"); 33 local sessions = module:shared("sessions");
33 local core_process_stanza = prosody.core_process_stanza; 34 local core_process_stanza = prosody.core_process_stanza;
34 local hosts = prosody.hosts; 35 local hosts = prosody.hosts;
35 36
37 local listener = {}; 38 local listener = {};
38 local runner_callbacks = {}; 39 local runner_callbacks = {};
39 40
40 module:hook("stats-update", function () 41 module:hook("stats-update", function ()
41 local count = 0; 42 local count = 0;
42 for _ in pairs(sessions) do 43 local ipv6 = 0;
44 for _, session in pairs(sessions) do
43 count = count + 1; 45 count = count + 1;
46 if session.ip and session.ip:match(":") then
47 ipv6 = ipv6 + 1;
48 end
44 end 49 end
45 measure_connections(count); 50 measure_connections(count);
51 measure_ipv6(ipv6);
46 end); 52 end);
47 53
48 --- Stream events handlers 54 --- Stream events handlers
49 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; 55 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
50 56