Changeset

1491:694a0a00e1a5

mod_console: Add c2s:close() command
author Matthew Wild <mwild1@gmail.com>
date Wed, 08 Jul 2009 02:29:13 +0100
parents 1490:b5c59667a04c
children 1492:aaeccebad0f3
files plugins/mod_console.lua
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_console.lua	Wed Jul 08 02:27:33 2009 +0100
+++ b/plugins/mod_console.lua	Wed Jul 08 02:29:13 2009 +0100
@@ -17,6 +17,7 @@
 local console_listener = { default_port = 5582; default_mode = "*l"; };
 
 require "util.iterators";
+local jid_bare = require "util.jid".bare;
 local set, array = require "util.set", require "util.array";
 
 local commands = {};
@@ -320,6 +321,16 @@
 	return true, "Total: "..count.." secure client connections";
 end
 
+function def_env.c2s:close(match_jid)
+	local print, count = self.session.print, 0;
+	show_c2s(function (jid, session)
+		if jid == match_jid or jid_bare(jid) == match_jid then
+			count = count + 1;
+			session:close();
+		end
+	end);
+	return true, "Total: "..count.." sessions closed";
+end
 
 def_env.s2s = {};
 function def_env.s2s:show(match_jid)