]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Register some more timeouts
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 10 Sep 2022 12:26:32 +0000 (13:26 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 10 Sep 2022 12:26:32 +0000 (13:26 +0100)
lualib/lua_util.lua
src/plugins/lua/arc.lua
src/plugins/lua/asn.lua
src/plugins/lua/clickhouse.lua
src/plugins/lua/dmarc.lua
src/plugins/lua/hfilter.lua

index bd7c2dd29223e6882c0a136fe423fa3e16763420..454629bbae0395573cf97acee7e442b5b7a5bab1 100644 (file)
@@ -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
index b2baa4a11d3e10fd00a4c6fbd4befaced8fad67c..871d64b43f8a3f86c624c9971acb61111bc5bca1 100644 (file)
@@ -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
 
index aa281d7811eb84d80d76b027c1c6eef4b19f06ab..7f2bfea6b379b3fd1a4f4c547a4444c1753dfbf7 100644 (file)
@@ -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({
index 8a40bb80076e0b149b88d10626532044e2f94acd..b8f418abd8a3c5da39895f7c1db7a3880fc76038 100644 (file)
@@ -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
index 2d00bad10b41233a7bc0aa4c4e2dcfc7f3bf765a..99d909154f05618bbbab61c2b37032087aa9be84 100644 (file)
@@ -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')
index 18205e37eae4d64e2909dfc5284cbe4a9aaf5257..f68d5b5797f178fce1beb108ef175d44c78c5963 100644 (file)
@@ -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{