@@ -2046,6 +2046,7 @@ rspamd_controller_handle_stat_common ( | |||
struct rspamd_task *task; | |||
struct rspamd_stat_cbdata *cbdata; | |||
memset (&mem_st, 0, sizeof (mem_st)); | |||
rspamd_mempool_stat (&mem_st); | |||
memcpy (&stat_copy, session->ctx->worker->srv->stat, sizeof (stat_copy)); | |||
stat = &stat_copy; |
@@ -370,6 +370,8 @@ struct rspamd_config { | |||
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 */ | |||
guint32 dns_retransmits; /**< maximum retransmits count */ | |||
guint32 dns_throttling_errors; /**< maximum errors for starting resolver throttling */ |
@@ -93,7 +93,7 @@ rspamd_rcl_logging_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
GError **err) | |||
{ | |||
const ucl_object_t *val; | |||
const gchar *facility, *log_type, *log_level; | |||
const gchar *facility = NULL, *log_type = NULL, *log_level = NULL; | |||
struct rspamd_config *cfg = ud; | |||
val = ucl_object_lookup (obj, "type"); | |||
@@ -1940,6 +1940,12 @@ rspamd_rcl_config_init (struct rspamd_config *cfg) | |||
G_STRUCT_OFFSET (struct rspamd_config, ssl_ciphers), | |||
0, | |||
"List of ssl ciphers (e.g. HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4)"); | |||
rspamd_rcl_add_default_handler (sub, | |||
"magic_file", | |||
rspamd_rcl_parse_struct_string, | |||
G_STRUCT_OFFSET (struct rspamd_config, magic_file), | |||
0, | |||
"Path to a custom libmagic file"); | |||
/* New DNS configuration */ | |||
ssub = rspamd_rcl_add_section_doc (&sub->subsections, "dns", NULL, NULL, | |||
UCL_OBJECT, FALSE, TRUE, |
@@ -1194,7 +1194,7 @@ rspamd_parse_host_port_priority (const gchar *str, | |||
} | |||
guchar* | |||
rspamd_inet_address_get_radix_key (const rspamd_inet_addr_t *addr, guint *klen) | |||
rspamd_inet_address_get_hash_key (const rspamd_inet_addr_t *addr, guint *klen) | |||
{ | |||
guchar *res = NULL; | |||
static struct in_addr local = {INADDR_LOOPBACK}; | |||
@@ -1214,6 +1214,10 @@ rspamd_inet_address_get_radix_key (const rspamd_inet_addr_t *addr, guint *klen) | |||
*klen = sizeof (struct in_addr); | |||
res = (guchar *)&local; | |||
} | |||
else { | |||
*klen = 0; | |||
res = NULL; | |||
} | |||
return res; | |||
} |
@@ -136,7 +136,7 @@ gint rspamd_inet_address_get_af (const rspamd_inet_addr_t *addr); | |||
* @param klen | |||
* @return | |||
*/ | |||
guchar * rspamd_inet_address_get_radix_key (const rspamd_inet_addr_t *addr, guint *klen); | |||
guchar * rspamd_inet_address_get_hash_key (const rspamd_inet_addr_t *addr, guint *klen); | |||
/** | |||
* Receive data from an unconnected socket and fill the inet_addr structure if needed |
@@ -129,7 +129,7 @@ radix_find_compressed_addr (radix_compressed_t *tree, | |||
return RADIX_NO_VALUE; | |||
} | |||
key = rspamd_inet_address_get_radix_key (addr, &klen); | |||
key = rspamd_inet_address_get_hash_key (addr, &klen); | |||
if (key && klen) { | |||
return radix_find_compressed (tree, key, klen); |
@@ -2069,7 +2069,6 @@ rspamd_init_libs (void) | |||
#endif | |||
ctx->libmagic = magic_open (MAGIC_MIME|MAGIC_NO_CHECK_COMPRESS| | |||
MAGIC_NO_CHECK_ELF|MAGIC_NO_CHECK_TAR); | |||
magic_load (ctx->libmagic, NULL); | |||
ctx->local_addrs = rspamd_inet_library_init (); | |||
REF_INIT_RETAIN (ctx, rspamd_deinit_libs); | |||
@@ -2113,6 +2112,10 @@ rspamd_config_libs (struct rspamd_external_libs_ctx *ctx, | |||
SSL_CTX_set_cipher_list (ctx->ssl_ctx, secure_ciphers); | |||
} | |||
} | |||
if (ctx->libmagic) { | |||
magic_load (ctx->libmagic, cfg->magic_file); | |||
} | |||
} | |||
} | |||
@@ -224,7 +224,7 @@ lua_ip_to_table (lua_State *L) | |||
if (ip != NULL && ip->addr) { | |||
lua_newtable (L); | |||
ptr = rspamd_inet_address_get_radix_key (ip->addr, &max); | |||
ptr = rspamd_inet_address_get_hash_key (ip->addr, &max); | |||
for (i = 1; i <= max; i++, ptr++) { | |||
lua_pushnumber (L, *ptr); | |||
@@ -250,7 +250,7 @@ lua_ip_str_octets (lua_State *L) | |||
if (ip != NULL && ip->addr) { | |||
lua_newtable (L); | |||
af = rspamd_inet_address_get_af (ip->addr); | |||
ptr = rspamd_inet_address_get_radix_key (ip->addr, &max); | |||
ptr = rspamd_inet_address_get_hash_key (ip->addr, &max); | |||
for (i = 1; i <= max; i++, ptr++) { | |||
if (af == AF_INET) { | |||
@@ -289,7 +289,7 @@ lua_ip_inversed_str_octets (lua_State *L) | |||
if (ip != NULL && ip->addr) { | |||
lua_newtable (L); | |||
ptr = rspamd_inet_address_get_radix_key (ip->addr, &max); | |||
ptr = rspamd_inet_address_get_hash_key (ip->addr, &max); | |||
af = rspamd_inet_address_get_af (ip->addr); | |||
ptr += max - 1; | |||
@@ -379,7 +379,7 @@ lua_ip_to_number (lua_State *L) | |||
guchar *ptr; | |||
if (ip != NULL && ip->addr) { | |||
ptr = rspamd_inet_address_get_radix_key (ip->addr, &max); | |||
ptr = rspamd_inet_address_get_hash_key (ip->addr, &max); | |||
for (i = 0; i < max / sizeof (c); i ++) { | |||
memcpy (&c, ptr + i * sizeof (c), sizeof (c)); |
@@ -279,7 +279,7 @@ spf_check_element (struct spf_addr *addr, struct rspamd_task *task) | |||
/* Basic comparing algorithm */ | |||
if (((addr->flags & RSPAMD_SPF_FLAG_IPV6) && af == AF_INET6) || | |||
((addr->flags & RSPAMD_SPF_FLAG_IPV4) && af == AF_INET)) { | |||
d = rspamd_inet_address_get_radix_key (task->from_addr, &addrlen); | |||
d = rspamd_inet_address_get_hash_key (task->from_addr, &addrlen); | |||
if (af == AF_INET6) { | |||
s = (const guint8 *)addr->addr6; |
@@ -432,7 +432,7 @@ static inline uintptr_t | |||
make_listen_key (struct rspamd_worker_bind_conf *cf) | |||
{ | |||
rspamd_cryptobox_fast_hash_state_t st; | |||
guint i, keylen; | |||
guint i, keylen = 0; | |||
guint8 *key; | |||
rspamd_inet_addr_t *addr; | |||
guint16 port; | |||
@@ -446,7 +446,7 @@ make_listen_key (struct rspamd_worker_bind_conf *cf) | |||
rspamd_cryptobox_fast_hash_update (&st, cf->name, strlen (cf->name)); | |||
for (i = 0; i < cf->cnt; i ++) { | |||
addr = g_ptr_array_index (cf->addrs, i); | |||
key = rspamd_inet_address_get_radix_key ( | |||
key = rspamd_inet_address_get_hash_key ( | |||
addr, &keylen); | |||
rspamd_cryptobox_fast_hash_update (&st, key, keylen); | |||
port = rspamd_inet_address_get_port (addr); |