Skip to content

Commit

Permalink
Small style changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
moteus committed Sep 25, 2014
1 parent 6308dd0 commit 56668d5
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions lua/sendmail.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- sendmail.lua v0.1.3-dev (2014-08)
-- sendmail.lua v0.1.3-dev (2014-09)

-- Copyright (c) 2013-2014 Alexey Melnichuk
--
Expand Down Expand Up @@ -280,12 +280,9 @@ local function find_ca_by_fs(name)
for _, p in ipairs(split(env.path, ';', true)) do paths[#paths + 1] = p end

for _, p in ipairs(paths) do
p = path.fullpath(p)
if path.isdir(p) then
p = path.join(p, name)
if path.isfile(p) then
return p
end
p = path.join(path.fullpath(p), name)
if path.isfile(p) then
return p
end
end
end
Expand All @@ -310,7 +307,7 @@ luasec_create = function(params)
params.mode = params.mode or "client"
params.protocol = params.protocol or "tlsv1"
params.verify = params.verify or {"peer", "fail_if_no_peer_cert"}
params.options = params.options or {"all"}
params.options = params.options or "all"

assert(params.mode == "client")

Expand All @@ -319,13 +316,15 @@ luasec_create = function(params)
if params.cafile then
params.cafile = find_ca_by_fs(params.cafile) or params.cafile
end
break end
break
end

local cafile, capath = find_ca_by_env()
if cafile or capath then
params.cafile, params.capath = cafile, capath
break
end

params.cafile = find_ca_by_fs()
until true end

Expand All @@ -334,18 +333,20 @@ luasec_create = function(params)
local sock = socket.tcp()

return setmetatable({
connect = function(_, host, port)
local r, e = sock:connect(host, port)
if not r then return r, e end
sock = ssl.wrap(sock, params)
return sock:dohandshake()
end
connect = function(_, host, port)
local r, e = sock:connect(host, port)
if not r then return r, e end
sock = ssl.wrap(sock, params)
return sock:dohandshake()
end
}, {
__index = function(t,n)
return function(_, ...)
return sock[n](sock, ...)
end
__index = function(t,n)
local fn = function(_, ...)
return sock[n](sock, ...)
end
t[n] = fn
return fn
end
})
end
end
Expand Down

0 comments on commit 56668d5

Please sign in to comment.