]> source.dussan.org Git - rspamd.git/commitdiff
Add upstreams configuration.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Nov 2014 10:18:55 +0000 (10:18 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Nov 2014 10:18:55 +0000 (10:18 +0000)
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/libserver/cfg_rcl.h

index 833dd053db4b57fe3d9259e5d0467f89966ef1c2..5844a945f95c78da067be0cd6fec5735ba55e6fb 100644 (file)
@@ -322,6 +322,10 @@ struct rspamd_config {
        guint32 dns_throttling_time;                    /**< time in seconds for DNS throttling                                 */
        guint32 dns_io_per_server;                      /**< number of sockets per DNS server                                   */
        GList *nameservers;                             /**< list of nameservers or NULL to parse resolv.conf   */
+
+       guint upstream_max_errors;                                              /**< upstream max errors before shutting off                    */
+       gdouble upstream_error_time;                                    /**< rate of upstream errors                                                    */
+       gdouble upstream_revive_time;                                   /**< revive timeout for upstreams                                               */
 };
 
 
index 922eb1ef4c42b80db671bbe8bf924484ee8fc106..c7ccdccbe7c1dbf3e1d63fa09b670c45586440dc 100644 (file)
@@ -212,8 +212,8 @@ static gboolean
 rspamd_rcl_options_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
        gpointer ud, struct rspamd_rcl_section *section, GError **err)
 {
-       const ucl_object_t *dns;
-       struct rspamd_rcl_section *dns_section;
+       const ucl_object_t *dns, *upstream;
+       struct rspamd_rcl_section *dns_section, *upstream_section;
 
        HASH_FIND_STR (section->subsections, "dns", dns_section);
 
@@ -225,6 +225,16 @@ rspamd_rcl_options_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
                }
        }
 
+       HASH_FIND_STR (section->subsections, "upstream", upstream_section);
+
+       upstream = ucl_object_find_key (obj, "upstream");
+       if (upstream_section != NULL && upstream != NULL) {
+               if (!rspamd_rcl_section_parse_defaults (upstream_section, cfg,
+                       upstream, cfg, err)) {
+                       return FALSE;
+               }
+       }
+
        return rspamd_rcl_section_parse_defaults (section, cfg, obj, cfg, err);
 }
 
@@ -1252,6 +1262,7 @@ rspamd_rcl_config_init (void)
                rspamd_rcl_parse_struct_integer,
                G_STRUCT_OFFSET (struct rspamd_config, dns_io_per_server),
                RSPAMD_CL_FLAG_INT_32);
+
        /* New DNS configiration */
        ssub = rspamd_rcl_add_section (&sub->subsections, "dns", NULL,
                        UCL_OBJECT, FALSE, TRUE);
@@ -1276,6 +1287,25 @@ rspamd_rcl_config_init (void)
                G_STRUCT_OFFSET (struct rspamd_config, dns_io_per_server),
                RSPAMD_CL_FLAG_INT_32);
 
+       /* New upstreams configuration */
+       ssub = rspamd_rcl_add_section (&sub->subsections, "upstream", NULL,
+               UCL_OBJECT, FALSE, TRUE);
+       rspamd_rcl_add_default_handler (ssub,
+               "max_errors",
+               rspamd_rcl_parse_struct_integer,
+               G_STRUCT_OFFSET (struct rspamd_config, upstream_max_errors),
+               RSPAMD_CL_FLAG_UINT);
+       rspamd_rcl_add_default_handler (ssub,
+               "error_time",
+               rspamd_rcl_parse_struct_time,
+               G_STRUCT_OFFSET (struct rspamd_config, upstream_error_time),
+               RSPAMD_CL_FLAG_TIME_FLOAT);
+       rspamd_rcl_add_default_handler (ssub,
+               "revive_time",
+               rspamd_rcl_parse_struct_time,
+               G_STRUCT_OFFSET (struct rspamd_config, upstream_revive_time),
+               RSPAMD_CL_FLAG_TIME_FLOAT);
+
        rspamd_rcl_add_default_handler (sub,
                "raw_mode",
                rspamd_rcl_parse_struct_boolean,
index 333a3e1eead3741003a4bbf059e49693ae12dfc4..97f092ec3f76a53c2791261e7e7d296ca3047841 100644 (file)
@@ -50,8 +50,9 @@ struct rspamd_rcl_struct_parser {
                RSPAMD_CL_FLAG_INT_16 = 0x1 << 5,
                RSPAMD_CL_FLAG_INT_32 = 0x1 << 6,
                RSPAMD_CL_FLAG_INT_64 = 0x1 << 7,
-               RSPAMD_CL_FLAG_INT_SIZE = 0x1 << 8,
-               RSPAMD_CL_FLAG_STRING_PATH = 0x1 << 9
+               RSPAMD_CL_FLAG_UINT = 0x1 << 8,
+               RSPAMD_CL_FLAG_INT_SIZE = 0x1 << 9,
+               RSPAMD_CL_FLAG_STRING_PATH = 0x1 << 10
        } flags;
 };