diff options
author | Carsten Rosenberg <c.rosenberg@heinlein-support.de> | 2019-09-26 21:44:30 +0200 |
---|---|---|
committer | Carsten Rosenberg <c.rosenberg@heinlein-support.de> | 2019-09-26 21:44:30 +0200 |
commit | 46b76b3bad6b12f83d79819eee51d020bb08f207 (patch) | |
tree | c291218d015d25884ad3ad3b2a3fb92f9fe7eda7 /lualib/lua_scanners/spamassassin.lua | |
parent | 9d46c4f47925cbe49c920eaf4560064336cb4e38 (diff) | |
download | rspamd-46b76b3bad6b12f83d79819eee51d020bb08f207.tar.gz rspamd-46b76b3bad6b12f83d79819eee51d020bb08f207.zip |
[Minor] lua_scanners - align module structure
Diffstat (limited to 'lualib/lua_scanners/spamassassin.lua')
-rw-r--r-- | lualib/lua_scanners/spamassassin.lua | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/lualib/lua_scanners/spamassassin.lua b/lualib/lua_scanners/spamassassin.lua index 2227de235..860df42dd 100644 --- a/lualib/lua_scanners/spamassassin.lua +++ b/lualib/lua_scanners/spamassassin.lua @@ -28,6 +28,62 @@ local common = require "lua_scanners/common" local N = 'spamassassin' +local function spamassassin_config(opts) + + local spamassassin_conf = { + N = N, + scan_mime_parts = false, + scan_text_mime = false, + scan_image_mime = false, + default_port = 783, + timeout = 15.0, + log_clean = false, + retransmits = 2, + cache_expire = 3600, -- expire redis in one hour + symbol = "SPAMD", + message = '${SCANNER}: Spamassassin bulk message found: "${VIRUS}"', + detection_category = "spam", + default_score = 1, + action = false, + extended = false, + symbol_type = 'postfilter', + dynamic_scan = true, + } + + spamassassin_conf = lua_util.override_defaults(spamassassin_conf, opts) + + if not spamassassin_conf.prefix then + spamassassin_conf.prefix = 'rs_' .. spamassassin_conf.name .. '_' + end + + if not spamassassin_conf.log_prefix then + if spamassassin_conf.name:lower() == spamassassin_conf.type:lower() then + spamassassin_conf.log_prefix = spamassassin_conf.name + else + spamassassin_conf.log_prefix = spamassassin_conf.name .. ' (' .. spamassassin_conf.type .. ')' + end + end + + if not spamassassin_conf.servers then + rspamd_logger.errx(rspamd_config, 'no servers defined') + + return nil + end + + spamassassin_conf.upstreams = upstream_list.create(rspamd_config, + spamassassin_conf.servers, + spamassassin_conf.default_port) + + if spamassassin_conf.upstreams then + lua_util.add_debug_alias('external_services', spamassassin_conf.N) + return spamassassin_conf + end + + rspamd_logger.errx(rspamd_config, 'cannot parse servers %s', + spamassassin_conf.servers) + return nil +end + local function spamassassin_check(task, content, digest, rule) local function spamassassin_check_uncached () local upstream = rule.upstreams:get_upstream_round_robin() @@ -162,62 +218,6 @@ local function spamassassin_check(task, content, digest, rule) end end -local function spamassassin_config(opts) - - local spamassassin_conf = { - N = N, - scan_mime_parts = false, - scan_text_mime = false, - scan_image_mime = false, - default_port = 783, - timeout = 15.0, - log_clean = false, - retransmits = 2, - cache_expire = 3600, -- expire redis in one hour - symbol = "SPAMD", - message = '${SCANNER}: Spamassassin bulk message found: "${VIRUS}"', - detection_category = "spam", - default_score = 1, - action = false, - extended = false, - symbol_type = 'postfilter', - dynamic_scan = true, - } - - spamassassin_conf = lua_util.override_defaults(spamassassin_conf, opts) - - if not spamassassin_conf.prefix then - spamassassin_conf.prefix = 'rs_' .. spamassassin_conf.name .. '_' - end - - if not spamassassin_conf.log_prefix then - if spamassassin_conf.name:lower() == spamassassin_conf.type:lower() then - spamassassin_conf.log_prefix = spamassassin_conf.name - else - spamassassin_conf.log_prefix = spamassassin_conf.name .. ' (' .. spamassassin_conf.type .. ')' - end - end - - if not spamassassin_conf.servers then - rspamd_logger.errx(rspamd_config, 'no servers defined') - - return nil - end - - spamassassin_conf.upstreams = upstream_list.create(rspamd_config, - spamassassin_conf.servers, - spamassassin_conf.default_port) - - if spamassassin_conf.upstreams then - lua_util.add_debug_alias('external_services', spamassassin_conf.N) - return spamassassin_conf - end - - rspamd_logger.errx(rspamd_config, 'cannot parse servers %s', - spamassassin_conf.servers) - return nil -end - return { type = {N,'spam', 'scanner'}, description = 'spamassassin spam scanner', |