aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-07-26 13:43:45 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-07-26 13:43:45 +0100
commit5331d429f1bb3d615356c16f8ffe02632584938a (patch)
treecebd94e5de6f0980ee1eb693456d0acfdea15baa /src/lua
parent537a7180a0d5132c11636c4fd8b1450cd99d352c (diff)
downloadrspamd-5331d429f1bb3d615356c16f8ffe02632584938a.tar.gz
rspamd-5331d429f1bb3d615356c16f8ffe02632584938a.zip
[Minor] Add Lua methods to get urls order
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_url.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c
index 4dd09dec8..3f25b3128 100644
--- a/src/lua/lua_url.c
+++ b/src/lua/lua_url.c
@@ -72,6 +72,8 @@ LUA_FUNCTION_DEF(url, init);
LUA_FUNCTION_DEF(url, all);
LUA_FUNCTION_DEF(url, lt);
LUA_FUNCTION_DEF(url, eq);
+LUA_FUNCTION_DEF(url, get_order);
+LUA_FUNCTION_DEF(url, get_part_order);
static const struct luaL_reg urllib_m[] = {
LUA_INTERFACE_DEF(url, get_length),
@@ -97,6 +99,8 @@ static const struct luaL_reg urllib_m[] = {
LUA_INTERFACE_DEF(url, get_count),
LUA_INTERFACE_DEF(url, get_flags),
LUA_INTERFACE_DEF(url, get_flags_num),
+ LUA_INTERFACE_DEF(url, get_order),
+ LUA_INTERFACE_DEF(url, get_part_order),
{"get_redirected", lua_url_get_phished},
LUA_INTERFACE_DEF(url, set_redirected),
{"__tostring", lua_url_tostring},
@@ -942,6 +946,48 @@ lua_url_get_flags_num(lua_State *L)
return 1;
}
+static gint
+lua_url_get_order(lua_State *L)
+{
+ LUA_TRACE_POINT;
+ struct rspamd_lua_url *url = lua_check_url(L, 1);
+
+ if (url) {
+ if (url->url->order != (uint16_t) -1) {
+ lua_pushinteger(L, url->url->order);
+ }
+ else {
+ lua_pushnil(L);
+ }
+ }
+ else {
+ return luaL_error(L, "invalid arguments");
+ }
+
+ return 1;
+}
+
+static gint
+lua_url_get_part_order(lua_State *L)
+{
+ LUA_TRACE_POINT;
+ struct rspamd_lua_url *url = lua_check_url(L, 1);
+
+ if (url) {
+ if (url->url->part_order != (uint16_t) -1) {
+ lua_pushinteger(L, url->url->part_order);
+ }
+ else {
+ lua_pushnil(L);
+ }
+ }
+ else {
+ return luaL_error(L, "invalid arguments");
+ }
+
+ return 1;
+}
+
void lua_tree_url_callback(gpointer key, gpointer value, gpointer ud)
{
struct rspamd_lua_url *lua_url;