# HG changeset patch # User Matthew Wild # Date 1336060324 -3600 # Node ID 3bf0100d7303d0bdc41aa675f2ba9842a0293631 # Parent 07d0a3a75c8af7d63d0ad23d8a151494555a30d5# Parent 3068ec951ffdb937a36ece372942b6de589b856d Merge with Zash diff -r 3068ec951ffd -r 3bf0100d7303 net/server.lua --- a/net/server.lua Thu May 03 15:38:12 2012 +0200 +++ b/net/server.lua Thu May 03 16:52:04 2012 +0100 @@ -18,19 +18,8 @@ local server; if use_luaevent then - server = require "net.server_event"; - -- util.timer requires "net.server", so instead of having - -- Lua look for, and load us again (causing a loop) - set this here - -- (usually it isn't set until we return, look down there...) - package.loaded["net.server"] = server; - - -- Backwards compatibility for timers, addtimer - -- called a function roughly every second - local add_task = require "util.timer".add_task; - function server.addtimer(f) - return add_task(1, function (...) f(...); return 1; end); - end - + server = require "net.server_select"; + -- Overwrite signal.signal() because we need to ask libevent to -- handle them instead local ok, signal = pcall(require, "util.signal"); @@ -48,7 +37,6 @@ end else server = require "net.server_select"; - package.loaded["net.server"] = server; end -- require "net.server" shall now forever return this, diff -r 3068ec951ffd -r 3bf0100d7303 net/server_select.lua --- a/net/server_select.lua Thu May 03 15:38:12 2012 +0200 +++ b/net/server_select.lua Thu May 03 16:52:04 2012 +0100 @@ -75,7 +75,6 @@ local loop local stats local idfalse -local addtimer local closeall local addsocket local addserver @@ -921,6 +920,7 @@ ----------------------------------// PUBLIC INTERFACE //-- return { + _addtimer = addtimer, addclient = addclient, wrapclient = wrapclient, @@ -930,7 +930,6 @@ step = step, stats = stats, closeall = closeall, - addtimer = addtimer, addserver = addserver, getserver = getserver, setlogger = setlogger, diff -r 3068ec951ffd -r 3bf0100d7303 plugins/mod_admin_telnet.lua --- a/plugins/mod_admin_telnet.lua Thu May 03 15:38:12 2012 +0200 +++ b/plugins/mod_admin_telnet.lua Thu May 03 16:52:04 2012 +0100 @@ -17,7 +17,8 @@ local iterators = require "util.iterators"; local keys, values = iterators.keys, iterators.values; -local jid_bare = require "util.jid".bare; +local jid = require "util.jid"; +local jid_bare, jid_split = jid.bare, jid.split; local set, array = require "util.set", require "util.array"; local cert_verify_identity = require "util.x509".verify_identity; @@ -832,6 +833,29 @@ return true, "Closed "..n_closed.." ports"; end +def_env.muc = {}; + +local console_room_mt = { + __index = function (self, k) return self.room[k]; end; + __tostring = function (self) + return "MUC room <"..self.room.jid..">"; + end; +}; + +function def_env.muc:room(room_jid) + local room_name, host = jid_split(room_jid); + if not hosts[host] then + return nil, "No such host: "..host; + elseif not hosts[host].modules.muc then + return nil, "Host '"..host.."' is not a MUC service"; + end + local room_obj = hosts[host].modules.muc.rooms[room_jid]; + if not room_obj then + return nil, "No such room: "..room_jid; + end + return setmetatable({ room = room_obj }, console_room_mt); +end + ------------- function printbanner(session) diff -r 3068ec951ffd -r 3bf0100d7303 util/timer.lua --- a/util/timer.lua Thu May 03 15:38:12 2012 +0200 +++ b/util/timer.lua Thu May 03 16:52:04 2012 +0100 @@ -6,11 +6,7 @@ -- COPYING file in the source package for more information. -- - -local ns_addtimer = require "net.server".addtimer; -local event = require "net.server".event; -local event_base = require "net.server".event_base; - +local server = require "net.server"; local math_min = math.min local math_huge = math.huge local get_time = require "socket".gettime; @@ -24,7 +20,7 @@ module "timer" local _add_task; -if not event then +if not server.event then function _add_task(delay, callback) local current_time = get_time(); delay = delay + current_time; @@ -38,7 +34,7 @@ end end - ns_addtimer(function() + server._addtimer(function() local current_time = get_time(); if #new_data > 0 then for _, d in pairs(new_data) do @@ -64,7 +60,10 @@ return next_time; end); else + local event = require "net.server".event; + local event_base = require "net.server".event_base; local EVENT_LEAVE = (event.core and event.core.LEAVE) or -1; + function _add_task(delay, callback) local event_handle; event_handle = event_base:addevent(nil, 0, function ()