Software /
code /
prosody
Changeset
5956:59997f3f5502
net/server_select: pcall require ssl (easy to forget to require ssl)
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Wed, 18 Dec 2013 17:50:38 -0500 |
parents | 5955:b3d5aa57c454 |
children | 5957:3c5061d937dd |
files | net/server_select.lua |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/net/server_select.lua Wed Dec 18 18:37:38 2013 +0100 +++ b/net/server_select.lua Wed Dec 18 17:50:38 2013 -0500 @@ -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 @@ -585,7 +585,7 @@ 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 @@ _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 @@ 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