diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-02-12 15:02:41 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-02-12 15:02:41 +0000 |
commit | 1485bf2c42c3104696ec3a6c5e61ebe627a71c21 (patch) | |
tree | daff0411f4abfe503975ae34f29f1c6628594819 /src/lua/lua_ip.c | |
parent | a84fef624d9de5faf21bcc393cb4156c4a65a010 (diff) | |
download | rspamd-1485bf2c42c3104696ec3a6c5e61ebe627a71c21.tar.gz rspamd-1485bf2c42c3104696ec3a6c5e61ebe627a71c21.zip |
[Rework] Move local IPs check
Diffstat (limited to 'src/lua/lua_ip.c')
-rw-r--r-- | src/lua/lua_ip.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/lua/lua_ip.c b/src/lua/lua_ip.c index fb6845519..2604aa100 100644 --- a/src/lua/lua_ip.c +++ b/src/lua/lua_ip.c @@ -14,6 +14,7 @@ * limitations under the License. */ #include "lua_common.h" +#include "libserver/maps/map_helpers.h" /*** * @module rspamd_ip @@ -530,8 +531,24 @@ lua_ip_is_local (lua_State *L) check_laddrs = lua_toboolean (L, 2); } - lua_pushboolean (L, rspamd_inet_address_is_local (ip->addr, - check_laddrs)); + if ( rspamd_inet_address_is_local (ip->addr)) { + lua_pushboolean (L, true); + + return 1; + } + else if (check_laddrs) { + struct rspamd_radix_map_helper *local_addrs = + rspamd_inet_library_get_lib_ctx (); + if (local_addrs) { + if (rspamd_match_radix_map_addr (local_addrs, ip->addr) != NULL) { + lua_pushboolean (L, true); + + return 1; + } + } + } + + lua_pushboolean (L, false); } else { lua_pushnil (L); |