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 | 5855fda78ff9dfc3dea65420474bd88bbd428b30 (patch) | |
tree | 168d7a8a71a152a4af33e06ac678b8df2ba6b947 /net/server_select.lua | |
parent | b244387ef5d355ed050a7e1cefc1ba9737501d0e (diff) | |
download | prosody-5855fda78ff9dfc3dea65420474bd88bbd428b30.tar.gz prosody-5855fda78ff9dfc3dea65420474bd88bbd428b30.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.lua | 24 |
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 |