X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=net%2Fconnlisteners.lua;h=a9b92a8c81a47a2ce1957a8fbe7267f00aee55d9;hb=4e9ad86f42f78e32d5a983b62277a0552c853a9c;hp=7aaee4c06f49d27d0a41fe5120e3ddd69808a871;hpb=4c97a5c415d081ff9b68df1bfdee350464b46e44;p=prosody.git diff --git a/net/connlisteners.lua b/net/connlisteners.lua index 7aaee4c0..a9b92a8c 100644 --- a/net/connlisteners.lua +++ b/net/connlisteners.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.4 +-- Prosody IM -- Copyright (C) 2008-2009 Matthew Wild -- Copyright (C) 2008-2009 Waqas Hussain -- @@ -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;