Changeset

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
parents 8763:67ecff7be011
children 8765:d5ff0982d3e6
files plugins/mod_c2s.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_c2s.lua	Sat Sep 09 14:45:23 2017 +0100
+++ b/plugins/mod_c2s.lua	Sat Sep 09 14:45:23 2017 +0100
@@ -28,6 +28,7 @@
 local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true));
 
 local measure_connections = module:measure("connections", "amount");
+local measure_ipv6 = module:measure("ipv6", "amount");
 
 local sessions = module:shared("sessions");
 local core_process_stanza = prosody.core_process_stanza;
@@ -39,10 +40,15 @@
 
 module:hook("stats-update", function ()
 	local count = 0;
-	for _ in pairs(sessions) do
+	local ipv6 = 0;
+	for _, session in pairs(sessions) do
 		count = count + 1;
+		if session.ip and session.ip:match(":") then
+			ipv6 = ipv6 + 1;
+		end
 	end
 	measure_connections(count);
+	measure_ipv6(ipv6);
 end);
 
 --- Stream events handlers