Merge 0.10->trunk
[prosody.git] / plugins / mod_admin_telnet.lua
index 9dfbbc7a379c524ad1dcdc79381a6ce2123014e9..dd583663c01746f216fdc551d3b2b3ca38ca8556 100644 (file)
@@ -336,6 +336,43 @@ function def_env.server:memory()
        return true, "OK";
 end
 
+def_env.timer = {};
+
+function def_env.timer:info()
+       local socket = require "socket";
+       local print = self.session.print;
+       local add_task = require"util.timer".add_task;
+       local h, params = add_task.h, add_task.params;
+       if h then
+               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
+       end
+       if server.event_base then
+               local count = 0;
+               for k, v in pairs(debug.getregistry()) do
+                       if type(v) == "function" and v.callback and v.callback == add_task._on_timer then
+                               count = count + 1;
+                       end
+               end
+               print(count .. " libevent callbacks");
+       end
+       if h then
+               local next_time = h:peek();
+               if next_time then
+                       return true, os.date("Next event at %F %T (in %%.6fs)", next_time):format(next_time - socket.gettime());
+               end
+       end
+       return true;
+end
+
 def_env.module = {};
 
 local function get_hosts_set(hosts, module)
@@ -732,7 +769,6 @@ local function print_errors(print, errors)
 end
 
 function def_env.s2s:showcert(domain)
-       local ser = require "util.serialization".serialize;
        local print = self.session.print;
        local s2s_sessions = module:shared"/*/s2s/sessions";
        local domain_sessions = set.new(array.collect(values(s2s_sessions)))
@@ -957,11 +993,11 @@ local function check_muc(jid)
 end
 
 function def_env.muc:create(room_jid)
-       local room, host = check_muc(room_jid);
+       local room_name, host = check_muc(room_jid);
        if not room_name then
                return room_name, host;
        end
-       if not room then return nil, host end
+       if not room_name then return nil, host end
        if hosts[host].modules.muc.rooms[room_jid] then return nil, "Room exists already" end
        return hosts[host].modules.muc.create_room(room_jid);
 end
@@ -971,7 +1007,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
@@ -985,8 +1021,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";
@@ -1151,7 +1187,7 @@ function printbanner(session)
        if option == "short" or option == "full" then
        session.print("Welcome to the Prosody administration console. For a list of commands, type: help");
        session.print("You may find more help on using this console in our online documentation at ");
-       session.print("http://prosody.im/doc/console\n");
+       session.print("https://prosody.im/doc/console\n");
        end
        if option ~= "short" and option ~= "full" and option ~= "graphic" then
                session.print(option);