From: Vsevolod Stakhov Date: Sun, 3 Jul 2022 12:04:56 +0000 (+0100) Subject: [Minor] Use upstreams in aws_s3 plugin X-Git-Tag: 3.3~145 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bcc19a2fa7d3ca07c8238530e15a4d6fe6ec3e7e;p=rspamd.git [Minor] Use upstreams in aws_s3 plugin --- 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',