From: Vsevolod Stakhov Date: Sat, 10 Sep 2022 12:26:32 +0000 (+0100) Subject: [Minor] Register some more timeouts X-Git-Tag: 3.3~38 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=57e500a029fe4e8e3ba6575450998618a2f60d13;p=rspamd.git [Minor] Register some more timeouts --- diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua index bd7c2dd29..454629bba 100644 --- a/lualib/lua_util.lua +++ b/lualib/lua_util.lua @@ -1521,4 +1521,15 @@ end --]]] exports.http_upstreams_by_url = http_upstreams_by_url +---[[[ +-- @function lua_util.dns_timeout_augmentation(cfg) +-- Returns an augmentation suitable to define DNS timeout for a module +-- @return {string} a string in format 'timeout=x' where `x` is a number of seconds for DNS timeout +--]]] +local function dns_timeout_augmentation(cfg) + return string.format('timeout=%f', cfg:get_dns_timeout() or 0.0) +end + +exports.dns_timeout_augmentation = dns_timeout_augmentation + return exports diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua index b2baa4a11..871d64b43 100644 --- a/src/plugins/lua/arc.lua +++ b/src/plugins/lua/arc.lua @@ -802,6 +802,7 @@ if settings.whitelisted_signers_map then score = -2.0, group = 'policies', groups = {'arc'}, + augmentations = {lua_util.dns_timeout_augmentation(rspamd_config)}, }) end diff --git a/src/plugins/lua/asn.lua b/src/plugins/lua/asn.lua index aa281d781..7f2bfea6b 100644 --- a/src/plugins/lua/asn.lua +++ b/src/plugins/lua/asn.lua @@ -145,6 +145,7 @@ if configure_asn_module() then callback = asn_check, priority = 8, flags = 'empty,nostat', + augmentations = {lua_util.dns_timeout_augmentation(rspamd_config)}, }) if options['symbol'] then rspamd_config:register_symbol({ diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index 8a40bb800..b8f418abd 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -1469,6 +1469,7 @@ if opts then callback = clickhouse_collect, priority = 10, flags = 'empty,explicit_disable,ignore_passthrough', + augmentations = {string.format("timeout=%f", settings.timeout)}, }) rspamd_config:register_finish_script(function(task) if nrows > 0 then diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index 2d00bad10..99d909154 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -657,7 +657,8 @@ if settings.munging then score = 0, group = 'policies', groups = {'dmarc'}, - callback = dmarc_common.gen_munging_callback(munging_opts, settings) + callback = dmarc_common.gen_munging_callback(munging_opts, settings), + augmentations = {lua_util.dns_timeout_augmentation(rspamd_config)}, }) rspamd_config:register_dependency('DMARC_MUNGED', 'DMARC_CHECK') diff --git a/src/plugins/lua/hfilter.lua b/src/plugins/lua/hfilter.lua index 18205e37e..f68d5b579 100644 --- a/src/plugins/lua/hfilter.lua +++ b/src/plugins/lua/hfilter.lua @@ -551,6 +551,7 @@ local auth_and_local_conf = lua_util.config_check_local_or_authed(rspamd_config, false, false) check_local = auth_and_local_conf[1] check_authed = auth_and_local_conf[2] +local timeout = 0.0 local opts = rspamd_config:get_all_opt('hfilter') if opts then @@ -568,15 +569,18 @@ if config['helo_enabled'] then checks_hellohost_map = add_static_map(checks_hellohost) checks_hello_map = add_static_map(checks_hello) append_t(symbols_enabled, symbols_helo) + timeout = math.max(timeout, rspamd_config:get_dns_timeout() * 3) end if config['hostname_enabled'] then if not checks_hellohost_map then checks_hellohost_map = add_static_map(checks_hellohost) end append_t(symbols_enabled, symbols_hostname) + timeout = math.max(timeout, rspamd_config:get_dns_timeout()) end if config['from_enabled'] then append_t(symbols_enabled, symbols_from) + timeout = math.max(timeout, rspamd_config:get_dns_timeout()) end if config['rcpt_enabled'] then append_t(symbols_enabled, symbols_rcpt) @@ -594,6 +598,7 @@ if #symbols_enabled > 0 then name = 'HFILTER_CHECK', callback = hfilter_callback, type = 'callback', + augmentations = {string.format("timeout=%f", timeout)}, } for _,sym in ipairs(symbols_enabled) do rspamd_config:register_symbol{