aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
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/libserver
parenta84fef624d9de5faf21bcc393cb4156c4a65a010 (diff)
downloadrspamd-1485bf2c42c3104696ec3a6c5e61ebe627a71c21.tar.gz
rspamd-1485bf2c42c3104696ec3a6c5e61ebe627a71c21.zip
[Rework] Move local IPs check
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/cfg_file.h6
-rw-r--r--src/libserver/cfg_utils.c25
2 files changed, 30 insertions, 1 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 4a8ab5bfc..1d782dd8b 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -846,6 +846,12 @@ gboolean rspamd_libs_reset_compression (struct rspamd_external_libs_ctx *ctx);
void rspamd_deinit_libs (struct rspamd_external_libs_ctx *ctx);
/**
+ * Returns TRUE if an address belongs to some local address
+ */
+gboolean rspamd_ip_is_local_cfg (struct rspamd_config *cfg,
+ const rspamd_inet_addr_t *addr);
+
+/**
* Configure libraries
*/
gboolean rspamd_config_libs (struct rspamd_external_libs_ctx *ctx,
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 204e9bd55..d8237b88e 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -2998,4 +2998,27 @@ rspamd_deinit_libs (struct rspamd_external_libs_ctx *ctx)
g_free (ctx);
}
-} \ No newline at end of file
+}
+
+gboolean
+rspamd_ip_is_local_cfg (struct rspamd_config *cfg,
+ const rspamd_inet_addr_t *addr)
+{
+ struct rspamd_radix_map_helper *local_addrs = NULL;
+
+ if (cfg && cfg->libs_ctx) {
+ local_addrs = *(struct rspamd_radix_map_helper**)cfg->libs_ctx->local_addrs;
+ }
+
+ if (rspamd_inet_address_is_local (addr)) {
+ return TRUE;
+ }
+
+ if (local_addrs) {
+ if (rspamd_match_radix_map_addr (local_addrs, addr) != NULL) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}