Comparison

plugins/mod_admin_telnet.lua @ 4979:5614bbc163e0

Merge with Maranda
author Matthew Wild <mwild1@gmail.com>
date Sun, 22 Jul 2012 18:52:20 +0100
parent 4977:7006ccbf22a9
parent 4978:0b9e86302de4
child 4989:573123ff2ab0
comparison
equal deleted inserted replaced
4977:7006ccbf22a9 4979:5614bbc163e0
197 print [[c2s:show_secure() - Show all encrypted client connections]] 197 print [[c2s:show_secure() - Show all encrypted client connections]]
198 print [[c2s:close(jid) - Close all sessions for the specified JID]] 198 print [[c2s:close(jid) - Close all sessions for the specified JID]]
199 elseif section == "s2s" then 199 elseif section == "s2s" then
200 print [[s2s:show(domain) - Show all s2s connections for the given domain (or all if no domain given)]] 200 print [[s2s:show(domain) - Show all s2s connections for the given domain (or all if no domain given)]]
201 print [[s2s:close(from, to) - Close a connection from one domain to another]] 201 print [[s2s:close(from, to) - Close a connection from one domain to another]]
202 print [[s2s:closeall(host) - Close all the incoming/outgoing s2s sessions to specified host]]
202 elseif section == "module" then 203 elseif section == "module" then
203 print [[module:load(module, host) - Load the specified module on the specified host (or all hosts if none given)]] 204 print [[module:load(module, host) - Load the specified module on the specified host (or all hosts if none given)]]
204 print [[module:reload(module, host) - The same, but unloads and loads the module (saving state if the module supports it)]] 205 print [[module:reload(module, host) - The same, but unloads and loads the module (saving state if the module supports it)]]
205 print [[module:unload(module, host) - The same, but just unloads the module from memory]] 206 print [[module:unload(module, host) - The same, but just unloads the module from memory]]
206 print [[module:list(host) - List the modules loaded on the specified host]] 207 print [[module:list(host) - List the modules loaded on the specified host]]
772 end 773 end
773 774
774 return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s"); 775 return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s");
775 end 776 end
776 777
778 function def_env.s2s:closeall(host)
779 local count = 0;
780
781 if not host or type(host) ~= "string" then return false, "wrong syntax: please use s2s:closeall('hostname.tld')"; end
782 if hosts[host] then
783 for session in pairs(incoming_s2s) do
784 if session.to_host == host then
785 (session.close or s2smanager.destroy_session)(session);
786 count = count + 1;
787 end
788 end
789 for _, session in pairs(hosts[host].s2sout) do
790 (session.close or s2smanager.destroy_session)(session);
791 count = count + 1;
792 end
793 else
794 for session in pairs(incoming_s2s) do
795 if session.from_host == host then
796 (session.close or s2smanager.destroy_session)(session);
797 count = count + 1;
798 end
799 end
800 for _, h in pairs(hosts) do
801 if h.s2sout[host] then
802 (h.s2sout[host].close or s2smanager.destroy_session)(h.s2sout[host]);
803 count = count + 1;
804 end
805 end
806 end
807
808 if count == 0 then return false, "No sessions to close.";
809 else return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s"); end
810 end
811
777 def_env.host = {}; def_env.hosts = def_env.host; 812 def_env.host = {}; def_env.hosts = def_env.host;
778 813
779 function def_env.host:activate(hostname, config) 814 function def_env.host:activate(hostname, config)
780 return hostmanager.activate(hostname, config); 815 return hostmanager.activate(hostname, config);
781 end 816 end