Changeset

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
parents 8762:2f8523bf7ff2
children 8764:81d305bbe7bc
files plugins/mod_s2s/mod_s2s.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_s2s/mod_s2s.lua	Sun Apr 29 21:43:39 2018 +0100
+++ b/plugins/mod_s2s/mod_s2s.lua	Sat Sep 09 14:45:23 2017 +0100
@@ -39,6 +39,7 @@
 local require_encryption = module:get_option_boolean("s2s_require_encryption", false);
 
 local measure_connections = module:measure("connections", "amount");
+local measure_ipv6 = module:measure("ipv6", "amount");
 
 local sessions = module:shared("sessions");
 
@@ -48,10 +49,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);
 
 --- Handle stanzas to remote domains