diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-19 13:46:28 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-19 13:46:28 +0000 |
commit | c87580806c6e941fe34be0751f928325271ee7eb (patch) | |
tree | ab0bc97142c7f3159cf2fdae01662028a8f74414 /src | |
parent | 4a2376ca9feaadff2f91f3e39ee65a864e2ddc74 (diff) | |
download | rspamd-c87580806c6e941fe34be0751f928325271ee7eb.tar.gz rspamd-c87580806c6e941fe34be0751f928325271ee7eb.zip |
Add get_version for lua IP module.
Diffstat (limited to 'src')
-rw-r--r-- | src/lua/lua_ip.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lua/lua_ip.c b/src/lua/lua_ip.c index 1297f0403..a040901b8 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) { |