Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion infra/conf/transport_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,12 +997,20 @@ type XDriveConfig struct {
EagerWindowMs uint32 `json:"eagerWindowMs"`
HoleTimeoutMs uint32 `json:"holeTimeoutMs"`
Template json.RawMessage `json:"template"`
S3 *XDriveS3Config `json:"s3"`
Xmux XmuxConfig `json:"xmux"`

// set by StreamConfig when "alpn" is ["h3"]
h3 bool
}

type XDriveS3Config struct {
Endpoint string `json:"endpoint"`
Region string `json:"region"`
Bucket string `json:"bucket"`
PathStyle *bool `json:"pathStyle"`
}

// Build implements Buildable.
func (c *XDriveConfig) Build() (proto.Message, error) {
switch c.Service {
Expand All @@ -1019,8 +1027,12 @@ func (c *XDriveConfig) Build() (proto.Message, error) {
if len(c.Template) == 0 {
return nil, errors.New(`service "template" needs a "template" object`)
}
case "s3":
if c.S3 == nil {
return nil, errors.New(`service "s3" needs an "s3" object`)
}
default:
return nil, errors.New(`unknown "service": "`, c.Service, `", use "google-drive", "template" or "local"`)
return nil, errors.New(`unknown "service": "`, c.Service, `", use "google-drive", "template", "s3" or "local"`)
}
if c.Xmux.MaxConnections.To > 0 && c.Xmux.MaxConcurrency.To > 0 {
return nil, errors.New("maxConnections cannot be specified together with maxConcurrency")
Expand Down Expand Up @@ -1059,5 +1071,16 @@ func (c *XDriveConfig) Build() (proto.Message, error) {
HKeepAlivePeriod: c.Xmux.HKeepAlivePeriod,
},
}
if c.Service == "s3" {
config.S3 = &xdrive.S3Config{
Endpoint: c.S3.Endpoint,
Region: c.S3.Region,
Bucket: c.S3.Bucket,
PathStyle: c.S3.PathStyle == nil || *c.S3.PathStyle,
}
if err := xdrive.ValidateS3Config(config); err != nil {
return nil, err
}
}
return config, nil
}
2 changes: 1 addition & 1 deletion infra/conf/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func TestXDriveRejectsUnknownService(t *testing.T) {
if err := json.Unmarshal([]byte(`{"remoteFolder": "/tmp/xdrive", "service": "Dropbox"}`), config); err != nil {
t.Fatalf("Unmarshal: %v", err)
}
if _, err := config.Build(); err == nil || !strings.Contains(err.Error(), `use "google-drive", "template" or "local"`) {
if _, err := config.Build(); err == nil || !strings.Contains(err.Error(), `use "google-drive", "template", "s3" or "local"`) {
t.Fatalf("expected an unknown service error, got %v", err)
}
}
Expand Down
107 changes: 96 additions & 11 deletions transport/internet/xdrive/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions transport/internet/xdrive/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ message Config {
uint32 hole_timeout_ms = 11;
string template = 12;
xray.transport.internet.splithttp.XmuxConfig xmux = 13;
S3Config s3 = 14;
}

message S3Config {
string endpoint = 1;
string region = 2;
string bucket = 3;
bool path_style = 4;
}
Loading
Loading