commit e401747: [Config] Allow configurable s3 urls

bradleydoherty59 bradleydoherty59 at gmail.com
Fri Nov 5 19:49:04 UTC 2021


Author: bradleydoherty59
Date: 2021-11-05 14:01:12 -0500
URL: https://github.com/rspamd/rspamd/commit/e401747c7920e6ac5fe9a50e0a2c6a2750f13cd3 (refs/pull/3964/head)

[Config] Allow configurable s3 urls

---
 conf/modules.d/aws_s3.conf | 1 +
 src/plugins/lua/aws_s3.lua | 6 ++++--
 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)


More information about the Commits mailing list