diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-01-22 14:23:02 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-01-22 14:23:02 +0000 |
commit | 199b32be13c152cd501a772d23c25f45605b6cff (patch) | |
tree | 64e10f24a44cc94b7a538f22322ccc1d1c68f0d0 | |
parent | 253eeb9b99fe588e3ed1ef08ec2343e4ee821653 (diff) | |
download | rspamd-199b32be13c152cd501a772d23c25f45605b6cff.tar.gz rspamd-199b32be13c152cd501a772d23c25f45605b6cff.zip |
Improve hostname processing.
-rw-r--r-- | conf/lua/hfilter.lua | 12 | ||||
-rw-r--r-- | src/lua/lua_task.c | 16 |
2 files changed, 19 insertions, 9 deletions
diff --git a/conf/lua/hfilter.lua b/conf/lua/hfilter.lua index 967953157..f0c4748a8 100644 --- a/conf/lua/hfilter.lua +++ b/conf/lua/hfilter.lua @@ -134,12 +134,10 @@ local function check_host(task, host, symbol_suffix, eq_ip, eq_host) end if eq_host then eq_host = string.lower(eq_host) - else - eq_host = '' end if check_fqdn(host) then - if eq_host == '' or eq_host ~= host then + if not eq_host or (eq_host ~= 'unknown' or eq_host ~= host) then task:get_resolver():resolve_a(task:get_session(), task:get_mempool(), host, check_host_cb_a) end else @@ -169,9 +167,6 @@ local function hfilter(task) --HOSTNAME-- local hostname = task:get_hostname() - if hostname and ip and hostname == '[' .. ip .. ']' then - hostname = false - end --HELO-- local helo = task:get_helo() @@ -218,8 +213,9 @@ local function hfilter(task) break end end - else - task:insert_result('HFILTER_HOSTNAME_NOPTR', 1.00) + if hostname == 'unknown' then + task:insert_result('HFILTER_HOSTNAME_NOPTR', 1.00) + end end --Insert weight's for HELO or HOSTNAME diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index a9e0d5433..73da200ad 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -1067,7 +1067,21 @@ lua_task_get_hostname (lua_State *L) if (task) { if (task->hostname != NULL) { - lua_pushstring (L, (gchar *)task->hostname); + /* Check whether it looks like an IP address */ + if (*task->hostname == '[') { + /* + * From the milter documentation: + * If the reverse lookup fails or if none of the IP + * addresses of the resolved host name matches the + * original IP address, hostname will contain the + * message sender's IP address enclosed in square + * brackets (e.g. `[a.b.c.d]') + */ + lua_pushstring (L, "unknown"); + } + else { + lua_pushstring (L, task->hostname); + } return 1; } } |