]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add public_groups_only flag
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 30 Aug 2019 18:27:26 +0000 (19:27 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 30 Aug 2019 18:40:08 +0000 (19:40 +0100)
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/libserver/protocol.c

index 9573b776aeee3bbdfa31589dc481ffa83bc72c37..cffe997e4c27242cfb8ca535caea8f59b1e142a1 100644 (file)
@@ -368,6 +368,7 @@ struct rspamd_config {
        gboolean disable_pcre_jit;                      /**< Disable pcre JIT                                                                   */
        gboolean own_lua_state;                         /**< True if we have created lua_state internally               */
        gboolean soft_reject_on_timeout;                /**< If true emit soft reject on task timeout (if not reject) */
+       gboolean public_groups_only;                    /**< Output merely public groups everywhere                             */
 
        gsize max_cores_size;                           /**< maximum size occupied by rspamd core files                 */
        gsize max_cores_count;                          /**< maximum number of core files                                               */
index d224b4029459224bff7c08e959fdef498885057a..2bdb6adc6ee0c25a513f218a9dfba33b85a82462 100644 (file)
@@ -1960,6 +1960,12 @@ rspamd_rcl_config_init (struct rspamd_config *cfg, GHashTable *skip_sections)
                                G_STRUCT_OFFSET (struct rspamd_config, check_all_filters),
                                0,
                                "Always check all filters");
+               rspamd_rcl_add_default_handler (sub,
+                               "public_groups_only",
+                               rspamd_rcl_parse_struct_boolean,
+                               G_STRUCT_OFFSET (struct rspamd_config, public_groups_only),
+                               0,
+                               "Output merely public groups everywhere");
                rspamd_rcl_add_default_handler (sub,
                                "enable_experimental",
                                rspamd_rcl_parse_struct_boolean,
index f09784c48f215d758fe9e7144de2a10172740b2f..469b834dc462593c5c092f3e6fe138fe54ed0b0d 100644 (file)
@@ -1248,8 +1248,13 @@ rspamd_scan_result_ucl (struct rspamd_task *task,
                gdouble gr_score;
 
                obj = ucl_object_typed_new (UCL_OBJECT);
+               ucl_object_reserve (obj, kh_size (mres->sym_groups));
 
                kh_foreach (mres->sym_groups, gr, gr_score,{
+                       if (task->cfg->public_groups_only &&
+                               !(gr->flags & RSPAMD_SYMBOL_GROUP_PUBLIC)) {
+                               continue;
+                       }
                        sobj = rspamd_metric_group_ucl (task, gr, gr_score);
                        ucl_object_insert_key (obj, sobj, gr->name, 0, false);
                });