lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Why not throw an error? (e.g. luaL_error(L, "libtls version too old, version = 0x%x", version);)

A regular return will register the module in the module table, for every value possible it seems. The error handling will bypass that.



On Tue, Aug 7, 2018 at 3:28 AM Frank Kastenholz <fkastenholz@verizon.net> wrote:

Simply return nil?

Have the module return a table, just like it would if it worked, but populate the table with dummy functions that all return/throw a “module not properly loaded” error?

Put a status variable in the modules table that indicates it didn’t load properly and the additional reason information?




> On Aug 6, 2018, at 10:32 PM, Sean Conner <sean@conman.org> wrote:
>
>
>  I'm working on two modules, both related to libtls [1].  The first one is
> just a C wrapper around libtls (which is done for the most part), and I
> thought it would be nice to support as many versions as possible.
>
>  The second module is a Lua module (or rather, a collection of modules)
> that handle TLS (or TCP) connections via coroutines---each connection is
> wrapped up in a coroutine and there's a main event loop that schedules
> everything.  This one too, is mostly done.
>
>  Enough of the background, now the problem.  The Lua module will only work
> with libtls 2.5.0 (the earliest version that supports user-controlled
> sockets).  It's not enough that, say, org.conman.tls exists, but unless it
> was compiled against libtls 2.5.0 (or higher), it won't work.  I'm looking
> for something like:
>
>    -----[ my-tls.lua / loaded as a module ]----
>
>    local tls = require "org.conman.tls"
>
>    if tls.LIBRESSL_VERSION < 0x2050000f then
>      ??? there's no point in continuing with loading
>      ??? this module, because libtls will not let us
>      ??? control the socket.
>    end
>
>  How to I abort the module?  There's nothing I can find in the
> documentation to deal with this, unless I'm missing something.
>
>  -spc
>
> [1]    I started this with the latest version and got it working.  Now I'm
>    working backwards, supporting earlier verions of the library.
>




--
--