Software /
code /
prosody
Diff
net/server_select.lua @ 5957:3c5061d937dd
net/server_select: Check arguments to add_server correctly
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Wed, 18 Dec 2013 17:51:27 -0500 |
parent | 5956:59997f3f5502 |
child | 5959:9e3b15199ec5 |
line wrap: on
line diff
--- a/net/server_select.lua Wed Dec 18 17:50:38 2013 -0500 +++ b/net/server_select.lua Wed Dec 18 17:51:27 2013 -0500 @@ -713,11 +713,13 @@ ----------------------------------// PUBLIC //-- addserver = function( addr, port, listeners, pattern, sslctx ) -- this function provides a way for other scripts to reg a server + addr = addr or "*" local err if type( listeners ) ~= "table" then err = "invalid listener table" - end - if type( port ) ~= "number" or not ( port >= 0 and port <= 65535 ) then + elseif type ( addr ) ~= "string" then + err = "invalid address" + elseif type( port ) ~= "number" or not ( port >= 0 and port <= 65535 ) then err = "invalid port" elseif _server[ addr..":"..port ] then err = "listeners on '[" .. addr .. "]:" .. port .. "' already exist" @@ -728,7 +730,6 @@ out_error( "server.lua, [", addr, "]:", port, ": ", err ) return nil, err end - addr = addr or "*" local server, err = socket_bind( addr, port, _tcpbacklog ) if err then out_error( "server.lua, [", addr, "]:", port, ": ", err )