mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-09-23 01:27:04 +00:00
https://github.com/XTLS/Xray-core/pull/5414#issuecomment-3796734827 https://github.com/XTLS/Xray-core/pull/5581#issuecomment-3797134147 https://github.com/XTLS/Xray-core/pull/5645#issuecomment-3899873945 https://github.com/XTLS/Xray-core/pull/6745#issuecomment-5627420177 https://github.com/XTLS/Xray-core/pull/6748#issuecomment-5740443122 --------- Co-authored-by: Risaro <62798663+Risaro@users.noreply.github.com>
40 lines
924 B
Go
40 lines
924 B
Go
package xdrive
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/xtls/xray-core/common/errors"
|
|
"github.com/xtls/xray-core/transport/internet"
|
|
)
|
|
|
|
var errNotFound = errors.New("object not found")
|
|
|
|
type Entry struct {
|
|
Name string
|
|
Inline []byte
|
|
}
|
|
|
|
type Storage interface {
|
|
Put(ctx context.Context, name string, data []byte) error
|
|
Get(ctx context.Context, name string) ([]byte, error)
|
|
Delete(ctx context.Context, name string) error
|
|
List(ctx context.Context, prefix string) ([]Entry, error)
|
|
Close() error
|
|
}
|
|
|
|
func newStorage(streamSettings *internet.MemoryStreamConfig) (Storage, error) {
|
|
config, err := streamConfig(streamSettings)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
switch config.Service {
|
|
case "local":
|
|
return newLocalStorage(config.RemoteFolder)
|
|
case "Google Drive":
|
|
return nil, errors.New(`service "Google Drive" is not implemented yet`)
|
|
default:
|
|
return nil, errors.New("unsupported service: ", config.Service)
|
|
}
|
|
}
|