aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/aws_s3.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-07-03 13:04:56 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-07-03 13:04:56 +0100
commitbcc19a2fa7d3ca07c8238530e15a4d6fe6ec3e7e (patch)
treedf14586d2d1d2c44769475d30f0d8540f7b959c2 /src/plugins/lua/aws_s3.lua
parent36ca24fd2f41e0cf0c8f28729ad36c5c7dcef19e (diff)
downloadrspamd-bcc19a2fa7d3ca07c8238530e15a4d6fe6ec3e7e.tar.gz
rspamd-bcc19a2fa7d3ca07c8238530e15a4d6fe6ec3e7e.zip
[Minor] Use upstreams in aws_s3 plugin
Diffstat (limited to 'src/plugins/lua/aws_s3.lua')
-rw-r--r--src/plugins/lua/aws_s3.lua13
1 files changed, 13 insertions, 0 deletions
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',