aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_select.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-02-23 12:04:43 +0100
committerKim Alvefur <zash@zash.se>2015-02-23 12:04:43 +0100
commit7105732151705b081800987a0f319849abb85b92 (patch)
treef91a687924f1c22452367c15b375053f2aecb809 /net/server_select.lua
parent3573e516c2c12d907bed1ee25d8bacf57ee04f71 (diff)
downloadprosody-7105732151705b081800987a0f319849abb85b92.tar.gz
prosody-7105732151705b081800987a0f319849abb85b92.zip
net.server_{select,event}: Don't rely on LuaSocket and LuaSec being present in the globals table
Diffstat (limited to 'net/server_select.lua')
-rw-r--r--net/server_select.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/server_select.lua b/net/server_select.lua
index 486e953b..322c0b57 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
@@ -594,7 +594,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);
@@ -647,7 +647,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);
@@ -731,7 +731,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