diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-09-11 14:16:23 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-09-11 14:16:23 +0100 |
commit | bd984bec8d80dce70e457d64743d13e4041b3731 (patch) | |
tree | abe152d119c0786bf37f7715e4a565b1f5c18cad /src/fuzzy_storage.c | |
parent | ffc34f417edef9f37860105d34449db0db19a5d8 (diff) | |
download | rspamd-bd984bec8d80dce70e457d64743d13e4041b3731.tar.gz rspamd-bd984bec8d80dce70e457d64743d13e4041b3731.zip |
[Project] Move ratelimit parsing stuff to a common library
Diffstat (limited to 'src/fuzzy_storage.c')
-rw-r--r-- | src/fuzzy_storage.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index 2f889c759..257d22bcd 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -698,6 +698,11 @@ fuzzy_key_dtor(gpointer p) kh_destroy(fuzzy_key_ids_set, key->forbidden_ids); } + if (key->rl_bucket) { + /* TODO: save bucket stats */ + g_free(key->rl_bucket); + } + g_free(key); } } @@ -2827,6 +2832,10 @@ fuzzy_add_keypair_from_ucl(const ucl_object_t *obj, khash_t(rspamd_fuzzy_keys_ha rspamd_inet_address_hash, rspamd_inet_address_equal); key->stat = keystat; key->flags_stat = kh_init(fuzzy_key_flag_stat); + key->burst = NAN; + key->rate = NAN; + key->expire = NAN; + key->rl_bucket = NULL; /* Preallocate some space for flags */ kh_resize(fuzzy_key_flag_stat, key->flags_stat, 8); const unsigned char *pk = rspamd_keypair_component(kp, RSPAMD_KEYPAIR_COMPONENT_PK, @@ -2874,6 +2883,20 @@ fuzzy_add_keypair_from_ucl(const ucl_object_t *obj, khash_t(rspamd_fuzzy_keys_ha } } } + + /* + * TODO: parse ratelimit using Lua code from `ratelimit` plugin to + * have unified form of settings + */ + const ucl_object_t *ratelimit = ucl_object_lookup(extensions, "ratelimit"); + + if (ratelimit && ucl_object_type(ratelimit) == UCL_STRING) { + } + + const ucl_object_t *expire = ucl_object_lookup(extensions, "expire"); + if (expire && ucl_object_type(expire) == UCL_STRING) { + struct tm tm; + } } msg_debug("loaded keypair %*bs", crypto_box_publickeybytes(), pk); |