summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/config/config.go19
-rw-r--r--internal/config/defaults.go11
-rw-r--r--internal/config/helpers.gen.go25
-rw-r--r--internal/storage/storage.go18
4 files changed, 57 insertions, 16 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 2c4035ecf..78068ab86 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -112,15 +112,16 @@ type Configuration struct {
MediaCleanupEvery time.Duration `name:"media-cleanup-every" usage:"Period to elapse between cleanups, starting from media-cleanup-at."`
MediaFfmpegPoolSize int `name:"media-ffmpeg-pool-size" usage:"Number of instances of the embedded ffmpeg WASM binary to add to the media processing pool. 0 or less uses GOMAXPROCS."`
- StorageBackend string `name:"storage-backend" usage:"Storage backend to use for media attachments"`
- StorageLocalBasePath string `name:"storage-local-base-path" usage:"Full path to an already-created directory where gts should store/retrieve media files. Subfolders will be created within this dir."`
- StorageS3Endpoint string `name:"storage-s3-endpoint" usage:"S3 Endpoint URL (e.g 'minio.example.org:9000')"`
- StorageS3AccessKey string `name:"storage-s3-access-key" usage:"S3 Access Key"`
- StorageS3SecretKey string `name:"storage-s3-secret-key" usage:"S3 Secret Key"`
- StorageS3UseSSL bool `name:"storage-s3-use-ssl" usage:"Use SSL for S3 connections. Only set this to 'false' when testing locally"`
- StorageS3BucketName string `name:"storage-s3-bucket" usage:"Place blobs in this bucket"`
- StorageS3Proxy bool `name:"storage-s3-proxy" usage:"Proxy S3 contents through GoToSocial instead of redirecting to a presigned URL"`
- StorageS3RedirectURL string `name:"storage-s3-redirect-url" usage:"Custom URL to use for redirecting S3 media links. If set, this will be used instead of the S3 bucket URL."`
+ StorageBackend string `name:"storage-backend" usage:"Storage backend to use for media attachments"`
+ StorageLocalBasePath string `name:"storage-local-base-path" usage:"Full path to an already-created directory where gts should store/retrieve media files. Subfolders will be created within this dir."`
+ StorageS3Endpoint string `name:"storage-s3-endpoint" usage:"S3 Endpoint URL (e.g 'minio.example.org:9000')"`
+ StorageS3AccessKey string `name:"storage-s3-access-key" usage:"S3 Access Key"`
+ StorageS3SecretKey string `name:"storage-s3-secret-key" usage:"S3 Secret Key"`
+ StorageS3UseSSL bool `name:"storage-s3-use-ssl" usage:"Use SSL for S3 connections. Only set this to 'false' when testing locally"`
+ StorageS3BucketName string `name:"storage-s3-bucket" usage:"Place blobs in this bucket"`
+ StorageS3Proxy bool `name:"storage-s3-proxy" usage:"Proxy S3 contents through GoToSocial instead of redirecting to a presigned URL"`
+ StorageS3RedirectURL string `name:"storage-s3-redirect-url" usage:"Custom URL to use for redirecting S3 media links. If set, this will be used instead of the S3 bucket URL."`
+ StorageS3BucketLookup string `name:"storage-s3-bucket-lookup" usage:"S3 bucket lookup type to use. Can be 'auto', 'dns' or 'path'. Defaults to 'auto'."`
StatusesMaxChars int `name:"statuses-max-chars" usage:"Max permitted characters for posted statuses, including content warning"`
StatusesPollMaxOptions int `name:"statuses-poll-max-options" usage:"Max amount of options permitted on a poll"`
diff --git a/internal/config/defaults.go b/internal/config/defaults.go
index 7e1d234f3..e3ea64592 100644
--- a/internal/config/defaults.go
+++ b/internal/config/defaults.go
@@ -87,11 +87,12 @@ var Defaults = Configuration{
MediaCleanupEvery: 24 * time.Hour, // 1/day.
MediaFfmpegPoolSize: 1,
- StorageBackend: "local",
- StorageLocalBasePath: "/gotosocial/storage",
- StorageS3UseSSL: true,
- StorageS3Proxy: false,
- StorageS3RedirectURL: "",
+ StorageBackend: "local",
+ StorageLocalBasePath: "/gotosocial/storage",
+ StorageS3UseSSL: true,
+ StorageS3Proxy: false,
+ StorageS3RedirectURL: "",
+ StorageS3BucketLookup: "auto",
StatusesMaxChars: 5000,
StatusesPollMaxOptions: 6,
diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go
index b039d26a5..2fa502084 100644
--- a/internal/config/helpers.gen.go
+++ b/internal/config/helpers.gen.go
@@ -1781,6 +1781,31 @@ func GetStorageS3RedirectURL() string { return global.GetStorageS3RedirectURL()
// SetStorageS3RedirectURL safely sets the value for global configuration 'StorageS3RedirectURL' field
func SetStorageS3RedirectURL(v string) { global.SetStorageS3RedirectURL(v) }
+// GetStorageS3BucketLookup safely fetches the Configuration value for state's 'StorageS3BucketLookup' field
+func (st *ConfigState) GetStorageS3BucketLookup() (v string) {
+ st.mutex.RLock()
+ v = st.config.StorageS3BucketLookup
+ st.mutex.RUnlock()
+ return
+}
+
+// SetStorageS3BucketLookup safely sets the Configuration value for state's 'StorageS3BucketLookup' field
+func (st *ConfigState) SetStorageS3BucketLookup(v string) {
+ st.mutex.Lock()
+ defer st.mutex.Unlock()
+ st.config.StorageS3BucketLookup = v
+ st.reloadToViper()
+}
+
+// StorageS3BucketLookupFlag returns the flag name for the 'StorageS3BucketLookup' field
+func StorageS3BucketLookupFlag() string { return "storage-s3-bucket-lookup" }
+
+// GetStorageS3BucketLookup safely fetches the value for global configuration 'StorageS3BucketLookup' field
+func GetStorageS3BucketLookup() string { return global.GetStorageS3BucketLookup() }
+
+// SetStorageS3BucketLookup safely sets the value for global configuration 'StorageS3BucketLookup' field
+func SetStorageS3BucketLookup(v string) { global.SetStorageS3BucketLookup(v) }
+
// GetStatusesMaxChars safely fetches the Configuration value for state's 'StatusesMaxChars' field
func (st *ConfigState) GetStatusesMaxChars() (v int) {
st.mutex.RLock()
diff --git a/internal/storage/storage.go b/internal/storage/storage.go
index 3e5a69734..780d2ca5d 100644
--- a/internal/storage/storage.go
+++ b/internal/storage/storage.go
@@ -315,11 +315,25 @@ func NewS3Storage() (*Driver, error) {
bucket := config.GetStorageS3BucketName()
redirectURL := config.GetStorageS3RedirectURL()
+ var bucketLookup minio.BucketLookupType
+ switch s := config.GetStorageS3BucketLookup(); s {
+ case "auto":
+ bucketLookup = minio.BucketLookupAuto
+ case "dns":
+ bucketLookup = minio.BucketLookupDNS
+ case "path":
+ bucketLookup = minio.BucketLookupPath
+ default:
+ log.Warnf(nil, "%s set to %s which is not recognized, defaulting to 'auto'", config.StorageS3BucketLookupFlag(), s)
+ bucketLookup = minio.BucketLookupAuto
+ }
+
// Open the s3 storage implementation
s3, err := s3.Open(endpoint, bucket, &s3.Config{
CoreOpts: minio.Options{
- Creds: credentials.NewStaticV4(access, secret, ""),
- Secure: secure,
+ Creds: credentials.NewStaticV4(access, secret, ""),
+ Secure: secure,
+ BucketLookup: bucketLookup,
},
PutChunkSize: 5 * 1024 * 1024, // 5MiB
ListSize: 200,