]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Feature] Add 'noop' redis backend for scripts running
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 11 Jan 2025 14:12:26 +0000 (14:12 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 11 Jan 2025 14:12:26 +0000 (14:12 +0000)
src/libserver/CMakeLists.txt
src/libserver/fuzzy_backend/fuzzy_backend.c
src/libserver/fuzzy_backend/fuzzy_backend_redis.h

index dd17865de2bed5d23e58516088c1773e981c352a..d3415bdb299bb54e5cf55100f18b2073302af218 100644 (file)
@@ -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
index c1846361815ef8796f3d8b7d33917a5851939f0f..bab2895cd051e6b9a27face955b8b5b1653299c5 100644 (file)
@@ -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",
index afeb1c5738ecc088fd9abe74718419f78734a2de..0a536c2fa297b9439c6a36679feb67f24af27cb3 100644 (file)
@@ -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"