#include "libserver/dynamic_cfg.h"
#include "libutil/rrd.h"
#include "libutil/map.h"
+#include "libutil/map_helpers.h"
#include "libutil/map_private.h"
#include "libutil/http_private.h"
#include "libstat/stat_api.h"
gchar *ssl_key;
/* A map of secure IP */
const ucl_object_t *secure_ip;
- radix_compressed_t *secure_map;
+ struct rspamd_radix_map_helper *secure_map;
/* Static files dir */
gchar *static_files_dir;
(hdr->begin + hdr->len) - comma)) {
/* We have addr now, so check if it is still trusted */
if (ctx->secure_map &&
- radix_find_compressed_addr (ctx->secure_map,
- addr) != RADIX_NO_VALUE) {
+ rspamd_match_radix_map_addr (ctx->secure_map, addr) != NULL) {
/* rspamd_inet_address_to_string is not reentrant */
rspamd_strlcpy (ip_buf, rspamd_inet_address_to_string (addr),
sizeof (ip_buf));
if (rspamd_parse_inet_address (&addr, hdr->begin, hdr->len)) {
/* We have addr now, so check if it is still trusted */
if (ctx->secure_map &&
- radix_find_compressed_addr (ctx->secure_map,
- addr) != RADIX_NO_VALUE) {
+ rspamd_match_radix_map_addr (ctx->secure_map, addr) != NULL) {
/* rspamd_inet_address_to_string is not reentrant */
rspamd_strlcpy (ip_buf, rspamd_inet_address_to_string (addr),
sizeof (ip_buf));
}
}
else if (ctx->secure_map
- && radix_find_compressed_addr (ctx->secure_map, session->from_addr)
- != RADIX_NO_VALUE) {
+ && rspamd_match_radix_map_addr (ctx->secure_map, session->from_addr)
+ != NULL) {
ret = rspamd_controller_check_forwarded (session, msg, ctx);
if (ret == 1) {
* Rspamd fuzzy storage server
*/
-#include <libserver/rspamd_control.h>
-#include <src/libutil/map_private.h>
#include "config.h"
#include "util.h"
#include "rspamd.h"
#include "map.h"
+#include "map_helpers.h"
#include "fuzzy_wire.h"
#include "fuzzy_backend.h"
#include "ottery.h"
+#include "ref.h"
+#include "xxhash.h"
#include "libserver/worker_util.h"
#include "libserver/rspamd_control.h"
#include "libcryptobox/cryptobox.h"
#include "libcryptobox/keypairs_cache.h"
#include "libcryptobox/keypair.h"
-#include "ref.h"
-#include "xxhash.h"
+#include "libserver/rspamd_control.h"
+#include "libutil/map_private.h"
#include "libutil/hash.h"
#include "libutil/http_private.h"
#include "unix-std.h"
char *hashfile;
gdouble expire;
gdouble sync_timeout;
- radix_compressed_t *update_ips;
- radix_compressed_t *master_ips;
- radix_compressed_t *blocked_ips;
+ struct rspamd_radix_map_helper *update_ips;
+ struct rspamd_radix_map_helper *master_ips;
+ struct rspamd_radix_map_helper *blocked_ips;
struct rspamd_cryptobox_keypair *sync_keypair;
struct rspamd_cryptobox_pubkey *master_key;
rspamd_fuzzy_check_client (struct fuzzy_session *session, gboolean is_write)
{
if (session->ctx->blocked_ips != NULL) {
- if (radix_find_compressed_addr (session->ctx->update_ips,
- session->addr) != RADIX_NO_VALUE) {
+ if (rspamd_match_radix_map_addr (session->ctx->blocked_ips,
+ session->addr) != NULL) {
return FALSE;
}
}
if (is_write) {
if (session->ctx->update_ips != NULL) {
- if (radix_find_compressed_addr (session->ctx->update_ips,
- session->addr) == RADIX_NO_VALUE) {
+ if (rspamd_match_radix_map_addr (session->ctx->update_ips,
+ session->addr) == NULL) {
return FALSE;
- } else {
+ }
+ else {
return TRUE;
}
}
return;
}
- else if (radix_find_compressed_addr (ctx->master_ips, addr) == RADIX_NO_VALUE) {
+ else if (rspamd_match_radix_map_addr (ctx->master_ips, addr) == NULL) {
msg_err ("deny update request from %s",
rspamd_inet_address_to_string (addr));
rspamd_inet_address_free (addr);
#include "config.h"
#include "addr.h"
#include "util.h"
+#include "map_helpers.h"
#include "logger.h"
#include "cryptobox.h"
#include "unix-std.h"
#include <grp.h>
#endif
-static radix_compressed_t *local_addrs;
+static struct rspamd_radix_map_helper *local_addrs;
enum {
RSPAMD_IPV6_UNDEFINED = 0,
}
if (check_laddrs && local_addrs) {
- if (radix_find_compressed_addr (local_addrs, addr) != RADIX_NO_VALUE) {
+ if (rspamd_match_radix_map_addr (local_addrs, addr) != NULL) {
return TRUE;
}
}
return FALSE;
}
-radix_compressed_t **
+struct rspamd_radix_map_helper **
rspamd_inet_library_init (void)
{
return &local_addrs;
rspamd_inet_library_destroy (void)
{
if (local_addrs != NULL) {
- radix_destroy_compressed (local_addrs);
+ rspamd_map_helper_destroy_radix (local_addrs);
}
}
* Opaque structure
*/
typedef struct rspamd_inet_addr_s rspamd_inet_addr_t;
-struct radix_tree_compressed;
-struct radix_tree_compressed **rspamd_inet_library_init (void);
+struct rspamd_radix_map_helper;
+
+struct rspamd_radix_map_helper **rspamd_inet_library_init (void);
void rspamd_inet_library_destroy (void);
/**
#include "logger.h"
#include "rspamd.h"
#include "map.h"
+#include "map_helpers.h"
#include "ottery.h"
#include "unix-std.h"
pid_t pid;
guint32 repeats;
GQuark process_type;
- radix_compressed_t *debug_ip;
+ struct rspamd_radix_map_helper *debug_ip;
guint64 last_line_cksum;
gchar *saved_message;
gchar *saved_function;
if (cfg->debug_ip_map != NULL) {
/* Try to add it as map first of all */
if (logger->debug_ip) {
- radix_destroy_compressed (logger->debug_ip);
+ rspamd_map_helper_destroy_radix (logger->debug_ip);
}
logger->debug_ip = NULL;
&logger->debug_ip, NULL);
}
else if (logger->debug_ip) {
- radix_destroy_compressed (logger->debug_ip);
+ rspamd_map_helper_destroy_radix (logger->debug_ip);
logger->debug_ip = NULL;
}
if (rspamd_logger_need_log (rspamd_log, G_LOG_LEVEL_DEBUG, mod_id) ||
rspamd_log->is_debug) {
if (rspamd_log->debug_ip && addr != NULL) {
- if (radix_find_compressed_addr (rspamd_log->debug_ip, addr)
- == RADIX_NO_VALUE) {
+ if (rspamd_match_radix_map_addr (rspamd_log->debug_ip,
+ addr) == NULL) {
return;
}
}
if (rspamd_logger_need_log (rspamd_log, G_LOG_LEVEL_DEBUG, mod_id) ||
rspamd_log->is_debug) {
if (rspamd_log->debug_ip && addr != NULL) {
- if (radix_find_compressed_addr (rspamd_log->debug_ip, addr)
- == RADIX_NO_VALUE) {
+ if (rspamd_match_radix_map_addr (rspamd_log->debug_ip, addr)
+ == NULL) {
return;
}
}
guint id;
};
+struct rspamd_radix_map_helper;
+
struct rspamd_external_libs_ctx {
magic_t libmagic;
- radix_compressed_t **local_addrs;
+ struct rspamd_radix_map_helper **local_addrs;
struct rspamd_cryptobox_library_ctx *crypto_ctx;
struct ottery_config *ottery_cfg;
SSL_CTX *ssl_ctx;