aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_select.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
commit6d5ef2f7f9dafa7cd299c39a0e9f2873cb6f1289 (patch)
tree168d7a8a71a152a4af33e06ac678b8df2ba6b947 /net/server_select.lua
parente61a11d634322573b025a64991e7d141c95f1f73 (diff)
downloadprosody-6d5ef2f7f9dafa7cd299c39a0e9f2873cb6f1289.tar.gz
prosody-6d5ef2f7f9dafa7cd299c39a0e9f2873cb6f1289.zip
connlistener, server_select, prosody: Add support for binding to multiple addresses
Diffstat (limited to 'net/server_select.lua')
-rw-r--r--net/server_select.lua24
1 files changed, 12 insertions, 12 deletions
diff --git a/net/server_select.lua b/net/server_select.lua
index 13a910f8..4a22d2ed 100644
--- a/net/server_select.lua
+++ b/net/server_select.lua
@@ -701,19 +701,19 @@ addserver = function( addr, port, listeners, pattern, sslctx ) -- this function
end
if type( port ) ~= "number" or not ( port >= 0 and port <= 65535 ) then
err = "invalid port"
- elseif _server[ port ] then
- err = "listeners on port '" .. port .. "' already exist"
+ elseif _server[ addr..":"..port ] then
+ err = "listeners on '[" .. addr .. "]:" .. port .. "' already exist"
elseif sslctx and not luasec then
err = "luasec not found"
end
if err then
- out_error( "server.lua, port ", port, ": ", err )
+ out_error( "server.lua, [", addr, "]:", port, ": ", err )
return nil, err
end
addr = addr or "*"
local server, err = socket_bind( addr, port )
if err then
- out_error( "server.lua, port ", port, ": ", err )
+ out_error( "server.lua, [", addr, "]:", port, ": ", err )
return nil, err
end
local handler, err = wrapserver( listeners, server, addr, port, pattern, sslctx, _maxclientsperserver ) -- wrap new server socket
@@ -723,23 +723,23 @@ addserver = function( addr, port, listeners, pattern, sslctx ) -- this function
end
server:settimeout( 0 )
_readlistlen = addsocket(_readlist, server, _readlistlen)
- _server[ port ] = handler
+ _server[ addr..":"..port ] = handler
_socketlist[ server ] = handler
- out_put( "server.lua: new "..(sslctx and "ssl " or "").."server listener on '", addr, ":", port, "'" )
+ out_put( "server.lua: new "..(sslctx and "ssl " or "").."server listener on '[", addr, "]:", port, "'" )
return handler
end
-getserver = function ( port )
- return _server[ port ];
+getserver = function ( addr, port )
+ return _server[ addr..":"..port ];
end
-removeserver = function( port )
- local handler = _server[ port ]
+removeserver = function( addr, port )
+ local handler = _server[ addr..":"..port ]
if not handler then
- return nil, "no server found on port '" .. tostring( port ) .. "'"
+ return nil, "no server found on '[" .. addr .. "]:" .. tostring( port ) .. "'"
end
handler:close( )
- _server[ port ] = nil
+ _server[ addr..":"..port ] = nil
return true
end