aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-07-16 12:50:14 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-07-16 13:04:14 +0100
commitdc183dbe67572463edf73b0384baeb8334b62ba0 (patch)
tree20b075782c46f8bc9deb1f3f88f42ca6c7a190d1 /src
parentc67fe3100e015e8481631c7d4db18bceaed6b1a4 (diff)
downloadrspamd-dc183dbe67572463edf73b0384baeb8334b62ba0.tar.gz
rspamd-dc183dbe67572463edf73b0384baeb8334b62ba0.zip
[Minor] Add read-only mode for fuzzy storage
Diffstat (limited to 'src')
-rw-r--r--src/fuzzy_storage.c53
1 files changed, 15 insertions, 38 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 704f160f4..a0fa9d182 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -127,7 +127,6 @@ struct rspamd_fuzzy_storage_ctx {
struct rspamd_config *cfg;
/* END OF COMMON PART */
struct fuzzy_global_stat stat;
- char *hashfile;
gdouble expire;
gdouble sync_timeout;
struct rspamd_radix_map_helper *update_ips;
@@ -155,6 +154,7 @@ struct rspamd_fuzzy_storage_ctx {
GHashTable *keys;
gboolean encrypted_only;
gboolean collection_mode;
+ gboolean read_only;
struct rspamd_cryptobox_keypair *collection_keypair;
struct rspamd_cryptobox_pubkey *collection_sign_key;
gchar *collection_id_file;
@@ -241,6 +241,10 @@ rspamd_fuzzy_check_client (struct fuzzy_session *session, gboolean is_write)
}
if (is_write) {
+ if (session->ctx->read_only) {
+ return FALSE;
+ }
+
if (session->ctx->update_ips != NULL) {
if (rspamd_match_radix_map_addr (session->ctx->update_ips,
session->addr) == NULL) {
@@ -809,7 +813,7 @@ rspamd_fuzzy_check_callback (struct rspamd_fuzzy_reply *result, void *ud)
rspamd_fuzzy_make_reply (cmd, result, session, encrypted, is_shingle);
/* Refresh hash if found with strong confidence */
- if (result->v1.prob > 0.9) {
+ if (result->v1.prob > 0.9 && !session->ctx->read_only) {
struct fuzzy_peer_cmd up_cmd;
struct fuzzy_peer_request *up_req;
@@ -2468,42 +2472,6 @@ init_fuzzy (struct rspamd_config *cfg)
rspamd_rcl_register_worker_option (cfg,
type,
- "hashfile",
- rspamd_rcl_parse_struct_string,
- ctx,
- G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, hashfile),
- 0,
- "Path to fuzzy database");
-
- rspamd_rcl_register_worker_option (cfg,
- type,
- "hash_file",
- rspamd_rcl_parse_struct_string,
- ctx,
- G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, hashfile),
- 0,
- "Path to fuzzy database (alias for hashfile)");
-
- rspamd_rcl_register_worker_option (cfg,
- type,
- "file",
- rspamd_rcl_parse_struct_string,
- ctx,
- G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, hashfile),
- 0,
- "Path to fuzzy database (alias for hashfile)");
-
- rspamd_rcl_register_worker_option (cfg,
- type,
- "database",
- rspamd_rcl_parse_struct_string,
- ctx,
- G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, hashfile),
- 0,
- "Path to fuzzy database (alias for hashfile)");
-
- rspamd_rcl_register_worker_option (cfg,
- type,
"sync",
rspamd_rcl_parse_struct_time,
ctx,
@@ -2564,6 +2532,15 @@ init_fuzzy (struct rspamd_config *cfg)
rspamd_rcl_register_worker_option (cfg,
type,
+ "read_only",
+ rspamd_rcl_parse_struct_boolean,
+ ctx,
+ G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, read_only),
+ 0,
+ "Work in read only mode");
+
+ rspamd_rcl_register_worker_option (cfg,
+ type,
"master_timeout",
rspamd_rcl_parse_struct_time,
ctx,