diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-06-06 13:52:58 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-06-06 13:52:58 +0100 |
commit | 4f42cf904b7410714a3c12855619aea9749346b2 (patch) | |
tree | 3d660e716b88ce418b6fa16a8621ee1614a3e6c5 | |
parent | c11f9e68e6dc5891f9584a0a7e443153657b7737 (diff) | |
download | rspamd-4f42cf904b7410714a3c12855619aea9749346b2.tar.gz rspamd-4f42cf904b7410714a3c12855619aea9749346b2.zip |
[Minor] Add url:get_count method
-rw-r--r-- | src/lua/lua_url.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c index 8826bb41c..15966bfa3 100644 --- a/src/lua/lua_url.c +++ b/src/lua/lua_url.c @@ -56,6 +56,7 @@ LUA_FUNCTION_DEF (url, is_html_displayed); LUA_FUNCTION_DEF (url, is_subject); LUA_FUNCTION_DEF (url, get_phished); LUA_FUNCTION_DEF (url, get_tag); +LUA_FUNCTION_DEF (url, get_count); LUA_FUNCTION_DEF (url, get_tags); LUA_FUNCTION_DEF (url, add_tag); LUA_FUNCTION_DEF (url, create); @@ -82,6 +83,7 @@ static const struct luaL_reg urllib_m[] = { LUA_INTERFACE_DEF (url, get_tag), LUA_INTERFACE_DEF (url, get_tags), LUA_INTERFACE_DEF (url, add_tag), + LUA_INTERFACE_DEF (url, get_count), {"get_redirected", lua_url_get_phished}, {"__tostring", lua_url_get_text}, {NULL, NULL} @@ -529,6 +531,26 @@ lua_url_get_tld (lua_State *L) } /*** + * @method url:get_count() + * Return number of occurrencies for this particular URL + * @return {number} number of occurrencies + */ +static gint +lua_url_get_count (lua_State *L) +{ + struct rspamd_lua_url *url = lua_check_url (L, 1); + + if (url != NULL && url->url != NULL) { + lua_pushnumber (L, url->url->count); + } + else { + lua_pushnil (L); + } + + return 1; +} + +/*** * @method url:to_table() * Return url as a table with the following fields: * |