mirror of
https://github.com/brunoos/luasec.git
synced 2024-12-27 04:58:20 +01:00
Expose all options as a set
This commit is contained in:
parent
903efaf3b1
commit
ab6e984b40
19
src/ssl.c
19
src/ssl.c
@ -30,6 +30,7 @@
|
||||
#include "x509.h"
|
||||
#include "context.h"
|
||||
#include "ssl.h"
|
||||
#include "options.h"
|
||||
|
||||
/**
|
||||
* Underline socket error.
|
||||
@ -782,6 +783,8 @@ static luaL_Reg funcs[] = {
|
||||
#if (LUA_VERSION_NUM == 501)
|
||||
LSEC_API int luaopen_ssl_core(lua_State *L)
|
||||
{
|
||||
ssl_option_t *p;
|
||||
|
||||
/* Initialize SSL */
|
||||
if (!SSL_library_init()) {
|
||||
lua_pushstring(L, "unable to initialize SSL library");
|
||||
@ -809,11 +812,20 @@ LSEC_API int luaopen_ssl_core(lua_State *L)
|
||||
lua_pushnumber(L, SOCKET_INVALID);
|
||||
lua_setfield(L, -2, "invalidfd");
|
||||
|
||||
lua_newtable(L);
|
||||
for (p = ssl_options; p->name; p++) {
|
||||
lua_pushboolean(L, 1);
|
||||
lua_setfield(L, -2, p->name);
|
||||
}
|
||||
lua_setfield(L, -2, "options");
|
||||
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
LSEC_API int luaopen_ssl_core(lua_State *L)
|
||||
{
|
||||
ssl_option_t *p;
|
||||
|
||||
/* Initialize SSL */
|
||||
if (!SSL_library_init()) {
|
||||
lua_pushstring(L, "unable to initialize SSL library");
|
||||
@ -842,6 +854,13 @@ LSEC_API int luaopen_ssl_core(lua_State *L)
|
||||
lua_pushnumber(L, SOCKET_INVALID);
|
||||
lua_setfield(L, -2, "invalidfd");
|
||||
|
||||
lua_newtable(L);
|
||||
for (p = ssl_options; p->name; p++) {
|
||||
lua_pushboolean(L, 1);
|
||||
lua_setfield(L, -2, p->name);
|
||||
}
|
||||
lua_setfield(L, -2, "options");
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user