diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-11-20 13:52:08 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-11-20 13:52:08 +0000 |
commit | 2cd0e1c61cced7f9fdfde4f6e11dda296969e663 (patch) | |
tree | 49d21f6fef9a92f902867e5456a5d8c188378368 /src/lua/lua_url.c | |
parent | 640eeeed3dd244e2fcbea31063079e59d60a1c9c (diff) | |
download | rspamd-2cd0e1c61cced7f9fdfde4f6e11dda296969e663.tar.gz rspamd-2cd0e1c61cced7f9fdfde4f6e11dda296969e663.zip |
Add is_obscured method for lua url API
Diffstat (limited to 'src/lua/lua_url.c')
-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 8a9c90216..c503f1146 100644 --- a/src/lua/lua_url.c +++ b/src/lua/lua_url.c @@ -57,6 +57,7 @@ LUA_FUNCTION_DEF (url, get_text); LUA_FUNCTION_DEF (url, get_tld); LUA_FUNCTION_DEF (url, to_table); LUA_FUNCTION_DEF (url, is_phished); +LUA_FUNCTION_DEF (url, is_obscured); LUA_FUNCTION_DEF (url, get_phished); LUA_FUNCTION_DEF (url, create); LUA_FUNCTION_DEF (url, all); @@ -73,6 +74,7 @@ static const struct luaL_reg urllib_m[] = { LUA_INTERFACE_DEF (url, get_tld), LUA_INTERFACE_DEF (url, to_table), LUA_INTERFACE_DEF (url, is_phished), + LUA_INTERFACE_DEF (url, is_obscured), LUA_INTERFACE_DEF (url, get_phished), {"__tostring", lua_url_get_text}, {NULL, NULL} @@ -271,6 +273,26 @@ lua_url_is_phished (lua_State *L) } /*** + * @method url:is_obscured() + * Check whether URL is treated as obscured or obfusicated (e.g. numbers in IP address or other hacks) + * @return {boolean} `true` if URL is obscured + */ +static gint +lua_url_is_obscured (lua_State *L) +{ + struct rspamd_lua_url *url = lua_check_url (L, 1); + + if (url != NULL) { + lua_pushboolean (L, url->url->flags & RSPAMD_URL_FLAG_OBSCURED); + } + else { + lua_pushnil (L); + } + + return 1; +} + +/*** * @method url:get_phished() * Get another URL that pretends to be this URL (e.g. used in phishing) * @return {url} phished URL |