Browse Source

Allow to disable hyperscan and use pcre only

tags/1.1.0
Vsevolod Stakhov 8 years ago
parent
commit
335ab27a5f

+ 1
- 0
src/libserver/cfg_file.h View File

@@ -231,6 +231,7 @@ struct rspamd_config {
gboolean strict_protocol_headers; /**< strictly check protocol headers */
gboolean check_all_filters; /**< check all filters */
gboolean allow_raw_input; /**< scan messages with invalid mime */
gboolean disable_hyperscan; /**< disable hyperscan usage */

gsize max_diff; /**< maximum diff size for text parts */


+ 5
- 0
src/libserver/cfg_rcl.c View File

@@ -1465,6 +1465,11 @@ rspamd_rcl_config_init (void)
rspamd_rcl_parse_struct_integer,
G_STRUCT_OFFSET (struct rspamd_config, history_rows),
RSPAMD_CL_FLAG_UINT);
rspamd_rcl_add_default_handler (sub,
"disable_hyperscan",
rspamd_rcl_parse_struct_boolean,
G_STRUCT_OFFSET (struct rspamd_config, disable_hyperscan),
0);

/* New DNS configuration */
ssub = rspamd_rcl_add_section (&sub->subsections, "dns", NULL, NULL,

+ 1
- 1
src/libserver/cfg_utils.c View File

@@ -671,7 +671,7 @@ rspamd_config_post_load (struct rspamd_config *cfg, gboolean validate_cache)
rspamd_symbols_cache_init (cfg->cache);

/* Init re cache */
rspamd_re_cache_init (cfg->re_cache);
rspamd_re_cache_init (cfg->re_cache, cfg);

/* Validate cache */
if (validate_cache) {

+ 9
- 3
src/libserver/re_cache.c View File

@@ -29,6 +29,7 @@
#include "ref.h"
#include "libserver/url.h"
#include "libserver/task.h"
#include "libserver/cfg_file.h"
#include "libutil/util.h"
#ifdef WITH_HYPERSCAN
#include "hs.h"
@@ -99,6 +100,7 @@ struct rspamd_re_cache {
guint max_re_data;
gchar hash[rspamd_cryptobox_HASHBYTES + 1];
#ifdef WITH_HYPERSCAN
gboolean disable_hyperscan;
hs_platform_info_t plt;
#endif
};
@@ -286,7 +288,7 @@ rspamd_re_cache_sort_func (gconstpointer a, gconstpointer b)
}

void
rspamd_re_cache_init (struct rspamd_re_cache *cache)
rspamd_re_cache_init (struct rspamd_re_cache *cache, struct rspamd_config *cfg)
{
guint i, fl;
GHashTableIter it;
@@ -364,6 +366,8 @@ rspamd_re_cache_init (struct rspamd_re_cache *cache)
const gchar *platform = "generic";
rspamd_fstring_t *features = rspamd_fstring_new ();

cache->disable_hyperscan = cfg->disable_hyperscan;

g_assert (hs_populate_platform (&cache->plt) == HS_SUCCESS);

/* Now decode what we do have */
@@ -541,7 +545,7 @@ rspamd_re_cache_process_regexp_data (struct rspamd_re_runtime *rt,
#else
struct rspamd_re_hyperscan_cbdata cbdata;

if (elt->match_type == RSPAMD_RE_CACHE_PCRE) {
if (rt->cache->disable_hyperscan || elt->match_type == RSPAMD_RE_CACHE_PCRE) {
ret = rspamd_re_cache_process_pcre (rt, re, in, len, is_raw);
setbit (rt->checked, re_id);
rt->results[re_id] = ret;
@@ -751,7 +755,9 @@ rspamd_re_cache_exec_re (struct rspamd_task *task,
break;
}

rspamd_re_cache_finish_class (rt, re_class);
if (!rt->cache->disable_hyperscan) {
rspamd_re_cache_finish_class (rt, re_class);
}

return ret;
}

+ 3
- 1
src/libserver/re_cache.h View File

@@ -30,6 +30,7 @@
struct rspamd_re_cache;
struct rspamd_re_runtime;
struct rspamd_task;
struct rspamd_config;

enum rspamd_re_type {
RSPAMD_RE_HEADER,
@@ -78,7 +79,8 @@ void rspamd_re_cache_replace (struct rspamd_re_cache *cache,
/**
* Initialize and optimize re cache structure
*/
void rspamd_re_cache_init (struct rspamd_re_cache *cache);
void rspamd_re_cache_init (struct rspamd_re_cache *cache,
struct rspamd_config *cfg);

/**
* Get runtime data for a cache

Loading…
Cancel
Save