]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Register more timeouts
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 10 Sep 2022 12:47:54 +0000 (13:47 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 10 Sep 2022 12:47:54 +0000 (13:47 +0100)
13 files changed:
src/plugins/lua/bimi.lua
src/plugins/lua/clustering.lua
src/plugins/lua/elastic.lua
src/plugins/lua/history_redis.lua
src/plugins/lua/metadata_exporter.lua
src/plugins/lua/mx_check.lua
src/plugins/lua/p0f.lua
src/plugins/lua/ratelimit.lua
src/plugins/lua/rbl.lua
src/plugins/lua/reputation.lua
src/plugins/lua/settings.lua
src/plugins/lua/spf.lua
src/plugins/lua/url_redirector.lua

index 405477c621c01d0c91f77abf215ae8a86abb7a9e..bcf5a823dc04ebf77c4dafc7abf16f993e046c6b 100644 (file)
@@ -365,6 +365,8 @@ if redis_params then
     name = 'BIMI_CHECK',
     type = 'normal',
     callback = bimi_callback,
+    augmentations = {string.format("timeout=%f", settings.helper_timeout or
+        redis_params.timeout or 0.0)}
   })
   rspamd_config:register_symbol{
     name = 'BIMI_VALID',
index 3e546f8171ff0578fbc140df5fda25631e64fb5a..3a8a361b1ceaf3dcc46296b742de605995c90a20 100644 (file)
@@ -301,6 +301,7 @@ if opts['rules'] then
         type = 'idempotent',
         flags = 'empty,explicit_disable,ignore_passthrough',
         callback = callback_gen(clusterting_idempotent_cb, rule),
+        augmentations = {string.format("timeout=%f", redis_params.timeout or 0.0)}
       }
     end
   else
index 3fffd6612a0127e19ff2b155f7c38f4084362476..5578d48ec6cdbb2cdd777c25a4c8d63d04570999 100644 (file)
@@ -519,6 +519,7 @@ if redis_params and opts then
       callback = elastic_collect,
       priority = 10,
       flags = 'empty,explicit_disable,ignore_passthrough',
+      augmentations = {string.format("timeout=%f", settings.timeout)},
     })
 
     rspamd_config:add_on_load(function(cfg, ev_base,worker)
index b8bd9466a6a100e17a375def90508d7fcda8bf20..35bfb9242b4b20a89145506ff221998eaf773517 100644 (file)
@@ -290,7 +290,8 @@ if opts then
       type = 'idempotent',
       callback = history_save,
       flags = 'empty,explicit_disable,ignore_passthrough',
-      priority = 150
+      priority = 150,
+      augmentations = {string.format("timeout=%f", redis_params.timeout or 0.0)}
     })
     lua_redis.register_prefix(settings.key_prefix .. hostname, N,
         "Redis history", {
index d72454f861681b54f4297eeabf7cceca20e7168c..c5f4ca1485fab38bf5c452c11aeb42da9dc05d20 100644 (file)
@@ -484,6 +484,7 @@ if type(settings.rules) ~= 'table' then
       r.defer = settings.defer
       r.selector = settings.pusher_select.redis_pubsub
       r.formatter = settings.pusher_format.redis_pubsub
+      r.timeout = redis_params.timeout
       settings.rules[r.backend:upper()] = r
     end
   end
@@ -499,6 +500,7 @@ if type(settings.rules) ~= 'table' then
       r.defer = settings.defer
       r.selector = settings.pusher_select.http
       r.formatter = settings.pusher_format.http
+      r.timeout = settings.timeout or 0.0
       settings.rules[r.backend:upper()] = r
     end
   end
@@ -516,6 +518,7 @@ if type(settings.rules) ~= 'table' then
       r.smtp_port = settings.smtp_port
       r.email_template = settings.email_template
       r.defer = settings.defer
+      r.timeout = settings.timeout or 0.0
       r.selector = settings.pusher_select.send_mail
       r.formatter = settings.pusher_format.send_mail
       settings.rules[r.backend:upper()] = r
@@ -593,6 +596,7 @@ backend_check.redis_pubsub = function(k, rule)
     settings.rules[k] = nil
   else
     backend_check.default(k, rule)
+    rule.timeout = redis_params.timeout
   end
 end
 setmetatable(backend_check, {
@@ -650,5 +654,6 @@ for k, r in pairs(settings.rules) do
     callback = gen_exporter(r),
     priority = 10,
     flags = 'empty,explicit_disable,ignore_passthrough',
+    augmentations = {string.format("timeout=%f", r.timeout or 0.0)}
   })
 end
index bd55cdd8fe3f174a79b04674fbe47d3456b20519..cea636dfc794458331e5db220ea77f6b6a000f63 100644 (file)
@@ -315,6 +315,7 @@ if opts then
     type = 'normal',
     callback = mx_check,
     flags = 'empty',
+    augmentations = {string.format("timeout=%f", settings.timeout + rspamd_config:get_dns_timeout() or 0.0)},
   })
   rspamd_config:register_symbol({
     name = settings.symbol_no_mx,
index d9e91da0fa5ab546fe092131e0aed7bb4016a59c..a07b1ee00db08d609af470150fdfdc5d2f6b1b27 100644 (file)
@@ -89,7 +89,9 @@ if rule then
     callback = check_p0f,
     priority = 8,
     flags = 'empty,nostat',
-    group = N
+    group = N,
+    augmentations = {string.format("timeout=%f", rule.timeout or 0.0)},
+
   })
 
   if rule.symbol then
index 1c19d890c62889e9740bd1e090c4709d48f617f0..2b61b606f26726821cf92e44df4ed8b28a67dcfa 100644 (file)
@@ -871,6 +871,7 @@ if opts then
       priority = 7,
       callback = ratelimit_cb,
       flags = 'empty,nostat',
+      augmentations = {string.format("timeout=%f", redis_params.timeout or 0.0)},
     }
 
     local id = rspamd_config:register_symbol(s)
@@ -914,6 +915,7 @@ if opts then
       name = 'RATELIMIT_UPDATE',
       flags = 'explicit_disable,ignore_passthrough',
       callback = ratelimit_update_cb,
+      augmentations = {string.format("timeout=%f", redis_params.timeout or 0.0)},
     }
   end
 end
index 890ceb232e06d11b457eb886f6bc364ed94d02bb..dd69ccd67c7125444aa55386f7222d2585d87eb4 100644 (file)
@@ -1283,14 +1283,16 @@ rspamd_config:register_symbol{
   type = 'callback',
   callback = rbl_callback_white,
   name = 'RBL_CALLBACK_WHITE',
-  flags = 'nice,empty,no_squeeze'
+  flags = 'nice,empty,no_squeeze',
+  augmentations = {string.format("timeout=%f", rspamd_config:get_dns_timeout() or 0.0)},
 }
 
 rspamd_config:register_symbol{
   type = 'callback',
   callback = rbl_callback_fin,
   name = 'RBL_CALLBACK',
-  flags = 'empty,no_squeeze'
+  flags = 'empty,no_squeeze',
+  augmentations = {string.format("timeout=%f", rspamd_config:get_dns_timeout() or 0.0)},
 }
 
 for _, w in ipairs(white_symbols) do
index 6b7a703d6746c59e5964f45754cd069239614efd..3db6c52c7498b1fccc375a8ea5160513746b43e5 100644 (file)
@@ -1302,6 +1302,7 @@ local function parse_rule(name, tbl)
     name = rule.symbol,
     type = rule_type,
     callback = callback_gen(reputation_filter_cb, rule),
+    augmentations = {string.format("timeout=%f", redis_params.timeout or 0.0)},
   }
 
   if rule.selector.config.split_symbols then
@@ -1330,6 +1331,7 @@ local function parse_rule(name, tbl)
       type = 'postfilter',
       flags = 'nostat,explicit_disable,ignore_passthrough',
       callback = callback_gen(reputation_postfilter_cb, rule),
+      augmentations = {string.format("timeout=%f", redis_params.timeout or 0.0)},
     }
   end
 
@@ -1340,6 +1342,7 @@ local function parse_rule(name, tbl)
       type = 'idempotent',
       flags = 'explicit_disable,ignore_passthrough',
       callback = callback_gen(reputation_idempotent_cb, rule),
+      augmentations = {string.format("timeout=%f", redis_params.timeout or 0.0)},
     }
   end
 
index 94e1b23270c32c043d0c5ca1309f186eb59095b8..d8f0997f1083663587c6f4ad0b0072e151281d18 100644 (file)
@@ -1230,6 +1230,7 @@ if redis_section then
       callback = gen_redis_callback(h, id),
       priority = 10,
       flags = 'empty,nostat',
+      augmentations = {string.format("timeout=%f", redis_params.timeout or 0.0)},
     })
   end, redis_key_handlers)
 end
index c8aeb971b365b1a5465a8dc392f23abbc1aed534..997c07bcaa83ba6d97f8b13760f75ac19de00233 100644 (file)
@@ -209,7 +209,11 @@ local sym_id = rspamd_config:register_symbol{
   flags = 'fine,empty',
   groups = {'policies','spf'},
   score = 0.0,
-  callback = spf_check_callback
+  callback = spf_check_callback,
+  -- We can merely estimate timeout here, as it is possible to construct an SPF record that would cause
+  -- many DNS requests. But we won't like to set the maximum value for that all the time, as
+  -- the majority of requests will typically have 1-4 subrequests
+  augmentations = {string.format("timeout=%f", rspamd_config:get_dns_timeout() * 4 or 0.0)},
 }
 
 if local_config.whitelist then
index 53987ad623592e81e2c80cfe51101e3739027158..bc054ec69ffa3ae6cf9a30514ed924a1f2b39488 100644 (file)
@@ -357,6 +357,8 @@ if opts then
         name = 'URL_REDIRECTOR_CHECK',
         type = 'callback,prefilter',
         callback = url_redirector_handler,
+        -- In fact, the real timeout is nested_limit * timeout...
+        augmentations = {string.format("timeout=%f", settings.timeout)}
       }
 
       if settings.redirector_symbol then