Documentation ¶
Overview ¶
Package sample is a sample server driver
Index ¶
- type Account
- type ClientDriver
- func (driver *ClientDriver) CanAllocate(cc server.ClientContext, size int) (bool, error)
- func (driver *ClientDriver) ChangeDirectory(cc server.ClientContext, directory string) error
- func (driver *ClientDriver) ChmodFile(cc server.ClientContext, path string, mode os.FileMode) error
- func (driver *ClientDriver) DeleteFile(cc server.ClientContext, path string) error
- func (driver *ClientDriver) GetFileInfo(cc server.ClientContext, path string) (os.FileInfo, error)
- func (driver *ClientDriver) ListFiles(cc server.ClientContext) ([]os.FileInfo, error)
- func (driver *ClientDriver) MakeDirectory(cc server.ClientContext, directory string) error
- func (driver *ClientDriver) OpenFile(cc server.ClientContext, path string, flag int) (server.FileStream, error)
- func (driver *ClientDriver) RenameFile(cc server.ClientContext, from, to string) error
- type MainDriver
- func (driver *MainDriver) AuthUser(cc server.ClientContext, user, pass string) (server.ClientHandlingDriver, error)
- func (driver *MainDriver) GetSettings() (*server.Settings, error)
- func (driver *MainDriver) GetTLSConfig() (*tls.Config, error)
- func (driver *MainDriver) UserLeft(cc server.ClientContext)
- func (driver *MainDriver) WelcomeUser(cc server.ClientContext) (string, error)
- type OurSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientDriver ¶
type ClientDriver struct {
BaseDir string // Base directory from which to server file
}
ClientDriver defines a very basic client driver
func (*ClientDriver) CanAllocate ¶
func (driver *ClientDriver) CanAllocate(cc server.ClientContext, size int) (bool, error)
CanAllocate gives the approval to allocate some data
func (*ClientDriver) ChangeDirectory ¶
func (driver *ClientDriver) ChangeDirectory(cc server.ClientContext, directory string) error
ChangeDirectory changes the current working directory
func (*ClientDriver) ChmodFile ¶
func (driver *ClientDriver) ChmodFile(cc server.ClientContext, path string, mode os.FileMode) error
ChmodFile changes the attributes of the file
func (*ClientDriver) DeleteFile ¶
func (driver *ClientDriver) DeleteFile(cc server.ClientContext, path string) error
DeleteFile deletes a file or a directory
func (*ClientDriver) GetFileInfo ¶
func (driver *ClientDriver) GetFileInfo(cc server.ClientContext, path string) (os.FileInfo, error)
GetFileInfo gets some info around a file or a directory
func (*ClientDriver) ListFiles ¶
func (driver *ClientDriver) ListFiles(cc server.ClientContext) ([]os.FileInfo, error)
ListFiles lists the files of a directory
func (*ClientDriver) MakeDirectory ¶
func (driver *ClientDriver) MakeDirectory(cc server.ClientContext, directory string) error
MakeDirectory creates a directory
func (*ClientDriver) OpenFile ¶
func (driver *ClientDriver) OpenFile(cc server.ClientContext, path string, flag int) (server.FileStream, error)
OpenFile opens a file in 3 possible modes: read, write, appending write (use appropriate flags)
func (*ClientDriver) RenameFile ¶
func (driver *ClientDriver) RenameFile(cc server.ClientContext, from, to string) error
RenameFile renames a file or a directory
type MainDriver ¶
type MainDriver struct { *logrus.Entry // Logger SettingsFile string // Settings file BaseDir string // Base directory from which to serve file // contains filtered or unexported fields }
MainDriver defines a very basic ftpserver driver
func NewSampleDriver ¶
func NewSampleDriver(dir string, settingsFile string) (*MainDriver, error)
NewSampleDriver creates a sample driver
func (*MainDriver) AuthUser ¶
func (driver *MainDriver) AuthUser(cc server.ClientContext, user, pass string) (server.ClientHandlingDriver, error)
AuthUser authenticates the user and selects an handling driver
func (*MainDriver) GetSettings ¶
func (driver *MainDriver) GetSettings() (*server.Settings, error)
GetSettings returns some general settings around the server setup
func (*MainDriver) GetTLSConfig ¶
func (driver *MainDriver) GetTLSConfig() (*tls.Config, error)
GetTLSConfig returns a TLS Certificate to use
func (*MainDriver) UserLeft ¶
func (driver *MainDriver) UserLeft(cc server.ClientContext)
UserLeft is called when the user disconnects, even if he never authenticated
func (*MainDriver) WelcomeUser ¶
func (driver *MainDriver) WelcomeUser(cc server.ClientContext) (string, error)
WelcomeUser is called to send the very first welcome message