2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 01:57:19 +08:00
This commit is contained in:
2026-01-25 00:16:48 +08:00
parent 0f2bcb5290
commit 19c6f92e8c
6 changed files with 12 additions and 20 deletions

1
go.mod
View File

@@ -108,6 +108,7 @@ require (
replace (
github.com/mholt/acmez/v3 => github.com/libtnb/acmez/v3 v3.0.0-20260103184942-a835890fc93e
github.com/moby/moby/client => github.com/libtnb/moby/client v0.0.0-20260119133723-7d7dd88cf643
github.com/rhnvrm/simples3 => github.com/devhaozi/simples3 v0.0.0-20260124160558-447c94ecedff
github.com/stretchr/testify => github.com/libtnb/testify v0.0.0-20260103194301-c7a63ea79696
)

4
go.sum
View File

@@ -59,6 +59,8 @@ github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfv
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dchest/captcha v1.1.0 h1:2kt47EoYUUkaISobUdTbqwx55xvKOJxyScVfw25xzhQ=
github.com/dchest/captcha v1.1.0/go.mod h1:7zoElIawLp7GUMLcj54K9kbw+jEyvz2K0FDdRRYhvWo=
github.com/devhaozi/simples3 v0.0.0-20260124160558-447c94ecedff h1:R8fAbRKWR+NVWIkjdK45CXS2cZzXQn8QuoM0Dij2Jso=
github.com/devhaozi/simples3 v0.0.0-20260124160558-447c94ecedff/go.mod h1:c2xW30bukipkBlWNnXG1wDjq3gykQ6ww2AB/9NHMLMY=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
@@ -293,8 +295,6 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rhnvrm/simples3 v0.11.1 h1:/IU3Jz7R3oSJfafPvXemwSZvh0wZ1nFcc2CceMmloU4=
github.com/rhnvrm/simples3 v0.11.1/go.mod h1:c2xW30bukipkBlWNnXG1wDjq3gykQ6ww2AB/9NHMLMY=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=

View File

@@ -402,8 +402,8 @@ func (r *backupRepo) getStorage(backupStorage biz.BackupStorage) (storage.Storag
return storage.NewS3(storage.S3Config{
Region: backupStorage.Info.Region,
Bucket: backupStorage.Info.Bucket,
AccessKeyID: backupStorage.Info.AccessKey,
SecretAccessKey: backupStorage.Info.SecretKey,
AccessKey: backupStorage.Info.AccessKey,
SecretKey: backupStorage.Info.SecretKey,
Endpoint: backupStorage.Info.Endpoint,
Scheme: backupStorage.Info.Scheme,
BasePath: backupStorage.Info.Path,

View File

@@ -126,8 +126,8 @@ func (s *BackupStorageService) validateStorage(accountType string, info types.Ba
client, err = storage.NewS3(storage.S3Config{
Region: info.Region,
Bucket: info.Bucket,
AccessKeyID: info.AccessKey,
SecretAccessKey: info.SecretKey,
AccessKey: info.AccessKey,
SecretKey: info.SecretKey,
Endpoint: info.Endpoint,
Scheme: info.Scheme,
BasePath: info.Path,

View File

@@ -23,8 +23,8 @@ const (
type S3Config struct {
Region string // AWS 区域
Bucket string // S3 存储桶名称
AccessKeyID string // 访问密钥 ID
SecretAccessKey string // 访问密钥
AccessKey string // 访问密钥 ID
SecretKey string // 访问密钥
Endpoint string // 自定义端点
Scheme string // 协议 http 或 https
BasePath string // 基础路径前缀
@@ -47,11 +47,9 @@ func NewS3(cfg S3Config) (Storage, error) {
cfg.BasePath = strings.Trim(cfg.BasePath, "/")
client := simples3.New(cfg.Region, cfg.AccessKeyID, cfg.SecretAccessKey)
client := simples3.New(cfg.Region, cfg.AccessKey, cfg.SecretKey)
// bucket 用于 API 调用
// Virtual Hosted Style 时 bucket 已在 endpoint 中API 调用时传空
// Path Style 时 bucket 需要作为路径的一部分
bucket := cfg.Bucket
if cfg.Endpoint != "" {
@@ -59,6 +57,7 @@ func NewS3(cfg S3Config) (Storage, error) {
if cfg.AddressingStyle == S3AddressingStyleVirtualHosted {
// Virtual Hosted Style: https://{bucket}.{endpoint}/{key}
client.SetEndpoint(fmt.Sprintf("%s://%s.%s", cfg.Scheme, cfg.Bucket, cfg.Endpoint))
client.SetVirtualHostedStyle()
bucket = ""
} else {
// Path Style: https://{endpoint}/{bucket}/{key}
@@ -69,6 +68,7 @@ func NewS3(cfg S3Config) (Storage, error) {
if cfg.AddressingStyle == S3AddressingStyleVirtualHosted {
// Virtual Hosted Style: https://{bucket}.s3.{region}.amazonaws.com/{key}
client.SetEndpoint(fmt.Sprintf("https://%s.s3.%s.amazonaws.com", cfg.Bucket, cfg.Region))
client.SetVirtualHostedStyle()
bucket = ""
}
}

View File

@@ -1,9 +0,0 @@
package storage
import "testing"
func TestS3(t *testing.T) {
s3, err := NewS3(S3Config{
Region: "us-west-1",
})
}