Lua API: Add function: ssl_init
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>main
parent
64d3036347
commit
f03acc8b5c
|
@ -30,6 +30,8 @@ print("uhttpd version:", uh.VERSION)
|
|||
|
||||
local srv = uh.new(port)
|
||||
|
||||
-- srv:ssl_init("uhttpd.crt", "uhttpd.key")
|
||||
|
||||
print("Listen on:", port)
|
||||
|
||||
srv:add_action("/lua", function(cl, opt)
|
||||
|
|
|
@ -118,6 +118,17 @@ static void lua_uh_action(struct uh_client *cl)
|
|||
lua_call(L, 2, 0);
|
||||
}
|
||||
|
||||
static int lua_uh_ssl_init(lua_State *L)
|
||||
{
|
||||
struct lua_uh_server *lsrv = lua_touserdata(L, 1);
|
||||
const char *cert = lua_tostring(L, 2);
|
||||
const char *key = lua_tostring(L, 3);
|
||||
|
||||
lsrv->srv->ssl_init(lsrv->srv, key, cert);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lua_uh_add_action(lua_State *L)
|
||||
{
|
||||
struct lua_uh_server *lsrv = lua_touserdata(L, 1);
|
||||
|
@ -158,6 +169,7 @@ static int lua_uh_server_free(lua_State *L)
|
|||
}
|
||||
|
||||
static const luaL_Reg server_mt[] = {
|
||||
{ "ssl_init", lua_uh_ssl_init },
|
||||
{ "add_action", lua_uh_add_action },
|
||||
{ "free", lua_uh_server_free },
|
||||
{ NULL, NULL }
|
||||
|
|
Loading…
Reference in New Issue