From: Vsevolod Stakhov Date: Sat, 11 Jan 2025 14:12:26 +0000 (+0000) Subject: [Feature] Add 'noop' redis backend for scripts running X-Git-Tag: 3.11.1~44^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90b49435d34d1f4934f41edde70d54e641feab66;p=thirdparty%2Frspamd.git [Feature] Add 'noop' redis backend for scripts running --- diff --git a/src/libserver/CMakeLists.txt b/src/libserver/CMakeLists.txt index dd17865de2..d3415bdb29 100644 --- a/src/libserver/CMakeLists.txt +++ b/src/libserver/CMakeLists.txt @@ -12,6 +12,7 @@ SET(LIBRSPAMDSERVERSRC ${CMAKE_CURRENT_SOURCE_DIR}/fuzzy_backend/fuzzy_backend.c ${CMAKE_CURRENT_SOURCE_DIR}/fuzzy_backend/fuzzy_backend_sqlite.c ${CMAKE_CURRENT_SOURCE_DIR}/fuzzy_backend/fuzzy_backend_redis.c + ${CMAKE_CURRENT_SOURCE_DIR}/fuzzy_backend/fuzzy_backend_noop.c ${CMAKE_CURRENT_SOURCE_DIR}/milter.c ${CMAKE_CURRENT_SOURCE_DIR}/monitored.c ${CMAKE_CURRENT_SOURCE_DIR}/protocol.c diff --git a/src/libserver/fuzzy_backend/fuzzy_backend.c b/src/libserver/fuzzy_backend/fuzzy_backend.c index c184636181..bab2895cd0 100644 --- a/src/libserver/fuzzy_backend/fuzzy_backend.c +++ b/src/libserver/fuzzy_backend/fuzzy_backend.c @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -18,6 +18,7 @@ #include "fuzzy_backend.h" #include "fuzzy_backend_sqlite.h" #include "fuzzy_backend_redis.h" +#include "fuzzy_backend_noop.h" #include "cfg_file.h" #include "fuzzy_wire.h" @@ -26,6 +27,7 @@ enum rspamd_fuzzy_backend_type { RSPAMD_FUZZY_BACKEND_SQLITE = 0, RSPAMD_FUZZY_BACKEND_REDIS = 1, + RSPAMD_FUZZY_BACKEND_NOOP = 2, }; static void *rspamd_fuzzy_backend_init_sqlite(struct rspamd_fuzzy_backend *bk, @@ -96,6 +98,16 @@ static const struct rspamd_fuzzy_backend_subr fuzzy_subrs[] = { .id = rspamd_fuzzy_backend_id_redis, .periodic = rspamd_fuzzy_backend_expire_redis, .close = rspamd_fuzzy_backend_close_redis, + }, + [RSPAMD_FUZZY_BACKEND_NOOP] = { + .init = rspamd_fuzzy_backend_init_noop, + .check = rspamd_fuzzy_backend_check_noop, + .update = rspamd_fuzzy_backend_update_noop, + .count = rspamd_fuzzy_backend_count_noop, + .version = rspamd_fuzzy_backend_version_noop, + .id = rspamd_fuzzy_backend_id_noop, + .periodic = rspamd_fuzzy_backend_expire_noop, + .close = rspamd_fuzzy_backend_close_noop, }}; struct rspamd_fuzzy_backend { @@ -288,6 +300,9 @@ rspamd_fuzzy_backend_create(struct ev_loop *ev_base, else if (strcmp(ucl_object_tostring(elt), "redis") == 0) { type = RSPAMD_FUZZY_BACKEND_REDIS; } + else if (strcmp(ucl_object_tostring(elt), "noop") == 0) { + type = RSPAMD_FUZZY_BACKEND_NOOP; + } else { g_set_error(err, rspamd_fuzzy_backend_quark(), EINVAL, "invalid backend type: %s", diff --git a/src/libserver/fuzzy_backend/fuzzy_backend_redis.h b/src/libserver/fuzzy_backend/fuzzy_backend_redis.h index afeb1c5738..0a536c2fa2 100644 --- a/src/libserver/fuzzy_backend/fuzzy_backend_redis.h +++ b/src/libserver/fuzzy_backend/fuzzy_backend_redis.h @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,7 +15,6 @@ */ #ifndef SRC_LIBSERVER_FUZZY_BACKEND_REDIS_H_ #define SRC_LIBSERVER_FUZZY_BACKEND_REDIS_H_ - #include "config.h" #include "fuzzy_backend.h"