commit e4f459e: [Feature] Ppopagate monitored errors from rbl module
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Mar 17 14:28:07 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-03-17 14:21:38 +0000
URL: https://github.com/rspamd/rspamd/commit/e4f459ef31aed15751edd9ae77f6183b7da3b7b4 (HEAD -> master)
[Feature] Ppopagate monitored errors from rbl module
---
src/libserver/monitored.c | 2 +-
src/libserver/monitored.h | 8 ++++++++
src/lua/lua_config.c | 19 +++++++++++++++++++
src/plugins/lua/rbl.lua | 3 +++
4 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/src/libserver/monitored.c b/src/libserver/monitored.c
index 7b55b07ec..e1fac6fa1 100644
--- a/src/libserver/monitored.c
+++ b/src/libserver/monitored.c
@@ -98,7 +98,7 @@ struct rspamd_monitored {
INIT_LOG_MODULE(monitored)
-static inline void
+inline void
rspamd_monitored_propagate_error (struct rspamd_monitored *m,
const gchar *error)
{
diff --git a/src/libserver/monitored.h b/src/libserver/monitored.h
index 2453a8f48..ce259d176 100644
--- a/src/libserver/monitored.h
+++ b/src/libserver/monitored.h
@@ -148,6 +148,14 @@ void rspamd_monitored_stop (struct rspamd_monitored *m);
*/
void rspamd_monitored_start (struct rspamd_monitored *m);
+/**
+ * Propagate external monitored error
+ * @param m
+ * @param error
+ */
+void rspamd_monitored_propagate_error (struct rspamd_monitored *m,
+ const gchar *error);
+
/**
* Destroy monitored context and all monitored objects inside
* @param ctx
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index f42ca268e..fdc572d9d 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -912,12 +912,14 @@ LUA_FUNCTION_DEF (monitored, alive);
LUA_FUNCTION_DEF (monitored, latency);
LUA_FUNCTION_DEF (monitored, offline);
LUA_FUNCTION_DEF (monitored, total_offline);
+LUA_FUNCTION_DEF (monitored, propagate_error);
static const struct luaL_reg monitoredlib_m[] = {
LUA_INTERFACE_DEF (monitored, alive),
LUA_INTERFACE_DEF (monitored, latency),
LUA_INTERFACE_DEF (monitored, offline),
LUA_INTERFACE_DEF (monitored, total_offline),
+ LUA_INTERFACE_DEF (monitored, propagate_error),
{"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -4631,6 +4633,23 @@ lua_monitored_latency (lua_State *L)
return 1;
}
+static gint
+lua_monitored_propagate_error (lua_State *L)
+{
+ LUA_TRACE_POINT;
+ struct rspamd_monitored *m = lua_check_monitored (L, 1);
+ const gchar *what = luaL_checkstring (L, 2);
+
+ if (m && what) {
+ rspamd_monitored_propagate_error (m, what);
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 0;
+}
+
void
luaopen_config (lua_State * L)
{
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index f476932b0..fcda1727f 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -228,6 +228,9 @@ local function rbl_dns_process(task, rbl, to_resolve, results, err, resolve_tabl
rspamd_logger.infox(task, 'error looking up %s: %s', to_resolve, err)
task:insert_result(rbl.symbol .. '_FAIL', 1, string.format('%s:%s',
resolve_table_elt.orig, err))
+ if rbl.monitored then
+ rbl.monitored:propagate_error(err)
+ end
return
end
More information about the Commits
mailing list