aboutsummaryrefslogtreecommitdiffstats
path: root/net/connlisteners.lua
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2011-06-15 23:44:18 +0200
committerFlorian Zeitz <florob@babelmonkeys.de>2011-06-15 23:44:18 +0200
commit5855fda78ff9dfc3dea65420474bd88bbd428b30 (patch)
tree168d7a8a71a152a4af33e06ac678b8df2ba6b947 /net/connlisteners.lua
parentb244387ef5d355ed050a7e1cefc1ba9737501d0e (diff)
downloadprosody-5855fda78ff9dfc3dea65420474bd88bbd428b30.tar.gz
prosody-5855fda78ff9dfc3dea65420474bd88bbd428b30.zip
connlistener, server_select, prosody: Add support for binding to multiple addresses
Diffstat (limited to 'net/connlisteners.lua')
-rw-r--r--net/connlisteners.lua16
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;