]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add `compat_messages` for compatibility with legacy protocol 1313/head
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 5 Jan 2017 11:17:44 +0000 (11:17 +0000)
committerAndrew Lewis <nerf@judo.za.org>
Thu, 5 Jan 2017 11:19:50 +0000 (13:19 +0200)
MFH: true

src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/libserver/protocol.c

index ea75622f823257e7a1ccb9a5abc346d409945024..362395fc6e65e60267b9091600bad5a8d247552f 100644 (file)
@@ -330,6 +330,7 @@ struct rspamd_config {
        guint log_error_elt_maxlen;                     /**< maximum size of error log element                                  */
 
        gboolean mlock_statfile_pool;                   /**< use mlock (2) for locking statfiles                                */
+       gboolean compat_messages;                       /**< use old messages in the protocol (array)                   */
 
        gboolean delivery_enable;                       /**< is delivery agent is enabled                                               */
        gchar *deliver_host;                            /**< host for mail deliviring                                                   */
@@ -377,13 +378,9 @@ struct rspamd_config {
        gpointer lua_state;                             /**< pointer to lua state                                                               */
 
        gchar * rrd_file;                               /**< rrd file to store statistics                                               */
-
        gchar * history_file;                           /**< file to save rolling history                                               */
-
        gchar * tld_file;                               /**< file to load effective tld list from                               */
-
        gchar * hs_cache_dir;                           /**< directory to save hyperscan databases                              */
-
        gchar * magic_file;                             /**< file to initialize libmagic                                                */
 
        gdouble dns_timeout;                            /**< timeout in milliseconds for waiting for dns reply  */
index 7737b7b965bf1f9c2da64050551255094fc13bd8..fecc7e819172857bb2e7e211e99456e0791de071 100644 (file)
@@ -2028,6 +2028,12 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
                        G_STRUCT_OFFSET (struct rspamd_config, zstd_output_dictionary),
                        RSPAMD_CL_FLAG_STRING_PATH,
                        "Dictionary for outbound zstd compression");
+       rspamd_rcl_add_default_handler (sub,
+                       "compat_messages",
+                       rspamd_rcl_parse_struct_boolean,
+                       G_STRUCT_OFFSET (struct rspamd_config, compat_messages),
+                       0,
+                       "Use pre 1.4 style of messages in the protocol");
 
        /* New DNS configuration */
        ssub = rspamd_rcl_add_section_doc (&sub->subsections, "dns", NULL, NULL,
index f33422dfe50b469a214aae378e0c1c93a1395a0a..c864ce567932edf2b011bb0b697c46d95ec9a2c0 100644 (file)
@@ -1022,8 +1022,25 @@ rspamd_protocol_write_ucl (struct rspamd_task *task)
                ucl_object_insert_key (top, obj, h, 0, false);
        }
 
-       ucl_object_insert_key (top, ucl_object_ref (task->messages),
+       if (G_UNLIKELY (task->cfg->compat_messages)) {
+               const ucl_object_t *cur;
+               ucl_object_t *msg_object;
+               ucl_object_iter_t iter = NULL;
+
+               msg_object = ucl_object_typed_new (UCL_ARRAY);
+
+               while ((cur = ucl_object_iterate (task->messages, &iter, true)) != NULL) {
+                       if (cur->type == UCL_STRING) {
+                               ucl_array_append (msg_object, ucl_object_ref (cur));
+                       }
+               }
+
+               ucl_object_insert_key (top, msg_object, "messages", 0, false);
+       }
+       else {
+               ucl_object_insert_key (top, ucl_object_ref (task->messages),
                        "messages", 0, false);
+       }
 
        if (task->cfg->log_urls || (task->flags & RSPAMD_TASK_FLAG_EXT_URLS)) {
                if (g_hash_table_size (task->urls) > 0) {