Software /
code /
prosody
Diff
net/server_select.lua @ 6782:ec172dbe9d14
net.server_{select,event}: Don't rely on LuaSocket and LuaSec being present in the globals table
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 23 Feb 2015 12:04:43 +0100 |
parent | 6459:ba421af3dfd3 |
child | 6791:e813e8cf6046 |
child | 6812:7af63377a1cf |
line wrap: on
line diff
--- a/net/server_select.lua Sun Feb 22 19:06:26 2015 +0100 +++ b/net/server_select.lua Mon Feb 23 12:04:43 2015 +0100 @@ -48,13 +48,13 @@ --// 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 @@ 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 @@ _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 @@ 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