Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 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 |
parent | 6927:566e1cfcb814 |
child | 6988:329d5fb8a9d3 |
child | 7031:89221daefae9 |
comparison
equal
deleted
inserted
replaced
6986:6aae14b079d0 | 6987:06696882d972 |
---|---|
280 end | 280 end |
281 | 281 |
282 -- Session environment -- | 282 -- Session environment -- |
283 -- Anything in def_env will be accessible within the session as a global variable | 283 -- Anything in def_env will be accessible within the session as a global variable |
284 | 284 |
285 --luacheck: ignore 212/self | |
286 | |
285 def_env.server = {}; | 287 def_env.server = {}; |
286 | 288 |
287 function def_env.server:insane_reload() | 289 function def_env.server:insane_reload() |
288 prosody.unlock_globals(); | 290 prosody.unlock_globals(); |
289 dofile "prosody" | 291 dofile "prosody" |
1091 | 1093 |
1092 function def_env.dns:cache() | 1094 function def_env.dns:cache() |
1093 return true, "Cache:\n"..tostring(dns.cache()) | 1095 return true, "Cache:\n"..tostring(dns.cache()) |
1094 end | 1096 end |
1095 | 1097 |
1098 def_env.http = {}; | |
1099 | |
1100 function def_env.http:list() | |
1101 local print = self.session.print; | |
1102 | |
1103 for host in pairs(prosody.hosts) do | |
1104 local http_apps = modulemanager.get_items("http-provider", host); | |
1105 if #http_apps > 0 then | |
1106 local http_host = module:context(host):get_option("http_host"); | |
1107 print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":")); | |
1108 for _, provider in ipairs(http_apps) do | |
1109 local url = module:context(host):http_url(provider.name); | |
1110 print("", url); | |
1111 end | |
1112 print(""); | |
1113 end | |
1114 end | |
1115 | |
1116 local default_host = module:get_option("http_default_host"); | |
1117 if not default_host then | |
1118 print("HTTP requests to unknown hosts will return 404 Not Found"); | |
1119 else | |
1120 print("HTTP requests to unknown hosts will be handled by "..default_host); | |
1121 end | |
1122 return true; | |
1123 end | |
1124 | |
1096 ------------- | 1125 ------------- |
1097 | 1126 |
1098 function printbanner(session) | 1127 function printbanner(session) |
1099 local option = module:get_option("console_banner"); | 1128 local option = module:get_option("console_banner"); |
1100 if option == nil or option == "full" or option == "graphic" then | 1129 if option == nil or option == "full" or option == "graphic" then |