Merge with trunk
[prosody.git] / net / connlisteners.lua
index ebb3cc18e2cec986ccfd888deacc83e777c35f36..a9b92a8c81a47a2ce1957a8fbe7267f00aee55d9 100644 (file)
@@ -11,6 +11,7 @@
 local listeners_dir = (CFG_SOURCEDIR or ".").."/net/";
 local server = require "net.server";
 local log = require "util.logger".init("connlisteners");
+local tostring = tostring;
 
 local dofile, pcall, error = 
        dofile, pcall, error
@@ -37,7 +38,10 @@ function get(name)
        local h = listeners[name];
        if not h then
                local ok, ret = pcall(dofile, listeners_dir..name:gsub("[^%w%-]", "_").."_listener.lua");
-               if not ok then return nil, ret; end
+               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;
@@ -57,9 +61,14 @@ function start(name, udata)
                end
        end
        
-       return server.addserver(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 h.default_interface or "*", (udata and udata.mode) or h.default_mode or 1, (udata and udata.ssl) or nil, 99999999, udata and udata.type == "ssl");
+       local interface = (udata and udata.interface) or h.default_interface or "*";
+       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 maxclients = 99999999;
+       local autossl = udata and udata.type == "ssl";
+       
+       return server.addserver(interface, port, h, mode, ssl, autossl);
 end
 
 return _M;