diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-16 13:53:14 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-16 13:53:14 +0000 |
commit | eb697d4c984cca0f6e5566ac8c727f216b3f86fc (patch) | |
tree | b0c4c7cf0a239235fd9737e6b62f3304d2912aef /src/lua/lua_url.c | |
parent | 144acb70eb098e1d88bbc0d270a3e115f8b6aa27 (diff) | |
download | rspamd-eb697d4c984cca0f6e5566ac8c727f216b3f86fc.tar.gz rspamd-eb697d4c984cca0f6e5566ac8c727f216b3f86fc.zip |
[Minor] Lua_url: Add method to get url protocol
Diffstat (limited to 'src/lua/lua_url.c')
-rw-r--r-- | src/lua/lua_url.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c index 8bc0cf657..69a12e028 100644 --- a/src/lua/lua_url.c +++ b/src/lua/lua_url.c @@ -51,6 +51,7 @@ LUA_FUNCTION_DEF (url, tostring); LUA_FUNCTION_DEF (url, get_raw); LUA_FUNCTION_DEF (url, get_tld); LUA_FUNCTION_DEF (url, get_flags); +LUA_FUNCTION_DEF (url, get_protocol); LUA_FUNCTION_DEF (url, to_table); LUA_FUNCTION_DEF (url, is_phished); LUA_FUNCTION_DEF (url, is_redirected); @@ -77,6 +78,7 @@ static const struct luaL_reg urllib_m[] = { LUA_INTERFACE_DEF (url, get_text), LUA_INTERFACE_DEF (url, get_tld), LUA_INTERFACE_DEF (url, get_raw), + LUA_INTERFACE_DEF (url, get_protocol), LUA_INTERFACE_DEF (url, to_table), LUA_INTERFACE_DEF (url, is_phished), LUA_INTERFACE_DEF (url, is_redirected), @@ -607,6 +609,27 @@ lua_url_get_tld (lua_State *L) } /*** + * @method url:get_protocol() + * Get protocol name + * @return {string} protocol as a string + */ +static gint +lua_url_get_protocol (lua_State *L) +{ + LUA_TRACE_POINT; + struct rspamd_lua_url *url = lua_check_url (L, 1); + + if (url != NULL && url->url->protocol != PROTOCOL_UNKNOWN) { + lua_pushstring (L, rspamd_url_protocol_name (url->url->protocol)); + } + else { + lua_pushnil (L); + } + + return 1; +} + +/*** * @method url:get_count() * Return number of occurrencies for this particular URL * @return {number} number of occurrencies |