local function dmarc_callback(task)
local from = task:get_from(2)
+ local dmarc_domain
+
+ if from and from[1]['domain'] and not from[2] then
+ local url_from = rspamd_url.create(task:get_mempool(), from[1]['domain'])
+ if url_from then
+ dmarc_domain = url_from:get_tld()
+ else
+ return
+ end
+ else
+ return
+ end
local function dmarc_report_cb(task, err, data)
if not err then
task:get_resolver():resolve_txt(task:get_session(),
task:get_mempool(), '_dmarc.' .. dmarc_domain, dmarc_dns_cb)
return
- else
- return
+ end
+
+ return
end
local strict_spf = false
return
else
return
+ end
end
+
if failed_policy then return end
-- Check dkim and spf symbols
if task:get_symbol(symbols['spf_allow_symbol']) then
efrom = task:get_from(1)
if efrom and efrom[1] and efrom[1]['domain'] then
- if efrom[1]['domain'] == from[1]['domain'] then
+ if efrom[1]['domain'] == from[1]['domain'] then
+ spf_ok = true
+ elseif not strict_spf then
+ if string.sub(efrom[1]['domain'],
+ -string.len('.' .. lookup_domain))
+ == '.' .. lookup_domain then
spf_ok = true
- elseif not strict_spf then
- if string.sub(efrom[1]['domain'],
- -string.len('.' .. lookup_domain))
- == '.' .. lookup_domain then
- spf_ok = true
- end
end
+ end
end
end
local das = task:get_symbol(symbols['dkim_allow_symbol'])
elseif not strict_dkim then
if string.sub(das[1]['options'][0],
-string.len('.' .. lookup_domain))
- == '.' .. lookup_domain then
- dkim_ok = true
+ == '.' .. lookup_domain then
+ dkim_ok = true
end
end
end
-- XXX: handle rua and push data to redis
end
-
- if from and from[1]['domain'] and not from[2] then
- local url_from = rspamd_url.create(task:get_mempool(), from[1]['domain'])
- if url_from then
- dmarc_domain = url_from:get_tld()
- task:get_resolver():resolve_txt(task:get_session(), task:get_mempool(),
+
+ -- Do initial request
+ task:get_resolver():resolve_txt(task:get_session(), task:get_mempool(),
'_dmarc.' .. from[1]['domain'], dmarc_dns_cb)
- end
- end
end
local opts = rspamd_config:get_all_opt('dmarc')