]> source.dussan.org Git - rspamd.git/commitdiff
Allow multiple values for rcl parsers
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 13 Dec 2015 22:55:02 +0000 (22:55 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 13 Dec 2015 23:03:42 +0000 (23:03 +0000)
src/fuzzy_storage.c
src/libserver/cfg_rcl.c
src/libserver/cfg_rcl.h

index 4a5623ef23c9f4b7c0cf852407750f53f020f999..2a4709ec509fd382c8360bfc6085e48b12b3d602 100644 (file)
@@ -780,7 +780,7 @@ init_fuzzy (struct rspamd_config *cfg)
 
        rspamd_rcl_register_worker_option (cfg, type, "keypair",
                        fuzzy_parse_keypair, ctx,
-                       0, 0);
+                       0, RSPAMD_CL_FLAG_MULTIPLE);
 
        rspamd_rcl_register_worker_option (cfg, type, "keypair_cache_size",
                        rspamd_rcl_parse_struct_integer, ctx,
index 24e9fe605ef61d024dc1761da2c9f96967befb83..2c8186292e9c51edec120ecbed0cdcdc61f81be2 100644 (file)
@@ -529,7 +529,7 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
                const gchar *key, gpointer ud,
                struct rspamd_rcl_section *section, GError **err)
 {
-       const ucl_object_t *val, *cur;
+       const ucl_object_t *val, *cur, *cur_obj;
        ucl_object_t *robj;
        ucl_object_iter_t it = NULL;
        const gchar *worker_type, *worker_bind;
@@ -605,10 +605,21 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
                it = NULL;
                while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) {
                        HASH_FIND_STR (wparser->parsers, ucl_object_key (cur), whandler);
+
                        if (whandler != NULL) {
-                               if (!whandler->handler (cfg->cfg_pool, cur, &whandler->parser,
-                                               section, err)) {
-                                       return FALSE;
+
+                               LL_FOREACH (cur, cur_obj) {
+                                       if (!whandler->handler (cfg->cfg_pool,
+                                                       cur_obj,
+                                                       &whandler->parser,
+                                                       section,
+                                                       err)) {
+                                               return FALSE;
+                                       }
+
+                                       if (!whandler->parser.flags & RSPAMD_CL_FLAG_MULTIPLE) {
+                                               break;
+                                       }
                                }
                        }
                }
@@ -1951,7 +1962,7 @@ rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section,
        rspamd_mempool_t *pool, const ucl_object_t *obj, gpointer ptr,
        GError **err)
 {
-       const ucl_object_t *found;
+       const ucl_object_t *found, *cur_obj;
        struct rspamd_rcl_default_handler_data *cur, *tmp;
 
        if (obj->type != UCL_OBJECT) {
@@ -1967,8 +1978,15 @@ rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section,
                found = ucl_object_find_key (obj, cur->key);
                if (found != NULL) {
                        cur->pd.user_struct = ptr;
-                       if (!cur->handler (pool, found, &cur->pd, section, err)) {
-                               return FALSE;
+
+                       LL_FOREACH (found, cur_obj) {
+                               if (!cur->handler (pool, cur_obj, &cur->pd, section, err)) {
+                                       return FALSE;
+                               }
+
+                               if (!cur->pd.flags & RSPAMD_CL_FLAG_MULTIPLE) {
+                                       break;
+                               }
                        }
                }
        }
index c242d6be901da4c825105529c18318766fa5692c..c7f4e4a96a759f02503d62b2d6bfe25f731007f2 100644 (file)
@@ -52,7 +52,8 @@ enum rspamd_rcl_flag {
        RSPAMD_CL_FLAG_INT_SIZE = 0x1 << 9,
        RSPAMD_CL_FLAG_STRING_PATH = 0x1 << 10,
        RSPAMD_CL_FLAG_BOOLEAN_INVERSE = 0x1 << 11,
-       RSPAMD_CL_FLAG_STRING_LIST_HASH = 0x1 << 12
+       RSPAMD_CL_FLAG_STRING_LIST_HASH = 0x1 << 12,
+       RSPAMD_CL_FLAG_MULTIPLE = 0x1 << 13
 };
 
 struct rspamd_rcl_struct_parser {