From: Vsevolod Stakhov Date: Thu, 14 Apr 2016 17:27:51 +0000 (+0100) Subject: [Feature] Add common directory for hyperscan cache to config X-Git-Tag: 1.2.4~34 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ee1e8c27b804061f0e981ddc0b575291e4148c31;p=rspamd.git [Feature] Add common directory for hyperscan cache to config --- diff --git a/conf/options.inc b/conf/options.inc index d9b48a51e..318de7554 100644 --- a/conf/options.inc +++ b/conf/options.inc @@ -35,3 +35,4 @@ words_decay = 200; # Local networks local_addrs = "192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, fd00::/8, 169.254.0.0/16, fe80::/10"; +hs_cache_dir = "${DBDIR}/"; diff --git a/src/hs_helper.c b/src/hs_helper.c index 1434f551a..1292d6460 100644 --- a/src/hs_helper.c +++ b/src/hs_helper.c @@ -66,7 +66,7 @@ init_hs_helper (struct rspamd_config *cfg) ctx->magic = rspamd_hs_helper_magic; ctx->cfg = cfg; - ctx->hs_dir = RSPAMD_DBDIR "/"; + ctx->hs_dir = NULL; ctx->max_time = default_max_time; ctx->recompile_time = default_recompile_time; @@ -249,6 +249,14 @@ start_hs_helper (struct rspamd_worker *worker) struct timeval tv; double tim; + + if (ctx->hs_dir == NULL) { + ctx->hs_dir = ctx->cfg->hs_cache_dir; + } + if (ctx->hs_dir == NULL) { + ctx->hs_dir = RSPAMD_DBDIR "/"; + } + ctx->ev_base = rspamd_prepare_worker (worker, "hs_helper", NULL); diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index 0986ed035..67749c276 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -368,6 +368,8 @@ struct rspamd_config { gchar * tld_file; /**< file to load effective tld list from */ + gchar * hs_cache_dir; /**< directory to save hyperscan databases */ + gdouble dns_timeout; /**< timeout in milliseconds for waiting for dns reply */ guint32 dns_retransmits; /**< maximum retransmits count */ guint32 dns_throttling_errors; /**< maximum errors for starting resolver throttling */ diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index 288b8a505..7441e5bf0 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -1779,6 +1779,12 @@ rspamd_rcl_config_init (struct rspamd_config *cfg) G_STRUCT_OFFSET (struct rspamd_config, tld_file), RSPAMD_CL_FLAG_STRING_PATH, "Path to the TLD file for urls detector"); + rspamd_rcl_add_default_handler (sub, + "hs_cache_dir", + rspamd_rcl_parse_struct_string, + G_STRUCT_OFFSET (struct rspamd_config, hs_cache_dir), + RSPAMD_CL_FLAG_STRING_PATH, + "Path directory where rspamd would save hyperscan cache"); rspamd_rcl_add_default_handler (sub, "history_rows", rspamd_rcl_parse_struct_integer,