# HG changeset patch # User daurnimator # Date 1387407038 18000 # Node ID 59997f3f55024a4b3cb62d2fab8c4b6d6e39441f # Parent b3d5aa57c454d2d8d0c44944f14f3c2a1cd083c1 net/server_select: pcall require ssl (easy to forget to require ssl) diff -r b3d5aa57c454 -r 59997f3f5502 net/server_select.lua --- 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