Documentation
¶
Overview ¶
Package sftp 提供 SFTP 存储后端客户端:把任意 SFTP 服务适配为 `pkg/sync.FS` (7 方法),作为 sproxy 外部卷(V3 通用卷模型,RegisterBackend("sftp") 接入 系统盘/用户卷)。与 webdav 后端同构:Extra 读类型特有配置 → 构造客户端 → ExternalBackend 包装;装配层(cmd/sproxy/root.go)调用 Register 注册。
sftp_fs.go 是 SFTP 存储后端的 sync.FS 实现(客户端)。
并发安全:每实例独立 ssh.Client + sftp.Client(仓库硬规则 17:禁共享连接池); pkg/sftp 的 Client 并发安全(内部多 channel 复用单连接)。
Index ¶
- func RegisterSFTPBackend()
- type ClientConfig
- type SFTPFS
- func (f *SFTPFS) Close() error
- func (f *SFTPFS) Delete(ctx context.Context, relPath string) error
- func (f *SFTPFS) ListDir(ctx context.Context, relPath string) ([]sync.Entry, error)
- func (f *SFTPFS) MakeDir(ctx context.Context, relPath string) error
- func (f *SFTPFS) OpenRead(ctx context.Context, relPath string) (io.ReadCloser, error)
- func (f *SFTPFS) Ping(ctx context.Context) error
- func (f *SFTPFS) Rename(ctx context.Context, from, to string) error
- func (f *SFTPFS) Stat(ctx context.Context, relPath string) (*sync.Entry, error)
- func (f *SFTPFS) WriteFile(ctx context.Context, key sync.LogicalKey, relPath string, r io.Reader, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterSFTPBackend ¶
func RegisterSFTPBackend()
Types ¶
type ClientConfig ¶
type ClientConfig struct {
// URL 是 SFTP 地址(sftp://user@host:port[/root-path];必填,端口默认 22)。
URL string
// PrivateKey 私钥内容(与 Password 二选一;fail-closed 至少一个)。
PrivateKey string
// Password 密码认证(与 PrivateKey 二选一)。
Password string
// Root 远端根目录(可选;默认用户主目录)。
Root string
// DialTimeout 拨号超时(0 = 默认 10s)。
DialTimeout time.Duration
}
ClientConfig 是 SFTP 客户端配置。
type SFTPFS ¶
type SFTPFS struct {
// contains filtered or unexported fields
}
SFTPFS 是 SFTP 存储后端的 sync.FS 实现。
func NewSFTPFS ¶
func NewSFTPFS(cfg ClientConfig) (*SFTPFS, error)
NewSFTPFS 构造 SFTP 客户端:解析 URL → 拨 ssh → sftp 握手。 URL 必须为 sftp://user@host[:port][/path];认证 private_key 或 password 至少一个。
Click to show internal directories.
Click to hide internal directories.