X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=net%2Fconnlisteners.lua;h=99ddc720aa570fb02765191ca6b1c47eaddaaee0;hb=f50f4cb01c079cfa913a76313859e469abbda12e;hp=8c9b163f7a2d80cb205ff1648a7a41d26ec47a7d;hpb=8aba1c77f0714f2460cc21660bb494fc217e042b;p=prosody.git diff --git a/net/connlisteners.lua b/net/connlisteners.lua index 8c9b163f..99ddc720 100644 --- a/net/connlisteners.lua +++ b/net/connlisteners.lua @@ -1,66 +1,15 @@ --- Prosody IM v0.2 --- Copyright (C) 2008 Matthew Wild --- Copyright (C) 2008 Waqas Hussain --- --- This program is free software; you can redistribute it and/or --- modify it under the terms of the GNU General Public License --- as published by the Free Software Foundation; either version 2 --- of the License, or (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- +-- COMPAT w/pre-0.9 +local log = require "util.logger".init("net.connlisteners"); +local traceback = debug.traceback; +module "httpserver" - -local listeners_dir = (CFG_SOURCEDIR or ".").."/net/"; -local server_add = require "net.server".add; -local log = require "util.logger".init("connlisteners"); - -local dofile, pcall, error = - dofile, pcall, error - -module "connlisteners" - -local listeners = {}; - -function register(name, listener) - if listeners[name] and listeners[name] ~= listener then - log("warning", "Listener %s is already registered, not registering any more", name); - return false; - end - listeners[name] = listener; - log("info", "Registered connection listener %s", name); - return true; +function fail() + log("error", "Attempt to use legacy connlisteners API. For more info see http://prosody.im/doc/developers/network"); + log("error", "Legacy connlisteners API usage, %s", traceback("", 2)); end -function deregister(name) - listeners[name] = nil; -end - -function get(name) - local h = listeners[name]; - if not h then - pcall(dofile, listeners_dir..name:gsub("[^%w%-]", "_").."_listener.lua"); - h = listeners[name]; - end - return h; -end - -function start(name, udata) - local h = get(name); - if not h then - error("No such connection module: "..name, 0); - end - return server_add(h, - (udata and udata.port) or h.default_port or error("Can't start listener "..name.." because no port was specified, and it has no default port", 0), - (udata and udata.interface) or "*", (udata and udata.mode) or h.default_mode or 1, (udata and udata.ssl) or nil ); -end +register, deregister = fail, fail; +get, start = fail, fail, epic_fail; return _M;