gchar *pid_file; /**< name of pid file */
gchar *temp_dir; /**< dir for temp files */
gchar *control_socket_path; /**< path to the control socket */
+ gchar *local_addrs; /**< tree of local addresses */
#ifdef WITH_GPERF_TOOLS
gchar *profile_path;
#endif
/* Init re cache */
rspamd_re_cache_init (cfg->re_cache, cfg);
+ /* Config other libraries */
+ rspamd_config_libs (cfg->libs_ctx, cfg);
+
/* Validate cache */
if (validate_cache) {
return rspamd_symbols_cache_validate (cfg->cache, cfg, FALSE);
#include "util.h"
#include "logger.h"
#include "xxhash.h"
-
+#include "radix.h"
#include "unix-std.h"
/* pwd and grp */
#ifdef HAVE_PWD_H
#include <grp.h>
#endif
+static radix_compressed_t *local_addrs;
enum {
RSPAMD_IPV6_UNDEFINED = 0,
return TRUE;
}
}
+
+ if (local_addrs) {
+ if (radix_find_compressed_addr (local_addrs, addr) != RADIX_NO_VALUE) {
+ return TRUE;
+ }
+ }
}
return FALSE;
}
+
+void **
+rspamd_inet_library_init (void)
+{
+ return (void **)&local_addrs;
+}
+
+void
+rspamd_inet_library_destroy (void)
+{
+ if (local_addrs != NULL) {
+ radix_destroy_compressed (local_addrs);
+ }
+}
*/
typedef struct rspamd_inet_addr_s rspamd_inet_addr_t;
+void **rspamd_inet_library_init (void);
+void rspamd_inet_library_destroy (void);
+
/**
* Create new inet address structure based on the address familiy and opaque init pointer
* @param af
#include "xxhash.h"
#include "ottery.h"
#include "cryptobox.h"
+#include "libutil/map.h"
#ifdef HAVE_OPENSSL
#include <openssl/rand.h>
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);
return ctx;
}
+void
+rspamd_config_libs (struct rspamd_external_libs_ctx *ctx,
+ struct rspamd_config *cfg)
+{
+ g_assert (ctx != NULL);
+ g_assert (cfg != NULL);
+
+ if (cfg->local_addrs) {
+ if (!rspamd_map_add (cfg, cfg->local_addrs,
+ "Local addresses", rspamd_radix_read, rspamd_radix_fin,
+ (void **) ctx->local_addrs)) {
+ radix_add_generic_iplist (cfg->local_addrs,
+ (radix_compressed_t **)ctx->local_addrs);
+ }
+ }
+}
+
void
rspamd_deinit_libs (struct rspamd_external_libs_ctx *ctx)
{
EVP_cleanup ();
ERR_free_strings ();
#endif
+ rspamd_inet_library_destroy ();
}
}
/**
* Initialize rspamd libraries
*/
-struct rspamd_external_libs_ctx* rspamd_init_libs (void);
+struct rspamd_external_libs_ctx* rspamd_init_libs ();
+
+/**
+ * Configure libraries
+ */
+void rspamd_config_libs (struct rspamd_external_libs_ctx *ctx,
+ struct rspamd_config *cfg);
/**
* Destroy external libraries context
struct rspamd_external_libs_ctx {
magic_t libmagic;
+ void **local_addrs;
ref_entry_t ref;
};