diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-13 13:47:53 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-13 13:47:53 +0100 |
commit | 1ccfaf0523b69bda6f34e33faaf2dc9f321abfa9 (patch) | |
tree | e36028035e9691718ce4f9d47133b5d1858983c1 /src | |
parent | bd7794a75586e2b830f386dc9ee8309117b3cc09 (diff) | |
download | rspamd-1ccfaf0523b69bda6f34e33faaf2dc9f321abfa9.tar.gz rspamd-1ccfaf0523b69bda6f34e33faaf2dc9f321abfa9.zip |
Check ipv6 in hfilter.
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/lua/hfilter.lua | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/src/plugins/lua/hfilter.lua b/src/plugins/lua/hfilter.lua index 38ed0c1e5..7a520e511 100644 --- a/src/plugins/lua/hfilter.lua +++ b/src/plugins/lua/hfilter.lua @@ -162,9 +162,17 @@ end -- eq_host: host for comparing or empty string local function check_host(task, host, symbol_suffix, eq_ip, eq_host) + local failed_address = 0 + local failed_mx_address = 0 + local function check_host_cb_mx_a(resolver, to_resolve, results, err) task:inc_dns_req() + if not results then + failed_mx_address = failed_mx_address + 1 + end + + if failed_mx_address >= 2 then task:insert_result('HFILTER_' .. symbol_suffix .. '_NORESOLVE_MX', 1.0) end end @@ -175,11 +183,16 @@ local function check_host(task, host, symbol_suffix, eq_ip, eq_host) else for _,mx in pairs(results) do if mx['name'] then - task:get_resolver():resolve_a({ + task:get_resolver():resolve('a', { task=task, name = mx['name'], callback = check_host_cb_mx_a }) + task:get_resolver():resolve('aaaa', { + task = task, + name = mx['name'], + callback = check_host_cb_mx_a + }) end end end @@ -188,18 +201,25 @@ local function check_host(task, host, symbol_suffix, eq_ip, eq_host) task:inc_dns_req() if not results then + failed_address = failed_address + 1 + else + if eq_ip ~= '' then + for _,result in pairs(results) do + if result:to_string() == eq_ip then + return true + end + end + task:insert_result('HFILTER_' .. symbol_suffix .. '_IP_A', 1.0) + end + end + + if not failed_address >= 2 then + -- No A or AAAA records task:get_resolver():resolve_mx({ - task=task, - name = host, + task = task, + name = host, callback = check_host_cb_mx }) - elseif eq_ip ~= '' then - for _,result in pairs(results) do - if result:to_string() == eq_ip then - return true - end - end - task:insert_result('HFILTER_' .. symbol_suffix .. '_IP_A', 1.0) end end @@ -216,11 +236,17 @@ local function check_host(task, host, symbol_suffix, eq_ip, eq_host) if check_fqdn(host) then if eq_host == '' or eq_host ~= 'unknown' or eq_host ~= host then - task:get_resolver():resolve_a({ + task:get_resolver():resolve('a', { task=task, name = host, callback = check_host_cb_a }) + -- Check ipv6 as well + task:get_resolver():resolve('aaaa', { + task = task, + name = host, + callback = check_host_cb_a + }) end else task:insert_result('HFILTER_' .. symbol_suffix .. '_NOT_FQDN', 1.0) |