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
--HOSTNAME--
local hostname = task:get_hostname()
- if hostname and ip and hostname == '[' .. ip .. ']' then
- hostname = false
- end
--HELO--
local helo = task:get_helo()
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
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;
}
}