diff options
author | Florian Zeitz <florob@babelmonkeys.de> | 2011-06-15 23:44:18 +0200 |
---|---|---|
committer | Florian Zeitz <florob@babelmonkeys.de> | 2011-06-15 23:44:18 +0200 |
commit | 6d5ef2f7f9dafa7cd299c39a0e9f2873cb6f1289 (patch) | |
tree | 168d7a8a71a152a4af33e06ac678b8df2ba6b947 /net/connlisteners.lua | |
parent | e61a11d634322573b025a64991e7d141c95f1f73 (diff) | |
download | prosody-6d5ef2f7f9dafa7cd299c39a0e9f2873cb6f1289.tar.gz prosody-6d5ef2f7f9dafa7cd299c39a0e9f2873cb6f1289.zip |
connlistener, server_select, prosody: Add support for binding to multiple addresses
Diffstat (limited to 'net/connlisteners.lua')
-rw-r--r-- | net/connlisteners.lua | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/net/connlisteners.lua b/net/connlisteners.lua index 7da25c62..6a227c9d 100644 --- a/net/connlisteners.lua +++ b/net/connlisteners.lua @@ -12,6 +12,8 @@ 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 @@ -55,7 +57,8 @@ function start(name, udata) error("No such connection module: "..name.. (err and (" ("..err..")") or ""), 0); end - local interface = (udata and udata.interface) or h.default_interface or "*"; + 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; @@ -64,8 +67,15 @@ function start(name, udata) if autossl and not ssl then return nil, "no ssl context"; end - - return server.addserver(interface, port, h, mode, autossl and ssl or nil); + + 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 return _M; |