aboutsummaryrefslogtreecommitdiffstats
path: root/net/connlisteners.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-04-29 02:10:55 +0100
committerMatthew Wild <mwild1@gmail.com>2012-04-29 02:10:55 +0100
commitbd5f9b8cbfd168a21141607218446222ab9d8642 (patch)
treee78baabff21e9b6fefaeef4a709098ca30b35922 /net/connlisteners.lua
parent9b89441dd008a8b3fda12d9217ff6f9ba240df9a (diff)
parenta2055895d362fed58ff314820bb7fddd53e40436 (diff)
downloadprosody-bd5f9b8cbfd168a21141607218446222ab9d8642.tar.gz
prosody-bd5f9b8cbfd168a21141607218446222ab9d8642.zip
Merge 0.9->trunk
Diffstat (limited to 'net/connlisteners.lua')
-rw-r--r--net/connlisteners.lua84
1 files changed, 9 insertions, 75 deletions
diff --git a/net/connlisteners.lua b/net/connlisteners.lua
index 6a227c9d..99ddc720 100644
--- a/net/connlisteners.lua
+++ b/net/connlisteners.lua
@@ -1,81 +1,15 @@
--- Prosody IM
--- Copyright (C) 2008-2010 Matthew Wild
--- Copyright (C) 2008-2010 Waqas Hussain
---
--- This project is MIT/X11 licensed. Please see the
--- COPYING file in the source package for more information.
---
+-- 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 = require "net.server";
-local log = require "util.logger".init("connlisteners");
-local tostring = tostring;
-local type = type
-local ipairs = ipairs
-
-local dofile, xpcall, error =
- dofile, xpcall, error
-
-local debug_traceback = debug.traceback;
-
-module "connlisteners"
-
-local listeners = {};
-
-function register(name, listener)
- if listeners[name] and listeners[name] ~= listener then
- log("debug", "Listener %s is already registered, not registering any more", name);
- return false;
- end
- listeners[name] = listener;
- log("debug", "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
- local ok, ret = xpcall(function() dofile(listeners_dir..name:gsub("[^%w%-]", "_").."_listener.lua") end, debug_traceback);
- if not ok then
- log("error", "Error while loading listener '%s': %s", tostring(name), tostring(ret));
- return nil, ret;
- end
- h = listeners[name];
- end
- return h;
-end
-
-function start(name, udata)
- local h, err = get(name);
- if not h then
- error("No such connection module: "..name.. (err and (" ("..err..")") or ""), 0);
- end
-
- local interfaces = (udata and udata.interface) or h.default_interface or "*";
- if type(interfaces) == "string" then interfaces = {interfaces}; end
- local port = (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);
- local mode = (udata and udata.mode) or h.default_mode or 1;
- local ssl = (udata and udata.ssl) or nil;
- local autossl = udata and udata.type == "ssl";
-
- if autossl and not ssl then
- return nil, "no ssl context";
- end
-
- ok, err = true, {};
- for _, interface in ipairs(interfaces) do
- local handler
- handler, err[interface] = server.addserver(interface, port, h, mode, autossl and ssl or nil);
- ok = ok and handler;
- end
-
- return ok, err;
-end
+register, deregister = fail, fail;
+get, start = fail, fail, epic_fail;
return _M;