#endif
gboolean
-rspamd_inet_address_is_local (const rspamd_inet_addr_t *addr)
+rspamd_inet_address_is_local (const rspamd_inet_addr_t *addr,
+ gboolean check_laddrs)
{
if (addr == NULL) {
return FALSE;
}
}
- if (local_addrs) {
+ if (check_laddrs && local_addrs) {
if (radix_find_compressed_addr (local_addrs, addr) != RADIX_NO_VALUE) {
return TRUE;
}
/**
* Returns TRUE if an address belongs to some local address
*/
-gboolean rspamd_inet_address_is_local (const rspamd_inet_addr_t *addr);
+gboolean rspamd_inet_address_is_local (const rspamd_inet_addr_t *addr,
+ gboolean check_laddrs);
/**
* Returns size of storage required to store a complete IP address
lua_ip_is_local (lua_State *L)
{
struct rspamd_lua_ip *ip = lua_check_ip (L, 1);
+ gboolean check_laddrs = TRUE;
if (ip && ip->addr) {
- lua_pushboolean (L, rspamd_inet_address_is_local (ip->addr));
+
+ if (lua_type (L, 2) == LUA_TBOOLEAN) {
+ check_laddrs = lua_toboolean (L, 2);
+ }
+
+ lua_pushboolean (L, rspamd_inet_address_is_local (ip->addr,
+ check_laddrs));
}
else {
lua_pushnil (L);
/* First check if plugin should be enabled */
if ((!dkim_module_ctx->check_authed && task->user != NULL)
- || (!dkim_module_ctx->check_local && rspamd_inet_address_is_local (task->from_addr))) {
+ || (!dkim_module_ctx->check_local &&
+ rspamd_inet_address_is_local (task->from_addr, TRUE))) {
msg_info_task ("skip DKIM checks for local networks and authorized users");
return;
}
}
if ((!spf_module_ctx->check_authed && task->user != NULL)
- || (!spf_module_ctx->check_local && rspamd_inet_address_is_local (task->from_addr))) {
+ || (!spf_module_ctx->check_local &&
+ rspamd_inet_address_is_local (task->from_addr, TRUE))) {
msg_info_task ("skip SPF checks for local networks and authorized users");
return;
}
}
if (m->local ||
- rspamd_inet_address_is_local (rspamd_upstream_addr (bk_conn->up))) {
+ rspamd_inet_address_is_local (
+ rspamd_upstream_addr (bk_conn->up), FALSE)) {
if (session->fname) {
rspamd_http_message_add_header (msg, "File", session->fname);
if (backend->local ||
rspamd_inet_address_is_local (
- rspamd_upstream_addr (session->master_conn->up))) {
+ rspamd_upstream_addr (session->master_conn->up), FALSE)) {
if (session->fname) {
rspamd_http_message_add_header (msg, "File", session->fname);