]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: lua: Add proxy as member of proxy object.
authorThierry FOURNIER <thierry.fournier@ozon.io>
Mon, 24 Jul 2017 11:59:22 +0000 (13:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 25 Jul 2017 16:18:40 +0000 (18:18 +0200)
By Adis Nezirovic:

   This is just for convenience and uniformity, Proxy.servers/listeners
   returns a table/hash of objects with names as keys, but for example when
   I want to pass such object to some other Lua function I have to manually
   copy the name (or wrap the object), since the object itself doesn't
   expose name info.

This patch simply adds the proxy name as member of the proxy object.

src/hlua_fcn.c

index d44f2bd4fc540b1a864a213a09b418ee23f5b6ae..a176b34bd7535428181b4d03ec3e76092c5c5b39 100644 (file)
@@ -776,6 +776,11 @@ int hlua_fcn_new_proxy(lua_State *L, struct proxy *px)
        lua_pushlightuserdata(L, px);
        lua_rawseti(L, -2, 0);
 
+       /* Add proxy name. */
+       lua_pushstring(L, "name");
+       lua_pushstring(L, px->id);
+       lua_settable(L, -3);
+
        /* Browse and register servers. */
        lua_pushstring(L, "servers");
        lua_newtable(L);