diff options
author | Andrew Lewis <nerf@judo.za.org> | 2016-12-15 11:38:26 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2016-12-15 11:38:26 +0200 |
commit | f9de08822c9dac84c30d1e7885d1400aa584a0b1 (patch) | |
tree | f52c1d8bfb99df6833ba8574379125f8fe2ad7e8 /src/plugins/lua/dmarc.lua | |
parent | 82c29e005bb28986ab2efcb45ec17abae0a81ad2 (diff) | |
download | rspamd-f9de08822c9dac84c30d1e7885d1400aa584a0b1.tar.gz rspamd-f9de08822c9dac84c30d1e7885d1400aa584a0b1.zip |
[Minor] Avoid some table lookups in Lua parts
Diffstat (limited to 'src/plugins/lua/dmarc.lua')
-rw-r--r-- | src/plugins/lua/dmarc.lua | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index 14e7bc52d..d1adce6a1 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -54,6 +54,8 @@ local dmarc_redis_key_expire = 60 * 60 * 24 * 2 local dmarc_reporting = false local dmarc_actions = {} +local E = {} + local function gen_dmarc_grammar() local lpeg = require "lpeg" lpeg.locale(lpeg) @@ -99,7 +101,7 @@ local function dmarc_callback(task) rspamd_logger.infox(task, "skip DMARC checks for local networks and authorized users"); return end - if from and from[1] and from[1]['domain'] and not from[2] then + if ((from or E)[1] or E).domain and not (from or E)[2] then dmarc_domain = rspamd_util.get_tld(from[1]['domain']) else task:insert_result(dmarc_symbols['na'], 1.0, 'No From header') @@ -260,7 +262,7 @@ local function dmarc_callback(task) local dkim_ok = false if task:has_symbol(symbols['spf_allow_symbol']) then local efrom = task:get_from(1) - if efrom and efrom[1] and efrom[1]['domain'] then + if ((efrom or E)[1] or E).domain then if strict_spf and rspamd_util.strequal_caseless(efrom[1]['domain'], from[1]['domain']) then spf_ok = true elseif strict_spf then @@ -279,7 +281,7 @@ local function dmarc_callback(task) table.insert(reason, "No valid SPF") end local das = task:get_symbol(symbols['dkim_allow_symbol']) - if das and das[1] and das[1]['options'] then + if ((das or E)[1] or E).options then for _,dkim_domain in ipairs(das[1]['options']) do if strict_dkim and rspamd_util.strequal_caseless(from[1]['domain'], dkim_domain) then dkim_ok = true |