From 286ed38486ab5b4d1337d907b768639ec0a2fb71 Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Tue, 7 Nov 2017 18:44:09 +0200 Subject: [PATCH] [Minor] Stop expecting hostname to be "unknown" --- src/plugins/lua/dcc.lua | 4 ++-- src/plugins/lua/greylist.lua | 2 +- src/plugins/lua/hfilter.lua | 18 ++++++++---------- src/plugins/lua/multimap.lua | 2 +- src/plugins/lua/once_received.lua | 2 +- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/plugins/lua/dcc.lua b/src/plugins/lua/dcc.lua index 7995699b2..503dcce7c 100644 --- a/src/plugins/lua/dcc.lua +++ b/src/plugins/lua/dcc.lua @@ -45,7 +45,7 @@ local function check_dcc (task) client = client_ip:to_string() end local client_host = task:get_hostname() - if client_host and client_host ~= 'unknown' then + if client_host then client = client .. "\r" .. client_host end @@ -140,4 +140,4 @@ if opts and opts['host'] then }) else logger.infox('DCC module not configured'); -end \ No newline at end of file +end diff --git a/src/plugins/lua/greylist.lua b/src/plugins/lua/greylist.lua index 76d95acb2..32338f7d5 100644 --- a/src/plugins/lua/greylist.lua +++ b/src/plugins/lua/greylist.lua @@ -284,7 +284,7 @@ local function greylist_set(task) -- Third and second level domains whitelist if not is_whitelisted and whitelist_domains_map then local hostname = task:get_hostname() - if hostname and hostname ~= 'unknown' then + if hostname then local domain = rspamd_util.get_tld(hostname) if whitelist_domains_map:get_key(hostname) or (domain and whitelist_domains_map:get_key(domain)) then is_whitelisted = 'meta' diff --git a/src/plugins/lua/hfilter.lua b/src/plugins/lua/hfilter.lua index ca77dddc4..a564c1c44 100644 --- a/src/plugins/lua/hfilter.lua +++ b/src/plugins/lua/hfilter.lua @@ -307,7 +307,7 @@ local function check_host(task, host, symbol_suffix, eq_ip, eq_host) end if check_fqdn(host) then - if eq_host == '' or eq_host ~= 'unknown' or eq_host ~= host then + if eq_host == '' or eq_host ~= host then task:get_resolver():resolve('a', { task=task, name = host, @@ -462,17 +462,15 @@ local function hfilter(task) if config['hostname_enabled'] then if hostname then -- Check regexp HOSTNAME - if hostname == 'unknown' then - task:insert_result('HFILTER_HOSTNAME_UNKNOWN', 1.00) - else - local weights = checks_hellohost_map:get_key(hostname) - for _,weight in ipairs(weights or {}) do - weight = tonumber(weight) or 0 - if weight > weight_hostname then - weight_hostname = weight - end + local weights = checks_hellohost_map:get_key(hostname) + for _,weight in ipairs(weights or {}) do + weight = tonumber(weight) or 0 + if weight > weight_hostname then + weight_hostname = weight end end + else + task:insert_result('HFILTER_HOSTNAME_UNKNOWN', 1.00) end end diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index 6b27f5ff8..407a943bc 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -756,7 +756,7 @@ local function multimap_callback(task, rule) end, hostname = function() local hostname = task:get_hostname() - if hostname and hostname ~= 'unknown' then + if hostname then match_hostname(rule, hostname) end end, diff --git a/src/plugins/lua/once_received.lua b/src/plugins/lua/once_received.lua index e6dd44436..d8fae5cf1 100644 --- a/src/plugins/lua/once_received.lua +++ b/src/plugins/lua/once_received.lua @@ -90,7 +90,7 @@ local function check_quantity_received (task) local hn = task:get_hostname() -- Here we don't care about received - if (not hn or hn == 'unknown') and task_ip and task_ip:is_valid() then + if (not hn) and task_ip and task_ip:is_valid() then task:get_resolver():resolve_ptr({task = task, name = task_ip:to_string(), callback = recv_dns_cb, -- 2.39.5