ftp

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ftp 实现 FTP 文件服务:多用户、每个用户映射到独立目录,可设为只读,支持 FTPS 与被动端口范围。

Index

Constants

View Source
const (
	TLSOptional  = 0 // 明文与 FTPS 均可
	TLSMandatory = 1 // 必须先 AUTH TLS(显式 FTPS)
	TLSImplicit  = 2 // 隐式 FTPS,连接即加密
)

TLS 模式,与 Lucky 的 TLSRequired 取值一致。

View Source
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 New

func New(certs CertSource) *Module

New 创建模块。

func (*Module) ID

func (m *Module) ID() string

ID 实现 module.Module。

func (*Module) ImportLucky

func (m *Module) ImportLucky(doc luckyimport.Document, opts luckyimport.Options) (*luckyimport.Report, error)

ImportLucky 实现 luckyimport.Importer,迁移监听与被动端口等服务参数(导入后保持停用)。 Lucky 配置中的用户列表结构未在样本中确认,不做猜测性导入,需在界面中重新添加用户。

func (*Module) Init

func (m *Module) Init(env module.Env) error

Init 实现 module.Module。

func (*Module) Routes

func (m *Module) Routes(r module.Router)

Routes 实现 module.Module。

func (*Module) Start

func (m *Module) Start(context.Context) error

Start 实现 module.Module。

func (*Module) Stop

func (m *Module) Stop() error

Stop 实现 module.Module。

func (*Module) Title

func (m *Module) Title() string

Title 实现 module.Module。

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"`
}

Settings 是模块配置。

func (*Settings) Validate

func (s *Settings) Validate() error

Validate 校验并规范化配置。

type User

type User struct {
	Name     string `json:"name"`
	Password string `json:"password"`
	// Root 为该用户可访问的目录(绝对路径)
	Root     string `json:"root"`
	ReadOnly bool   `json:"readOnly"`
}

User 是一个 FTP 账号。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL