Software /
code /
prosody
Changeset
6987:06696882d972
mod_admin_telnet: Add http:list() command to get info about current HTTP endpoints on the server
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 10 Dec 2015 18:00:08 +0000 |
parents | 6986:6aae14b079d0 |
children | 6988:329d5fb8a9d3 6992:0622f2820d1d 7006:93771dad3e05 |
files | plugins/mod_admin_telnet.lua |
diffstat | 1 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua Thu Dec 10 17:58:52 2015 +0000 +++ b/plugins/mod_admin_telnet.lua Thu Dec 10 18:00:08 2015 +0000 @@ -282,6 +282,8 @@ -- 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 @@ 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)