Merge 0.10->trunk
authorMatthew Wild <mwild1@gmail.com>
Thu, 10 Dec 2015 18:58:30 +0000 (18:58 +0000)
committerMatthew Wild <mwild1@gmail.com>
Thu, 10 Dec 2015 18:58:30 +0000 (18:58 +0000)
1  2 
plugins/mod_admin_telnet.lua

index 7aea28ba659250cf2044a63bca0d1090fe1d23b3,b77a1f564fb2d02127ac0aff35d44ae8e5f2a9df..aa7b10cb9c37b02d7862d319216e9c79624f91ef
@@@ -282,6 -282,8 +282,8 @@@ en
  -- 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()
@@@ -334,38 -336,6 +336,38 @@@ function def_env.server:memory(
        return true, "OK";
  end
  
 +def_env.timer = {};
 +
 +function def_env.timer:info()
 +      local print = self.session.print;
 +      local add_task = require"util.timer".add_task;
 +      local h, params = add_task.h, add_task.params;
 +      print("-- util.timer");
 +      for i, id in ipairs(h.ids) do
 +              if not params[id] then
 +                      print(os.date("%F %T", h.priorities[i]), h.items[id]);
 +              elseif not params[id].callback then
 +                      print(os.date("%F %T", h.priorities[i]), h.items[id], unpack(params[id]));
 +              else
 +                      print(os.date("%F %T", h.priorities[i]), params[id].callback, unpack(params[id]));
 +              end
 +      end
 +      if server.event_base then
 +              local count = 0;
 +              for k, v in pairs(debug.getregistry()) do
 +                      if type(v) == "function" and v.callback == add_task._on_timer then
 +                              count = count + 1;
 +                      end
 +              end
 +              print(count .. " libevent callbacks");
 +      end
 +      local next_time = h:peek();
 +      if next_time then
 +              return true, os.date("Next event at %F %T", next_time);
 +      end
 +      return true;
 +end
 +
  def_env.module = {};
  
  local function get_hosts_set(hosts, module)
@@@ -990,7 -960,7 +992,7 @@@ function def_env.muc:room(room_jid
        if not room_name then
                return room_name, host;
        end
 -      local room_obj = hosts[host].modules.muc.rooms[room_jid];
 +      local room_obj = hosts[host].modules.muc.get_room_from_jid(room_jid);
        if not room_obj then
                return nil, "No such room: "..room_jid;
        end
@@@ -1004,8 -974,8 +1006,8 @@@ function def_env.muc:list(host
        end
        local print = self.session.print;
        local c = 0;
 -      for name in keys(host_session.modules.muc.rooms) do
 -              print(name);
 +      for room in host_session.modules.muc.each_room() do
 +              print(room.jid);
                c = c + 1;
        end
        return true, c.." rooms";
@@@ -1125,6 -1095,33 +1127,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)