Mercurial > prosody-hg
comparison plugins/mod_admin_telnet.lua @ 8921:1c2925376315
mod_admin_telnet: Add debug:events() and debug:logevents()
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 22 Jun 2018 13:20:38 +0100 |
| parents | 4b5a00fffb22 |
| children | 47d318eeff8d |
comparison
equal
deleted
inserted
replaced
| 8919:c46c2942b8fe | 8921:1c2925376315 |
|---|---|
| 10 | 10 |
| 11 local hostmanager = require "core.hostmanager"; | 11 local hostmanager = require "core.hostmanager"; |
| 12 local modulemanager = require "core.modulemanager"; | 12 local modulemanager = require "core.modulemanager"; |
| 13 local s2smanager = require "core.s2smanager"; | 13 local s2smanager = require "core.s2smanager"; |
| 14 local portmanager = require "core.portmanager"; | 14 local portmanager = require "core.portmanager"; |
| 15 local helpers = require "util.helpers"; | |
| 15 | 16 |
| 16 local _G = _G; | 17 local _G = _G; |
| 17 | 18 |
| 18 local prosody = _G.prosody; | 19 local prosody = _G.prosody; |
| 19 local hosts = prosody.hosts; | 20 local hosts = prosody.hosts; |
| 1128 print("HTTP requests to unknown hosts will be handled by "..default_host); | 1129 print("HTTP requests to unknown hosts will be handled by "..default_host); |
| 1129 end | 1130 end |
| 1130 return true; | 1131 return true; |
| 1131 end | 1132 end |
| 1132 | 1133 |
| 1134 def_env.debug = {}; | |
| 1135 | |
| 1136 function def_env.debug:logevents(host) | |
| 1137 helpers.log_host_events(host); | |
| 1138 return true; | |
| 1139 end | |
| 1140 | |
| 1141 function def_env.debug:events(host, event) | |
| 1142 local events_obj; | |
| 1143 if host and host ~= "*" then | |
| 1144 if not hosts[host] then | |
| 1145 return false, "Unknown host: "..host; | |
| 1146 end | |
| 1147 events_obj = hosts[host].events; | |
| 1148 else | |
| 1149 events_obj = prosody.events; | |
| 1150 end | |
| 1151 return true, helpers.show_events(events_obj, event); | |
| 1152 end | |
| 1153 | |
| 1133 module:hook("server-stopping", function(event) | 1154 module:hook("server-stopping", function(event) |
| 1134 for conn, session in pairs(sessions) do | 1155 for conn, session in pairs(sessions) do |
| 1135 session.print("Shutting down: "..(event.reason or "unknown reason")); | 1156 session.print("Shutting down: "..(event.reason or "unknown reason")); |
| 1136 end | 1157 end |
| 1137 end); | 1158 end); |
