aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbradleydoherty59 <bradleydoherty59@gmail.com>2021-11-05 14:01:12 -0500
committerbradleydoherty59 <bradleydoherty59@gmail.com>2021-11-05 14:01:12 -0500
commite401747c7920e6ac5fe9a50e0a2c6a2750f13cd3 (patch)
tree5de2a73c58802c7a662ed4c30ed1a13aefc921e5
parentdeddef726c54c8dda758a726a9a75cc8db30ac9a (diff)
downloadrspamd-e401747c7920e6ac5fe9a50e0a2c6a2750f13cd3.tar.gz
rspamd-e401747c7920e6ac5fe9a50e0a2c6a2750f13cd3.zip
[Config] Allow configurable s3 urls
-rw-r--r--conf/modules.d/aws_s3.conf1
-rw-r--r--src/plugins/lua/aws_s3.lua6
2 files changed, 5 insertions, 2 deletions
diff --git a/conf/modules.d/aws_s3.conf b/conf/modules.d/aws_s3.conf
index 2dd966374..bef592aa9 100644
--- a/conf/modules.d/aws_s3.conf
+++ b/conf/modules.d/aws_s3.conf
@@ -16,6 +16,7 @@ aws_s3 {
# Required attributes
#s3_bucket = 'xxx';
s3_region = 'us-east-1';
+ s3_host = 's3.amazonaws.com';
#s3_secret_key = 'xxx';
#s3_key_id = 'xxx';
# Enable in local.d/aws_s3.conf
diff --git a/src/plugins/lua/aws_s3.lua b/src/plugins/lua/aws_s3.lua
index 7ec65eb5b..1a7873086 100644
--- a/src/plugins/lua/aws_s3.lua
+++ b/src/plugins/lua/aws_s3.lua
@@ -26,6 +26,7 @@ local rspamd_util = require "rspamd_util"
local settings = {
s3_bucket = nil,
s3_region = 'us-east-1',
+ s3_host = 's3.amazonaws.com',
s3_secret_key = nil,
s3_key_id = nil,
s3_timeout = 10,
@@ -36,6 +37,7 @@ local settings = {
local settings_schema = ts.shape{
s3_bucket = ts.string,
s3_region = ts.string,
+ s3_host = ts.string,
s3_secret_key = ts.string,
s3_key_id = ts.string,
s3_timeout = ts.number + ts.string / lua_util.parse_time_interval,
@@ -85,7 +87,7 @@ local function structured_data(task, nonce, queue_id)
end
local function s3_aws_callback(task)
- local uri = string.format('https://%s.s3.amazonaws.com', settings.s3_bucket)
+ local uri = string.format('https://%s.%s', settings.s3_bucket, settings.s3_host)
-- Create a nonce
local nonce = rspamd_text.randombytes(16):base32()
local queue_id = task:get_queue_id()
@@ -93,7 +95,7 @@ local function s3_aws_callback(task)
queue_id = rspamd_text.randombytes(8):base32()
end
-- Hack to pass host
- local aws_host = string.format('%s.s3.amazonaws.com', settings.s3_bucket)
+ local aws_host = string.format('%s.%s', settings.s3_bucket, settings.s3_host)
local function gen_s3_http_callback(path)
return function (http_err, code, body, headers)