aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-12 15:02:41 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-12 15:02:41 +0000
commit1485bf2c42c3104696ec3a6c5e61ebe627a71c21 (patch)
treedaff0411f4abfe503975ae34f29f1c6628594819 /src/libutil
parenta84fef624d9de5faf21bcc393cb4156c4a65a010 (diff)
downloadrspamd-1485bf2c42c3104696ec3a6c5e61ebe627a71c21.tar.gz
rspamd-1485bf2c42c3104696ec3a6c5e61ebe627a71c21.zip
[Rework] Move local IPs check
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/addr.c23
-rw-r--r--src/libutil/addr.h20
2 files changed, 23 insertions, 20 deletions
diff --git a/src/libutil/addr.c b/src/libutil/addr.c
index c0cb2d19d..4a540fefc 100644
--- a/src/libutil/addr.c
+++ b/src/libutil/addr.c
@@ -16,10 +16,6 @@
#include "config.h"
#include "addr.h"
#include "util.h"
-/*
- * TODO: fix this cross dependency!
- */
-#include "libserver/maps/map_helpers.h"
#include "logger.h"
#include "cryptobox.h"
#include "unix-std.h"
@@ -32,7 +28,7 @@
#include <grp.h>
#endif
-static struct rspamd_radix_map_helper *local_addrs;
+static void *local_addrs;
enum {
RSPAMD_IPV6_UNDEFINED = 0,
@@ -1879,8 +1875,7 @@ rspamd_inet_address_port_equal (gconstpointer a, gconstpointer b)
#endif
gboolean
-rspamd_inet_address_is_local (const rspamd_inet_addr_t *addr,
- gboolean check_laddrs)
+rspamd_inet_address_is_local (const rspamd_inet_addr_t *addr)
{
if (addr == NULL) {
return FALSE;
@@ -1904,23 +1899,23 @@ rspamd_inet_address_is_local (const rspamd_inet_addr_t *addr,
return TRUE;
}
}
-
- if (check_laddrs && local_addrs) {
- if (rspamd_match_radix_map_addr (local_addrs, addr) != NULL) {
- return TRUE;
- }
- }
}
return FALSE;
}
-struct rspamd_radix_map_helper **
+void **
rspamd_inet_library_init (void)
{
return &local_addrs;
}
+void *
+rspamd_inet_library_get_lib_ctx (void)
+{
+ return local_addrs;
+}
+
void
rspamd_inet_library_destroy (void)
{
diff --git a/src/libutil/addr.h b/src/libutil/addr.h
index 6a33ad7ec..c0910ad03 100644
--- a/src/libutil/addr.h
+++ b/src/libutil/addr.h
@@ -44,10 +44,19 @@ extern "C" {
*/
typedef struct rspamd_inet_addr_s rspamd_inet_addr_t;
-struct rspamd_radix_map_helper;
-
-struct rspamd_radix_map_helper **rspamd_inet_library_init (void);
-
+/**
+ * Returns pointer storage for global singleton (map for local addresses)
+ * @return
+ */
+void **rspamd_inet_library_init (void);
+/**
+ * Returns local addresses singleton
+ * @return
+ */
+void *rspamd_inet_library_get_lib_ctx (void);
+/**
+ * Cleanup library (currently it does nothing)
+ */
void rspamd_inet_library_destroy (void);
/**
@@ -323,8 +332,7 @@ gboolean rspamd_inet_address_port_equal (gconstpointer a, gconstpointer b);
/**
* Returns TRUE if an address belongs to some local address
*/
-gboolean rspamd_inet_address_is_local (const rspamd_inet_addr_t *addr,
- gboolean check_laddrs);
+gboolean rspamd_inet_address_is_local (const rspamd_inet_addr_t *addr);
/**
* Returns size of storage required to store a complete IP address