Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 4978:0b9e86302de4
mod_admin_telnet: add s2s:closeall command and relative help entry.
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Mon, 09 Jul 2012 19:50:11 +0000 |
parent | 4913:02dbed57a355 |
child | 4979:5614bbc163e0 |
comparison
equal
deleted
inserted
replaced
4953:24c2150cc8b0 | 4978:0b9e86302de4 |
---|---|
196 print [[c2s:show_secure() - Show all encrypted client connections]] | 196 print [[c2s:show_secure() - Show all encrypted client connections]] |
197 print [[c2s:close(jid) - Close all sessions for the specified JID]] | 197 print [[c2s:close(jid) - Close all sessions for the specified JID]] |
198 elseif section == "s2s" then | 198 elseif section == "s2s" then |
199 print [[s2s:show(domain) - Show all s2s connections for the given domain (or all if no domain given)]] | 199 print [[s2s:show(domain) - Show all s2s connections for the given domain (or all if no domain given)]] |
200 print [[s2s:close(from, to) - Close a connection from one domain to another]] | 200 print [[s2s:close(from, to) - Close a connection from one domain to another]] |
201 print [[s2s:closeall(host) - Close all the incoming/outgoing s2s sessions to specified host]] | |
201 elseif section == "module" then | 202 elseif section == "module" then |
202 print [[module:load(module, host) - Load the specified module on the specified host (or all hosts if none given)]] | 203 print [[module:load(module, host) - Load the specified module on the specified host (or all hosts if none given)]] |
203 print [[module:reload(module, host) - The same, but unloads and loads the module (saving state if the module supports it)]] | 204 print [[module:reload(module, host) - The same, but unloads and loads the module (saving state if the module supports it)]] |
204 print [[module:unload(module, host) - The same, but just unloads the module from memory]] | 205 print [[module:unload(module, host) - The same, but just unloads the module from memory]] |
205 print [[module:list(host) - List the modules loaded on the specified host]] | 206 print [[module:list(host) - List the modules loaded on the specified host]] |
767 end | 768 end |
768 | 769 |
769 return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s"); | 770 return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s"); |
770 end | 771 end |
771 | 772 |
773 function def_env.s2s:closeall(host) | |
774 local count = 0; | |
775 | |
776 if not host or type(host) ~= "string" then return false, "wrong syntax: please use s2s:closeall('hostname.tld')"; end | |
777 if hosts[host] then | |
778 for session in pairs(incoming_s2s) do | |
779 if session.to_host == host then | |
780 (session.close or s2smanager.destroy_session)(session); | |
781 count = count + 1; | |
782 end | |
783 end | |
784 for _, session in pairs(hosts[host].s2sout) do | |
785 (session.close or s2smanager.destroy_session)(session); | |
786 count = count + 1; | |
787 end | |
788 else | |
789 for session in pairs(incoming_s2s) do | |
790 if session.from_host == host then | |
791 (session.close or s2smanager.destroy_session)(session); | |
792 count = count + 1; | |
793 end | |
794 end | |
795 for _, h in pairs(hosts) do | |
796 if h.s2sout[host] then | |
797 (h.s2sout[host].close or s2smanager.destroy_session)(h.s2sout[host]); | |
798 count = count + 1; | |
799 end | |
800 end | |
801 end | |
802 | |
803 if count == 0 then return false, "No sessions to close."; | |
804 else return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s"); end | |
805 end | |
806 | |
772 def_env.host = {}; def_env.hosts = def_env.host; | 807 def_env.host = {}; def_env.hosts = def_env.host; |
773 | 808 |
774 function def_env.host:activate(hostname, config) | 809 function def_env.host:activate(hostname, config) |
775 return hostmanager.activate(hostname, config); | 810 return hostmanager.activate(hostname, config); |
776 end | 811 end |