Documentation ¶
Overview ¶
Package ftpd implements the FTP protocol
Index ¶
- func ReloadTLSCertificate() error
- type Configuration
- type Connection
- func (c *Connection) AllocateSpace(size int) error
- func (c *Connection) Chmod(name string, mode os.FileMode) error
- func (c *Connection) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (c *Connection) Create(name string) (afero.File, error)
- func (c *Connection) Disconnect() error
- func (c *Connection) GetClientVersion() string
- func (c *Connection) GetCommand() string
- func (c *Connection) GetHandle(name string, flags int, offset int64) (ftpserver.FileTransfer, error)
- func (c *Connection) GetRemoteAddress() string
- func (c *Connection) Mkdir(name string, perm os.FileMode) error
- func (c *Connection) MkdirAll(path string, perm os.FileMode) error
- func (c *Connection) Name() string
- func (c *Connection) Open(name string) (afero.File, error)
- func (c *Connection) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)
- func (c *Connection) ReadDir(name string) ([]os.FileInfo, error)
- func (c *Connection) Remove(name string) error
- func (c *Connection) RemoveAll(path string) error
- func (c *Connection) RemoveDir(name string) error
- func (c *Connection) Rename(oldname, newname string) error
- func (c *Connection) Stat(name string) (os.FileInfo, error)
- func (c *Connection) Symlink(oldname, newname string) error
- type PortRange
- type Server
- func (s *Server) AuthUser(cc ftpserver.ClientContext, username, password string) (ftpserver.ClientDriver, error)
- func (s *Server) ClientConnected(cc ftpserver.ClientContext) (string, error)
- func (s *Server) ClientDisconnected(cc ftpserver.ClientContext)
- func (s *Server) GetSettings() (*ftpserver.Settings, error)
- func (s *Server) GetTLSConfig() (*tls.Config, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReloadTLSCertificate ¶
func ReloadTLSCertificate() error
ReloadTLSCertificate reloads the TLS certificate and key from the configured paths
Types ¶
type Configuration ¶
type Configuration struct { // The port used for serving FTP requests BindPort int `json:"bind_port" mapstructure:"bind_port"` // The address to listen on. A blank value means listen on all available network interfaces. BindAddress string `json:"bind_address" mapstructure:"bind_address"` // External IP address to expose for passive connections. ForcePassiveIP string `json:"force_passive_ip" mapstructure:"force_passive_ip"` // Greeting banner displayed when a connection first comes in Banner string `json:"banner" mapstructure:"banner"` // the contents of the specified file, if any, are diplayed when someone connects to the server. // If set, it overrides the banner string provided by the banner option BannerFile string `json:"banner_file" mapstructure:"banner_file"` // If files containing a certificate and matching private key for the server are provided the server will accept // both plain FTP an explicit FTP over TLS. // Certificate and key files can be reloaded on demand sending a "SIGHUP" signal on Unix based systems and a // "paramchange" request to the running service on Windows. CertificateFile string `json:"certificate_file" mapstructure:"certificate_file"` CertificateKeyFile string `json:"certificate_key_file" mapstructure:"certificate_key_file"` // Do not impose the port 20 for active data transfer. Enabling this option allows to run SFTPGo with less privilege ActiveTransfersPortNon20 bool `json:"active_transfers_port_non_20" mapstructure:"active_transfers_port_non_20"` // Port Range for data connections. Random if not specified PassivePortRange PortRange `json:"passive_port_range" mapstructure:"passive_port_range"` // set to 1 to require TLS for both data and control connection TLSMode int `json:"tls_mode" mapstructure:"tls_mode"` }
Configuration defines the configuration for the ftp server
func (*Configuration) Initialize ¶
func (c *Configuration) Initialize(configDir string) error
Initialize configures and starts the FTP server
type Connection ¶
type Connection struct { *common.BaseConnection // contains filtered or unexported fields }
Connection details for an FTP connection. It implements common.ActiveConnection and ftpserver.ClientDriver interfaces
func (*Connection) AllocateSpace ¶
func (c *Connection) AllocateSpace(size int) error
AllocateSpace implements ClientDriverExtensionAllocate
func (*Connection) Chmod ¶
func (c *Connection) Chmod(name string, mode os.FileMode) error
Chmod changes the mode of the named file/directory
func (*Connection) Create ¶
func (c *Connection) Create(name string) (afero.File, error)
Create is not implemented we use ClientDriverExtentionFileTransfer
func (*Connection) Disconnect ¶
func (c *Connection) Disconnect() error
Disconnect disconnects the client
func (*Connection) GetClientVersion ¶
func (c *Connection) GetClientVersion() string
GetClientVersion returns the connected client's version. It returns "Unknown" if the client does not advertise its version
func (*Connection) GetCommand ¶
func (c *Connection) GetCommand() string
GetCommand returns an empty string
func (*Connection) GetHandle ¶
func (c *Connection) GetHandle(name string, flags int, offset int64) (ftpserver.FileTransfer, error)
GetHandle implements ClientDriverExtentionFileTransfer
func (*Connection) GetRemoteAddress ¶
func (c *Connection) GetRemoteAddress() string
GetRemoteAddress return the connected client's address
func (*Connection) Mkdir ¶
func (c *Connection) Mkdir(name string, perm os.FileMode) error
Mkdir creates a directory using the connection filesystem
func (*Connection) MkdirAll ¶
func (c *Connection) MkdirAll(path string, perm os.FileMode) error
MkdirAll is not implemented, we don't need it
func (*Connection) Name ¶
func (c *Connection) Name() string
Name returns the name of this connection
func (*Connection) Open ¶
func (c *Connection) Open(name string) (afero.File, error)
Open is not implemented we use ClientDriverExtentionFileTransfer and ClientDriverExtensionFileList
func (*Connection) ReadDir ¶
func (c *Connection) ReadDir(name string) ([]os.FileInfo, error)
ReadDir implements ClientDriverExtensionFilelist
func (*Connection) Remove ¶
func (c *Connection) Remove(name string) error
Remove removes a file. We implements ClientDriverExtensionRemoveDir for directories
func (*Connection) RemoveAll ¶
func (c *Connection) RemoveAll(path string) error
RemoveAll is not implemented, we don't need it
func (*Connection) RemoveDir ¶
func (c *Connection) RemoveDir(name string) error
RemoveDir implements ClientDriverExtensionRemoveDir
func (*Connection) Rename ¶
func (c *Connection) Rename(oldname, newname string) error
Rename renames a file or a directory
func (*Connection) Stat ¶
func (c *Connection) Stat(name string) (os.FileInfo, error)
Stat returns a FileInfo describing the named file/directory, or an error, if any happens
func (*Connection) Symlink ¶
func (c *Connection) Symlink(oldname, newname string) error
Symlink implements ClientDriverExtensionSymlink
type PortRange ¶
type PortRange struct { // Range start Start int `json:"start" mapstructure:"start"` // Range end End int `json:"end" mapstructure:"end"` }
PortRange defines a port range
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements the ftpserverlib MainDriver interface
func NewServer ¶
func NewServer(config *Configuration, configDir string) (*Server, error)
NewServer returns a new FTP server driver
func (*Server) AuthUser ¶
func (s *Server) AuthUser(cc ftpserver.ClientContext, username, password string) (ftpserver.ClientDriver, error)
AuthUser authenticates the user and selects an handling driver
func (*Server) ClientConnected ¶
func (s *Server) ClientConnected(cc ftpserver.ClientContext) (string, error)
ClientConnected is called to send the very first welcome message
func (*Server) ClientDisconnected ¶
func (s *Server) ClientDisconnected(cc ftpserver.ClientContext)
ClientDisconnected is called when the user disconnects, even if he never authenticated
func (*Server) GetSettings ¶
GetSettings returns FTP server settings