From: Vsevolod Stakhov Date: Tue, 19 Nov 2013 13:46:28 +0000 (+0000) Subject: Add get_version for lua IP module. X-Git-Tag: 0.6.0~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c87580806c6e941fe34be0751f928325271ee7eb;p=thirdparty%2Frspamd.git Add get_version for lua IP module. --- diff --git a/src/lua/lua_ip.c b/src/lua/lua_ip.c index 1297f0403a..a040901b84 100644 --- a/src/lua/lua_ip.c +++ b/src/lua/lua_ip.c @@ -29,12 +29,14 @@ LUA_FUNCTION_DEF (ip, str_octets); LUA_FUNCTION_DEF (ip, inversed_str_octets); LUA_FUNCTION_DEF (ip, from_string); LUA_FUNCTION_DEF (ip, destroy); +LUA_FUNCTION_DEF (ip, get_version); static const struct luaL_reg iplib_m[] = { LUA_INTERFACE_DEF (ip, to_string), LUA_INTERFACE_DEF (ip, to_table), LUA_INTERFACE_DEF (ip, str_octets), LUA_INTERFACE_DEF (ip, inversed_str_octets), + LUA_INTERFACE_DEF (ip, get_version), {"__tostring", lua_ip_to_string}, {"__gc", lua_ip_destroy}, {NULL, NULL} @@ -222,6 +224,21 @@ lua_ip_destroy (lua_State *L) return 0; } +static gint +lua_ip_get_version (lua_State *L) +{ + struct rspamd_lua_ip *ip = lua_check_ip (L, 1); + + if (ip) { + lua_pushnumber (L, ip->af == AF_INET6 ? 6 : 4); + } + else { + lua_pushnil (L); + } + + return 1; +} + void lua_ip_push (lua_State *L, int af, gpointer data) {