aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_admin_telnet.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2015-12-10 18:00:08 +0000
committerMatthew Wild <mwild1@gmail.com>2015-12-10 18:00:08 +0000
commit7f8d1c0995b51435b4d6a4f5c7a5d5ed7ab5d8e2 (patch)
tree22557ca2de807dcec68cecccf0623d5bcbd9192b /plugins/mod_admin_telnet.lua
parent9409b787dc7d6602836f43eeafee772b79afe6a4 (diff)
downloadprosody-7f8d1c0995b51435b4d6a4f5c7a5d5ed7ab5d8e2.tar.gz
prosody-7f8d1c0995b51435b4d6a4f5c7a5d5ed7ab5d8e2.zip
mod_admin_telnet: Add http:list() command to get info about current HTTP endpoints on the server
Diffstat (limited to 'plugins/mod_admin_telnet.lua')
-rw-r--r--plugins/mod_admin_telnet.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua
index 16bc786d..b77a1f56 100644
--- a/plugins/mod_admin_telnet.lua
+++ b/plugins/mod_admin_telnet.lua
@@ -282,6 +282,8 @@ end
-- Session environment --
-- Anything in def_env will be accessible within the session as a global variable
+--luacheck: ignore 212/self
+
def_env.server = {};
function def_env.server:insane_reload()
@@ -1093,6 +1095,33 @@ function def_env.dns:cache()
return true, "Cache:\n"..tostring(dns.cache())
end
+def_env.http = {};
+
+function def_env.http:list()
+ local print = self.session.print;
+
+ for host in pairs(prosody.hosts) do
+ local http_apps = modulemanager.get_items("http-provider", host);
+ if #http_apps > 0 then
+ local http_host = module:context(host):get_option("http_host");
+ print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":"));
+ for _, provider in ipairs(http_apps) do
+ local url = module:context(host):http_url(provider.name);
+ print("", url);
+ end
+ print("");
+ end
+ end
+
+ local default_host = module:get_option("http_default_host");
+ if not default_host then
+ print("HTTP requests to unknown hosts will return 404 Not Found");
+ else
+ print("HTTP requests to unknown hosts will be handled by "..default_host);
+ end
+ return true;
+end
+
-------------
function printbanner(session)