Merge 0.10->trunk
[prosody.git] / plugins / mod_admin_telnet.lua
index 66560d448bdbaadc252350ce4f166742b592283d..9185ac1ba41586c19cdc3f077315cc5e96488824 100644 (file)
@@ -27,6 +27,7 @@ local set, array = require "util.set", require "util.array";
 local cert_verify_identity = require "util.x509".verify_identity;
 local envload = require "util.envload".envload;
 local envloadfile = require "util.envload".envloadfile;
+local has_pposix, pposix = pcall(require, "util.pposix");
 
 local commands = module:shared("commands")
 local def_env = module:shared("env");
@@ -170,6 +171,10 @@ function console_listener.ondisconnect(conn, err)
        end
 end
 
+function console_listener.ondetach(conn)
+       sessions[conn] = nil;
+end
+
 -- Console commands --
 -- These are simple commands, not valid standalone in Lua
 
@@ -318,7 +323,7 @@ local function human(kb)
 end
 
 function def_env.server:memory()
-       if not pposix.meminfo then
+       if not has_pposix or not pposix.meminfo then
                return true, "Lua is using "..collectgarbage("count");
        end
        local mem, lua_mem = pposix.meminfo(), collectgarbage("count");
@@ -957,7 +962,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
@@ -970,8 +975,8 @@ function def_env.muc:list(host)
                return nil, "Please supply the address of a local MUC component";
        end
        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";
@@ -1073,12 +1078,12 @@ function def_env.dns:lookup(name, typ, class)
 end
 
 function def_env.dns:addnameserver(...)
-       dns.addnameserver(...)
+       dns._resolver:addnameserver(...)
        return true
 end
 
 function def_env.dns:setnameserver(...)
-       dns.setnameserver(...)
+       dns._resolver:setnameserver(...)
        return true
 end