From b34f9c0fd6a815f498c03717384ba8dd543e75f7 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 9 Aug 2015 00:47:35 +1000 Subject: Allow passing openssl.ssl.context:setCipherList a vararg of ciphers, or an array --- src/openssl.ssl.context.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/openssl.ssl.context.lua b/src/openssl.ssl.context.lua index 44a9163..2da84de 100644 --- a/src/openssl.ssl.context.lua +++ b/src/openssl.ssl.context.lua @@ -1,3 +1,16 @@ local ctx = require"_openssl.ssl.context" +local pack = table.pack or function(...) return { n = select("#", ...); ... } end + +-- Allow passing a vararg of ciphers, or an array +local setCipherList; setCipherList = ctx.interpose("setCipherList", function (self, ciphers, ...) + if (...) then + local ciphers_t = pack(...) + ciphers = table.concat(ciphers_t, ":", 1, ciphers_t.n) + elseif type(ciphers) == "table" then + ciphers = table.concat(ciphers, ":") + end + return setCipherList(self, ciphers) +end) + return ctx -- cgit v1.2.3-59-g8ed1b