diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-11 12:02:30 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-11 12:02:30 +0100 |
commit | 51a37928e9cb4be0984a0e3580a79bc2dec0891e (patch) | |
tree | 983c781114f98d31aa460b92ef74353f32cdb2fb | |
parent | d5ecc4135fe8a7a8cc578740095ad6d94bbccf2b (diff) | |
download | rspamd-51a37928e9cb4be0984a0e3580a79bc2dec0891e.tar.gz rspamd-51a37928e9cb4be0984a0e3580a79bc2dec0891e.zip |
[Minor] Lua_upstream: Add get_name method
-rw-r--r-- | src/lua/lua_upstream.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lua/lua_upstream.c b/src/lua/lua_upstream.c index c259c22db..322b242f8 100644 --- a/src/lua/lua_upstream.c +++ b/src/lua/lua_upstream.c @@ -78,12 +78,14 @@ static const struct luaL_reg upstream_list_f[] = { LUA_FUNCTION_DEF (upstream, ok); LUA_FUNCTION_DEF (upstream, fail); LUA_FUNCTION_DEF (upstream, get_addr); +LUA_FUNCTION_DEF (upstream, get_name); LUA_FUNCTION_DEF (upstream, destroy); static const struct luaL_reg upstream_m[] = { LUA_INTERFACE_DEF (upstream, ok), LUA_INTERFACE_DEF (upstream, fail), LUA_INTERFACE_DEF (upstream, get_addr), + LUA_INTERFACE_DEF (upstream, get_name), {"__tostring", rspamd_lua_class_tostring}, {"__gc", lua_upstream_destroy}, {NULL, NULL} @@ -127,6 +129,27 @@ lua_upstream_get_addr (lua_State *L) } /*** + * @method upstream:get_name() + * Get name of upstream + * @return {string} name of the upstream + */ +static gint +lua_upstream_get_name (lua_State *L) +{ + LUA_TRACE_POINT; + struct rspamd_lua_upstream *up = lua_check_upstream (L); + + if (up) { + lua_pushstring (L, rspamd_upstream_name (up->up)); + } + else { + lua_pushnil (L); + } + + return 1; +} + +/*** * @method upstream:fail() * Indicate upstream failure. After certain amount of failures during specified time frame, an upstream is marked as down and does not participate in rotations. */ |