From: Vsevolod Stakhov Date: Thu, 21 Jul 2016 08:25:09 +0000 (+0100) Subject: [Feature] Allow client ip match in the settings X-Git-Tag: 1.3.0~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ec3e4b6711f708b19fb3ebdb8fcb0dbef5e27e43;p=thirdparty%2Frspamd.git [Feature] Allow client ip match in the settings --- diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index ed44e2dba5..410aad7af1 100644 --- a/src/plugins/lua/settings.lua +++ b/src/plugins/lua/settings.lua @@ -139,7 +139,7 @@ local function check_settings(task) return false end - local function check_specific_setting(name, rule, ip, from, rcpt, user) + local function check_specific_setting(name, rule, ip, client_ip, from, rcpt, user) local res = false if rule['ip'] then @@ -157,6 +157,21 @@ local function check_settings(task) end end + if rule['client_ip'] then + if not client_ip or not client_ip:is_valid() then + return nil + end + for _, i in ipairs(rule['client_ip']) do + res = check_ip_setting(i, client_ip) + if res then + break + end + end + if not res then + return nil + end + end + if rule['from'] then if not from then return nil @@ -225,6 +240,7 @@ local function check_settings(task) rspamd_logger.infox(task, "check for settings") local ip = task:get_from_ip() + local client_ip = task:get_client_ip() local from = task:get_from() local rcpt = task:get_recipients() local uname = task:get_user() @@ -246,7 +262,7 @@ local function check_settings(task) for pri = max_pri,1,-1 do if settings[pri] then for name, r in pairs(settings[pri]) do - local rule = check_specific_setting(name, r, ip, from, rcpt, user) + local rule = check_specific_setting(name, r, ip, client_ip, from, rcpt, user) if rule then rspamd_logger.infox(task, "<%1> apply settings according to rule %2", task:get_message_id(), name)