local rspamd_logger = require "rspamd_logger"
+local function validate_dns(lstr, rstr)
+ if (lstr:len() + rstr:len()) > 252 then
+ return false
+ end
+ for v in lstr:gmatch("[^%.]+") do
+ if not v:match("^[%w%.-]+$") or v:len() > 63
+ or v:match("^-") or v:match("-$") then
+ return false
+ end
+ end
+ return true
+end
+
local function ip_to_rbl(ip, rbl)
return table.concat(ip:inversed_str_octets(), ".") .. '.' .. rbl
end
end
if not havegot['helo'] then
havegot['helo'] = task:get_helo()
- if havegot['helo'] == nil or string.sub(havegot['helo'],1,1) == '[' then
+ if havegot['helo'] == nil or
+ not validate_dns(havegot['helo'], rbl['rbl']) then
notgot['helo'] = true
return
end