commit bcc19a2: [Minor] Use upstreams in aws_s3 plugin

Vsevolod Stakhov vsevolod at rspamd.com
Sun Jul 3 12:07:04 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-07-03 13:04:56 +0100
URL: https://github.com/rspamd/rspamd/commit/bcc19a2fa7d3ca07c8238530e15a4d6fe6ec3e7e (HEAD -> master)

[Minor] Use upstreams in aws_s3 plugin

---
 src/plugins/lua/aws_s3.lua | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/plugins/lua/aws_s3.lua b/src/plugins/lua/aws_s3.lua
index 6f9f74c06..3bce7913c 100644
--- a/src/plugins/lua/aws_s3.lua
+++ b/src/plugins/lua/aws_s3.lua
@@ -197,6 +197,7 @@ local function s3_aws_callback(task)
       body = content,
       callback = gen_s3_http_callback(path, 'structured message'),
       headers = hdrs,
+      upstream = settings.upstreams:get_upstream_round_robin(),
       timeout = settings.s3_timeout,
     })
 
@@ -215,6 +216,7 @@ local function s3_aws_callback(task)
       rspamd_http.request({
         url = uri .. ref,
         task = task,
+        upstream = settings.upstreams:get_upstream_round_robin(),
         method = 'PUT',
         body = part_content,
         callback = gen_s3_http_callback(ref, 'part content'),
@@ -244,6 +246,17 @@ end
 rspamd_logger.infox(rspamd_config, 'enabled AWS s3 dump to %s', res.s3_bucket)
 
 settings = res
+
+settings.upstreams = lua_util.http_upstreams_by_url(rspamd_config:get_mempool(),
+    string.format('https://%s.%s', settings.s3_bucket, settings.s3_host))
+
+if not settings.upstreams then
+  rspamd_logger.warnx(rspamd_config, 'cannot parse hostname: %s',
+      string.format('https://%s.%s', settings.s3_bucket, settings.s3_host))
+  lua_util.disable_module(N, "config")
+  return
+end
+
 rspamd_config:register_symbol({
   name = 'EXPORT_AWS_S3',
   type = settings.fail_action and 'postfilter' or 'idempotent',


More information about the Commits mailing list