GHashTableIter iter;
gpointer key, value;
struct rspamd_keypair_cache *cache;
- const ucl_object_t *cur;
- ucl_object_iter_t it = NULL;
gpointer m;
ctx->ev_base = rspamd_prepare_worker (worker,
rspamd_strcase_equal);
if (ctx->secure_ip != NULL) {
- if (ucl_object_type (ctx->secure_ip) == UCL_ARRAY) {
-
- while ((cur = ucl_object_iterate (ctx->secure_ip, &it, true)) != NULL) {
- /* Try map syntax */
- if (ucl_object_type (cur) == UCL_STRING &&
- !rspamd_map_is_map (ucl_object_tostring (cur))) {
- if (!radix_add_generic_iplist (ucl_object_tostring (cur),
- &ctx->secure_map)) {
- msg_warn_ctx ("cannot load or parse ip list from '%s'",
- ucl_object_tostring (cur));
- }
- }
- else {
- rspamd_map_add_from_ucl (worker->srv->cfg, cur,
- "Allow webui access from the specified IP",
- rspamd_radix_read, rspamd_radix_fin,
- (void **)&ctx->secure_map);
- }
- }
- }
- else {
- LL_FOREACH (ctx->secure_ip, cur) {
- if (ucl_object_type (cur) == UCL_STRING &&
- !rspamd_map_is_map (ucl_object_tostring (cur))) {
- if (!radix_add_generic_iplist (ucl_object_tostring (cur),
- &ctx->secure_map)) {
- msg_warn_ctx ("cannot load or parse ip list from '%s'",
- ucl_object_tostring (cur));
- }
- }
- else {
- rspamd_map_add_from_ucl (worker->srv->cfg, ctx->secure_ip,
- "Allow webui access from the specified IP",
- rspamd_radix_read, rspamd_radix_fin,
- (void **)&ctx->secure_map);
- }
- }
- }
+ rspamd_config_radix_from_ucl (ctx->cfg, ctx->secure_ip,
+ "Allow unauthenticated requests from these addresses",
+ &ctx->secure_map, NULL);
}
if (ctx->saved_stats_path == NULL) {
struct timeval master_io_tv;
gdouble master_timeout;
GPtrArray *mirrors;
- gchar *update_map;
- gchar *masters_map;
+ const ucl_object_t *update_map;
+ const ucl_object_t *masters_map;
guint keypair_cache_size;
struct event_base *ev_base;
gint peer_fd;
rspamd_rcl_register_worker_option (cfg,
type,
"allow_update",
- rspamd_rcl_parse_struct_string,
+ rspamd_rcl_parse_struct_ucl,
ctx,
G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, update_map),
0,
rspamd_rcl_register_worker_option (cfg,
type,
"masters",
- rspamd_rcl_parse_struct_string,
+ rspamd_rcl_parse_struct_ucl,
ctx,
G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, masters_map),
0,
rspamd_fuzzy_storage_sync, ctx);
/* Create radix trees */
if (ctx->update_map != NULL) {
- if (!rspamd_map_is_map (ctx->update_map)) {
- if (!radix_add_generic_iplist (ctx->update_map,
- &ctx->update_ips)) {
- msg_warn ("cannot load or parse ip list from '%s'",
- ctx->update_map);
- }
- }
- else {
- rspamd_map_add (worker->srv->cfg, ctx->update_map,
- "Allow fuzzy updates from specified addresses",
- rspamd_radix_read, rspamd_radix_fin,
- (void **)&ctx->update_ips);
-
- }
+ rspamd_config_radix_from_ucl (worker->srv->cfg, ctx->update_map,
+ "Allow fuzzy updates from specified addresses",
+ &ctx->update_ips, NULL);
}
if (ctx->masters_map != NULL) {
- if (!rspamd_map_is_map (ctx->masters_map)) {
- if (!radix_add_generic_iplist (ctx->masters_map,
- &ctx->master_ips)) {
- msg_warn ("cannot load or parse ip list from '%s'",
- ctx->masters_map);
- }
- }
- else {
- rspamd_map_add (worker->srv->cfg, ctx->masters_map,
- "Allow fuzzy master/slave updates from specified addresses",
- rspamd_radix_read, rspamd_radix_fin,
- (void **)&ctx->master_ips);
-
- }
+ rspamd_config_radix_from_ucl (worker->srv->cfg, ctx->masters_map,
+ "Allow fuzzy master/slave updates from specified addresses",
+ &ctx->master_ips, NULL);
}
/* Maps events */
gchar *log_file; /**< path to logfile in case of file logging */
gboolean log_buffered; /**< whether logging is buffered */
guint32 log_buf_size; /**< length of log buffer */
- gchar *debug_ip_map; /**< turn on debugging for specified ip addresses */
+ const ucl_object_t *debug_ip_map; /**< turn on debugging for specified ip addresses */
gboolean log_urls; /**< whether we should log URLs */
GList *debug_symbols; /**< symbols to debug */
GHashTable *debug_modules; /**< logging modules to debug */
"Write statistics of regexp processing to log (useful for hyperscan)");
rspamd_rcl_add_default_handler (sub,
"debug_ip",
- rspamd_rcl_parse_struct_string,
+ rspamd_rcl_parse_struct_ucl,
G_STRUCT_OFFSET (struct rspamd_config, debug_ip_map),
0,
"Enable debugging log for the specified IP addresses");
return FALSE;
}
-void **
+radix_compressed_t **
rspamd_inet_library_init (void)
{
- return (void **)&local_addrs;
+ return &local_addrs;
}
void
* Opaque structure
*/
typedef struct rspamd_inet_addr_s rspamd_inet_addr_t;
+struct radix_tree_compressed;
-void **rspamd_inet_library_init (void);
+struct radix_tree_compressed **rspamd_inet_library_init (void);
void rspamd_inet_library_destroy (void);
/**
radix_destroy_compressed (rspamd->logger->debug_ip);
}
- rspamd->logger->debug_ip = radix_create_compressed ();
+ rspamd->logger->debug_ip = NULL;
- if (!rspamd_map_is_map (rspamd->cfg->debug_ip_map)) {
- radix_add_generic_iplist (rspamd->cfg->debug_ip_map,
- &rspamd->logger->debug_ip);
- }
- else {
- rspamd_map_add (rspamd->cfg, rspamd->cfg->debug_ip_map,
+ rspamd_config_radix_from_ucl (rspamd->cfg,
+ rspamd->cfg->debug_ip_map,
"IP addresses for which debug logs are enabled",
- rspamd_radix_read, rspamd_radix_fin,
- (void **) &rspamd->logger->debug_ip);
- }
+ &rspamd->logger->debug_ip, NULL);
}
else if (rspamd->logger->debug_ip) {
radix_destroy_compressed (rspamd->logger->debug_ip);
if (ctx != NULL) {
if (cfg->local_addrs) {
- if (ucl_object_type (cfg->local_addrs) == UCL_STRING &&
- !rspamd_map_is_map (ucl_object_tostring (cfg->local_addrs))) {
- radix_add_generic_iplist (ucl_object_tostring (cfg->local_addrs),
- (radix_compressed_t **)ctx->local_addrs);
- }
- else {
- rspamd_map_add_from_ucl (cfg, cfg->local_addrs,
- "Local addresses", rspamd_radix_read, rspamd_radix_fin,
- (void **) ctx->local_addrs);
- }
+ rspamd_config_radix_from_ucl (cfg, cfg->local_addrs, "Local addresses",
+ ctx->local_addrs, NULL);
}
if (cfg->ssl_ca_path) {
dkim_module_config (struct rspamd_config *cfg)
{
const ucl_object_t *value;
- const gchar *str;
gint res = TRUE, cb_id;
guint cache_size;
gboolean got_trusted = FALSE;
if ((value =
rspamd_config_get_module_opt (cfg, "dkim", "whitelist")) != NULL) {
- str = ucl_obj_tostring (value);
- if (str && !rspamd_map_is_map (str)) {
- radix_add_generic_iplist (str,
- &dkim_module_ctx->whitelist_ip);
- }
- else {
- rspamd_map_add_from_ucl (cfg, value,
- "DKIM whitelist", rspamd_radix_read, rspamd_radix_fin,
- (void **)&dkim_module_ctx->whitelist_ip);
-
- }
+ rspamd_config_radix_from_ucl (cfg, value, "DKIM whitelist",
+ &dkim_module_ctx->whitelist_ip, NULL);
}
if ((value =
rspamd_config_get_module_opt (cfg, "dkim", "domains")) != NULL) {
const ucl_object_t *value, *cur, *elt;
ucl_object_iter_t it;
gint res = TRUE, cb_id, nrules = 0;
- const gchar *str;
if (!rspamd_config_is_module_enabled (cfg, "fuzzy_check")) {
return TRUE;
if ((value =
rspamd_config_get_module_opt (cfg, "fuzzy_check",
"whitelist")) != NULL) {
- fuzzy_module_ctx->whitelist = radix_create_compressed ();
- ucl_obj_tostring (value);
-
- str = ucl_obj_tostring (value);
-
- if (str && !rspamd_map_is_map (str)) {
- radix_add_generic_iplist (str,
- &fuzzy_module_ctx->whitelist);
- }
- else {
- rspamd_map_add_from_ucl (cfg, value,
- "Fuzzy whitelist", rspamd_radix_read, rspamd_radix_fin,
- (void **)&fuzzy_module_ctx->whitelist);
-
- }
+ rspamd_config_radix_from_ucl (cfg, value, "Fuzzy whitelist",
+ &fuzzy_module_ctx->whitelist, NULL);
}
else {
fuzzy_module_ctx->whitelist = NULL;
const ucl_object_t *value;
gint res = TRUE, cb_id;
guint cache_size;
- const gchar *str;
if (!rspamd_config_is_module_enabled (cfg, "spf")) {
return TRUE;
if ((value =
rspamd_config_get_module_opt (cfg, "spf", "whitelist")) != NULL) {
- str = ucl_obj_tostring (value);
-
- if (str && !rspamd_map_is_map (str)) {
- radix_add_generic_iplist (str,
- &spf_module_ctx->whitelist_ip);
- }
- else {
- rspamd_map_add_from_ucl (cfg, value,
- "SPF whitelist", rspamd_radix_read, rspamd_radix_fin,
- (void **)&spf_module_ctx->whitelist_ip);
-
- }
+ rspamd_config_radix_from_ucl (cfg, value, "SPF whitelist",
+ &spf_module_ctx->whitelist_ip, NULL);
}
cb_id = rspamd_symbols_cache_add_symbol (cfg->cache,
#include "libutil/logger.h"
#include "libutil/http.h"
#include "libutil/upstream.h"
+#include "libutil/radix.h"
#include "libserver/url.h"
#include "libserver/protocol.h"
#include "libserver/buffer.h"
struct rspamd_external_libs_ctx {
magic_t libmagic;
- void **local_addrs;
+ radix_compressed_t **local_addrs;
struct rspamd_cryptobox_library_ctx *crypto_ctx;
struct ottery_config *ottery_cfg;
SSL_CTX *ssl_ctx;