From 483ae5e6eb161e6262539e90870e3e8a7893f3be Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Wed, 12 Jul 2017 21:09:19 -0400 Subject: [PATCH] Add minios:// for minio servers with SSL support --- src/duplicacy_s3storage.go | 5 +++-- src/duplicacy_storage.go | 7 ++++--- src/duplicacy_storage_test.go | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/duplicacy_s3storage.go b/src/duplicacy_s3storage.go index c9d0525..41590c0 100644 --- a/src/duplicacy_s3storage.go +++ b/src/duplicacy_s3storage.go @@ -23,7 +23,8 @@ type S3Storage struct { // CreateS3Storage creates a amazon s3 storage object. func CreateS3Storage(regionName string, endpoint string, bucketName string, storageDir string, - accessKey string, secretKey string, threads int, isMinioCompatible bool) (storage *S3Storage, err error) { + accessKey string, secretKey string, threads int, + isSSLSupported bool, isMinioCompatible bool) (storage *S3Storage, err error) { token := "" @@ -54,7 +55,7 @@ func CreateS3Storage(regionName string, endpoint string, bucketName string, stor Credentials: auth, Endpoint: aws.String(endpoint), S3ForcePathStyle: aws.Bool(isMinioCompatible), - DisableSSL: aws.Bool(isMinioCompatible), + DisableSSL: aws.Bool(!isSSLSupported), } if len(storageDir) > 0 && storageDir[len(storageDir) - 1] != '/' { diff --git a/src/duplicacy_storage.go b/src/duplicacy_storage.go index 33225f1..2f25cfe 100644 --- a/src/duplicacy_storage.go +++ b/src/duplicacy_storage.go @@ -293,7 +293,7 @@ func CreateStorage(preference Preference, resetPassword bool, threads int) (stor SavePassword(preference, "ssh_password", password) } return sftpStorage - } else if matched[1] == "s3" || matched[1] == "s3c" || matched[1] == "minio"{ + } else if matched[1] == "s3" || matched[1] == "s3c" || matched[1] == "minio" || matched[1] == "minios" { // urlRegex := regexp.MustCompile(`^(\w+)://([\w\-]+@)?([^/]+)(/(.+))?`) @@ -328,8 +328,9 @@ func CreateStorage(preference Preference, resetPassword bool, threads int) (stor return nil } } else { - isMinioCompatible := matched[1] == "minio" - storage, err = CreateS3Storage(region, endpoint, bucket, storageDir, accessKey, secretKey, threads, isMinioCompatible) + isMinioCompatible := (matched[1] == "minio" || matched[1] == "minios") + isSSLSupported := (matched[1] == "s3" || matched[1] == "minios") + storage, err = CreateS3Storage(region, endpoint, bucket, storageDir, accessKey, secretKey, threads, isSSLSupported, isMinioCompatible) if err != nil { LOG_ERROR("STORAGE_CREATE", "Failed to load the S3 storage at %s: %v", storageURL, err) return nil diff --git a/src/duplicacy_storage_test.go b/src/duplicacy_storage_test.go index 2a65ea0..b511689 100644 --- a/src/duplicacy_storage_test.go +++ b/src/duplicacy_storage_test.go @@ -65,17 +65,17 @@ func loadStorage(localStoragePath string, threads int) (Storage, error) { port, _ := strconv.Atoi(storage["port"]) return CreateSFTPStorageWithPassword(storage["server"], port, storage["username"], storage["directory"], storage["password"], threads) } else if testStorageName == "s3" { - return CreateS3Storage(storage["region"], storage["endpoint"], storage["bucket"], storage["directory"], storage["access_key"], storage["secret_key"], threads, false) + return CreateS3Storage(storage["region"], storage["endpoint"], storage["bucket"], storage["directory"], storage["access_key"], storage["secret_key"], threads, true, false) } else if testStorageName == "s3c" { return CreateS3CStorage(storage["region"], storage["endpoint"], storage["bucket"], storage["directory"], storage["access_key"], storage["secret_key"], threads) } else if testStorageName == "minio" { - return CreateS3Storage(storage["region"], storage["endpoint"], storage["bucket"], storage["directory"], storage["access_key"], storage["secret_key"], threads, true) + return CreateS3Storage(storage["region"], storage["endpoint"], storage["bucket"], storage["directory"], storage["access_key"], storage["secret_key"], threads, false, true) } else if testStorageName == "dropbox" { return CreateDropboxStorage(storage["token"], storage["directory"], threads) } else if testStorageName == "b2" { return CreateB2Storage(storage["account"], storage["key"], storage["bucket"], threads) } else if testStorageName == "gcs-s3" { - return CreateS3Storage(storage["region"], storage["endpoint"], storage["bucket"], storage["directory"], storage["access_key"], storage["secret_key"], threads, false) + return CreateS3Storage(storage["region"], storage["endpoint"], storage["bucket"], storage["directory"], storage["access_key"], storage["secret_key"], threads, true, false) } else if testStorageName == "gcs" { return CreateGCSStorage(storage["token_file"], storage["bucket"], storage["directory"], threads) } else if testStorageName == "gcs-sa" {