aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-11-03 10:18:55 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-11-03 10:18:55 +0000
commit00a71b1315eb60bbb62876b2927fa49ab2720d2b (patch)
tree65238ac4fc2f8fbcc19a30c825359fbf4966a91e
parent1e86acfae8cef9b7f0a547aca009a157fee2a1bf (diff)
downloadrspamd-00a71b1315eb60bbb62876b2927fa49ab2720d2b.tar.gz
rspamd-00a71b1315eb60bbb62876b2927fa49ab2720d2b.zip
Add upstreams configuration.
-rw-r--r--src/libserver/cfg_file.h4
-rw-r--r--src/libserver/cfg_rcl.c34
-rw-r--r--src/libserver/cfg_rcl.h5
3 files changed, 39 insertions, 4 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 833dd053d..5844a945f 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -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 */
};
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 922eb1ef4..c7ccdccbe 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -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,
diff --git a/src/libserver/cfg_rcl.h b/src/libserver/cfg_rcl.h
index 333a3e1ee..97f092ec3 100644
--- a/src/libserver/cfg_rcl.h
+++ b/src/libserver/cfg_rcl.h
@@ -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;
};