Documentation
¶
Overview ¶
Package ftp 实现 FTP 文件服务:多用户、每个用户映射到一个或多个目录,可设为只读,支持 FTPS 与被动端口范围。
Index ¶
- Constants
- type CertSource
- type Module
- func (m *Module) ID() string
- func (m *Module) ImportLucky(doc luckyimport.Document, opts luckyimport.Options) (*luckyimport.Report, error)
- func (m *Module) Init(env module.Env) error
- func (m *Module) Routes(r module.Router)
- func (m *Module) Start(context.Context) error
- func (m *Module) Stop() error
- func (m *Module) Title() string
- type Settings
- type User
Constants ¶
const ( TLSOptional = 0 // 明文与 FTPS 均可 TLSMandatory = 1 // 必须先 AUTH TLS(显式 FTPS) TLSImplicit = 2 // 隐式 FTPS,连接即加密 )
TLS 模式,取值与导入配置中的 TLSRequired 对应。
const ID = "ftp"
ID 是模块标识。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertSource ¶
type CertSource interface {
GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error)
}
CertSource 提供 FTPS 证书。
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module 是 FTP 模块。
func (*Module) ImportLucky ¶
func (m *Module) ImportLucky(doc luckyimport.Document, opts luckyimport.Options) (*luckyimport.Report, error)
ImportLucky 实现 luckyimport.Importer,迁移监听、被动端口等服务参数与用户。 Lucky 用户的挂载列表转换为多目录用户;与 Gately 中已有用户同名的用户跳过,已有用户保持不变。
type Settings ¶
type Settings struct {
Enable bool `json:"enable"`
ListenIP string `json:"listenIp"`
Port int `json:"port"`
// PassiveStart/PassiveEnd 为被动模式数据端口范围,均为 0 时由系统随机分配
PassiveStart int `json:"passiveStart"`
PassiveEnd int `json:"passiveEnd"`
// PublicHost 为被动模式对外通告的 IP(位于 NAT 之后时填写公网或转发后的 IP),留空自动取连接地址
PublicHost string `json:"publicHost"`
// TLSMode 取 TLSOptional / TLSMandatory / TLSImplicit,非 0 时证书由证书模块按 SNI 提供
TLSMode int `json:"tlsMode"`
// IdleTimeout 控制连接空闲多少秒后断开,ConnectionTimeout 为建立数据连接的超时秒数
IdleTimeout int `json:"idleTimeout"`
ConnectionTimeout int `json:"connectionTimeout"`
DisableActiveMode bool `json:"disableActiveMode"`
Users []User `json:"users"`
SharedUsers bool `json:"sharedUsers"`
}
Settings 是模块配置。
type User ¶
type User struct {
Name string `json:"name"`
Password string `json:"password"`
// Root 为该用户可访问的目录(绝对路径),ReadOnly 作用于该目录;Mounts 非空时二者不再使用
Root string `json:"root"`
ReadOnly bool `json:"readOnly"`
// Mounts 为多个目录:登录后根目录按名称列出各目录,每个目录可单独设为只读
Mounts []mountfs.Mount `json:"mounts,omitempty"`
// Remark 为备注(例如账号的用途),只在管理界面展示
Remark string `json:"remark,omitempty"`
// Disabled 为 true 时暂停该用户,不能登录,同名的共享用户也不能登录;旧配置没有该字段,即为启用
Disabled bool `json:"disabled,omitempty"`
}
User 是一个 FTP 账号。