diff options
author | daurnimator <quae@daurnimator.com> | 2013-12-18 18:11:17 -0500 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2013-12-18 18:11:17 -0500 |
commit | 0d7c7060984b1677c81e2a38089fabe7ebb9f79e (patch) | |
tree | 65d1979df3d0b5b567ae4bbad0eab1829ca0e4a2 /net | |
parent | 9923fa6385950d2e9533870bba6fbb8eceb33ec3 (diff) | |
download | prosody-0d7c7060984b1677c81e2a38089fabe7ebb9f79e.tar.gz prosody-0d7c7060984b1677c81e2a38089fabe7ebb9f79e.zip |
net/server_event: pcall require ssl rather than relying on globals
Diffstat (limited to 'net')
-rw-r--r-- | net/server_event.lua | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/net/server_event.lua b/net/server_event.lua index 00c99784..7575044a 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -716,25 +716,17 @@ do end local addserver = ( function( ) - return function( addr, port, listener, pattern, sslcfg, startssl ) -- TODO: check arguments - --vdebug( "creating new tcp server with following parameters:", addr or "nil", port or "nil", sslcfg or "nil", startssl or "nil") + return function( addr, port, listener, pattern, sslctx, startssl ) -- TODO: check arguments + --vdebug( "creating new tcp server with following parameters:", addr or "nil", port or "nil", sslctx or "nil", startssl or "nil") + if sslctx and not has_luasec then + debug "fatal error: luasec not found" + return nil, "luasec not found" + end local server, err = socket.bind( addr, port, cfg.ACCEPT_QUEUE ) -- create server socket if not server then debug( "creating server socket on "..addr.." port "..port.." failed:", err ) return nil, err end - local sslctx - if sslcfg then - if not has_luasec then - debug "fatal error: luasec not found" - return nil, "luasec not found" - end - sslctx, err = sslcfg - if err then - debug( "error while creating new ssl context for server socket:", err ) - return nil, err - end - end local interface = handleserver( server, addr, port, pattern, listener, sslctx, startssl ) -- new server handler debug( "new server created with id:", tostring(interface)) return interface @@ -751,7 +743,7 @@ do end function addclient( addr, serverport, listener, pattern, sslctx ) - if sslctx and not ssl then + if sslctx and not has_luasec then debug "need luasec, but not available" return nil, "luasec not found" end |