diff options
author | daurnimator <quae@daurnimator.com> | 2013-12-18 17:50:38 -0500 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2013-12-18 17:50:38 -0500 |
commit | a3c709b756f0789a33a1bc3703504b29981d2623 (patch) | |
tree | c3fbddcd93032dccb2fa8cfc89f078d2dfc37838 /net/server_select.lua | |
parent | 87ce8469aff9d28dcd58e8cc70445aa6ead376a7 (diff) | |
download | prosody-a3c709b756f0789a33a1bc3703504b29981d2623.tar.gz prosody-a3c709b756f0789a33a1bc3703504b29981d2623.zip |
net/server_select: pcall require ssl (easy to forget to require ssl)
Diffstat (limited to 'net/server_select.lua')
-rw-r--r-- | net/server_select.lua | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/net/server_select.lua b/net/server_select.lua index c5e0772f..61078202 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -48,13 +48,13 @@ local coroutine_yield = coroutine.yield --// extern libs //-- -local luasec = use "ssl" +local has_luasec, luasec = pcall ( require , "ssl" ) local luasocket = use "socket" or require "socket" local luasocket_gettime = luasocket.gettime --// extern lib methods //-- -local ssl_wrap = ( luasec and luasec.wrap ) +local ssl_wrap = ( has_luasec and luasec.wrap ) local socket_bind = luasocket.bind local socket_sleep = luasocket.sleep local socket_select = luasocket.select @@ -585,7 +585,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport end ) end - if luasec then + if has_luasec then handler.starttls = function( self, _sslctx) if _sslctx then handler:set_sslctx(_sslctx); @@ -638,7 +638,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport _socketlist[ socket ] = handler _readlistlen = addsocket(_readlist, socket, _readlistlen) - if sslctx and luasec then + if sslctx and has_luasec then out_put "server.lua: auto-starting ssl negotiation..." handler.autostart_ssl = true; local ok, err = handler:starttls(sslctx); @@ -721,7 +721,7 @@ addserver = function( addr, port, listeners, pattern, sslctx ) -- this function err = "invalid port" elseif _server[ addr..":"..port ] then err = "listeners on '[" .. addr .. "]:" .. port .. "' already exist" - elseif sslctx and not luasec then + elseif sslctx and not has_luasec then err = "luasec not found" end if err then |