diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-07-21 09:25:09 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-07-21 09:25:09 +0100 |
commit | ec3e4b6711f708b19fb3ebdb8fcb0dbef5e27e43 (patch) | |
tree | c3f3ce10f26fa94a73aab55fc73605fd9600a3e5 /src/plugins/lua/settings.lua | |
parent | 8bf2baa6bbb93760d6521012d4b51d1ea39dbd01 (diff) | |
download | rspamd-ec3e4b6711f708b19fb3ebdb8fcb0dbef5e27e43.tar.gz rspamd-ec3e4b6711f708b19fb3ebdb8fcb0dbef5e27e43.zip |
[Feature] Allow client ip match in the settings
Diffstat (limited to 'src/plugins/lua/settings.lua')
-rw-r--r-- | src/plugins/lua/settings.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index ed44e2dba..410aad7af 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) |