From: Vladimír Čunát Date: Tue, 5 Dec 2017 17:02:57 +0000 (+0100) Subject: print_tls_client_params: print all address#port pairs X-Git-Tag: v2.0.0~43^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c835731d97bf74b6ed93401ac901764aafcb2b4;p=thirdparty%2Fknot-resolver.git print_tls_client_params: print all address#port pairs nitpick: pre-allocate table sizes --- diff --git a/daemon/bindings.c b/daemon/bindings.c index 88b4e74e1..6875fa9fe 100644 --- a/daemon/bindings.c +++ b/daemon/bindings.c @@ -408,30 +408,32 @@ static int print_tls_param(const char *key, void *val, void *data) lua_State *L = (lua_State *)data; - lua_newtable(L); - lua_newtable(L); + lua_createtable(L, 0, 3); - lua_newtable(L); + lua_createtable(L, entry->pins.len, 0); for (size_t i = 0; i < entry->pins.len; ++i) { lua_pushnumber(L, i + 1); lua_pushstring(L, entry->pins.at[i]); lua_settable(L, -3); } lua_setfield(L, -2, "pins"); - lua_newtable(L); + + lua_createtable(L, entry->ca_files.len, 0); for (size_t i = 0; i < entry->ca_files.len; ++i) { lua_pushnumber(L, i + 1); lua_pushstring(L, entry->ca_files.at[i]); lua_settable(L, -3); } - lua_setfield(L, -2, "ca files"); - lua_newtable(L); + lua_setfield(L, -2, "ca_files"); + + lua_createtable(L, entry->hostnames.len, 0); for (size_t i = 0; i < entry->hostnames.len; ++i) { lua_pushnumber(L, i + 1); lua_pushstring(L, entry->hostnames.at[i]); lua_settable(L, -3); } lua_setfield(L, -2, "hostnames"); + lua_setfield(L, -2, key); return 0; @@ -450,6 +452,7 @@ static int print_tls_client_params(lua_State *L) if (net->tls_client_params.root == 0 ) { return 0; } + lua_newtable(L); map_walk(&net->tls_client_params, print_tls_param, (void *)L); return 1; }