mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-08 22:25:00 +03:00
feat(xray): support the XDRIVE s3 storage service
xray-core 26.10.31 (#7231) added an "s3" XDRIVE service that carries the stream through S3-compatible storage: secrets are AccessKeyID, SecretAccessKey and an optional SessionToken, an "s3" object names the endpoint, region, bucket and pathStyle, and remoteFolder becomes the object prefix. The schema and the shared XDRIVE form offer the service with a field for every S3 key, so an outbound or inbound keeps its storage on save. The save path refused "s3" as an unknown service; it now runs the vendored loader, whose ValidateS3Config would otherwise only fire when the listener starts and stop every inbound. A node refuses a pushed S3 storage like a pushed template one, since its endpoint is any URL the node would dial, including its own panel. Labels in all 14 locales; docs updated in en/fa/ru/zh.
This commit is contained in:
@@ -1028,18 +1028,21 @@ const (
|
||||
// listening (stopping every inbound) or an outbound dials.
|
||||
func validateXDriveStorage(streamSettings string) error {
|
||||
var stream struct {
|
||||
Network string `json:"network"`
|
||||
XDriveSettings struct {
|
||||
Service string `json:"service"`
|
||||
RemoteFolder string `json:"remoteFolder"`
|
||||
Secrets []string `json:"secrets"`
|
||||
Template json.RawMessage `json:"template"`
|
||||
} `json:"xdriveSettings"`
|
||||
Network string `json:"network"`
|
||||
XDriveSettings json.RawMessage `json:"xdriveSettings"`
|
||||
}
|
||||
if json.Unmarshal([]byte(streamSettings), &stream) != nil || stream.Network != "xdrive" {
|
||||
return nil
|
||||
}
|
||||
xd := stream.XDriveSettings
|
||||
var xd struct {
|
||||
Service string `json:"service"`
|
||||
RemoteFolder string `json:"remoteFolder"`
|
||||
Secrets []string `json:"secrets"`
|
||||
Template json.RawMessage `json:"template"`
|
||||
}
|
||||
if len(stream.XDriveSettings) > 0 && json.Unmarshal(stream.XDriveSettings, &xd) != nil {
|
||||
return common.NewError("XDRIVE settings are not a valid object.")
|
||||
}
|
||||
hasFolder := strings.TrimSpace(xd.RemoteFolder) != ""
|
||||
switch xd.Service {
|
||||
case "local":
|
||||
@@ -1058,8 +1061,12 @@ func validateXDriveStorage(streamSettings string) error {
|
||||
return common.NewError(`XDRIVE service "template" needs a "template" object describing the storage API.`)
|
||||
}
|
||||
return validateXDriveTemplate(xd.Template)
|
||||
case "s3":
|
||||
if err := xray.ValidateXDriveS3(stream.XDriveSettings); err != nil {
|
||||
return common.NewError("XDRIVE ", err)
|
||||
}
|
||||
default:
|
||||
return common.NewError(fmt.Sprintf("unsupported XDRIVE service %q: use local, google-drive or template.", xd.Service))
|
||||
return common.NewError(fmt.Sprintf("unsupported XDRIVE service %q: use local, google-drive, template or s3.", xd.Service))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user