sample

package
v0.0.0-...-cce756a Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package sample is a sample server driver

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	User string // Username
	Pass string // Password
	Dir  string // Directory
}

Account defines a user/pass password

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 {
	Logger       log.Logger // 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

type OurSettings

type OurSettings struct {
	Server         server.Settings // Server settings (shouldn't need to be filled)
	Users          []Account       // Credentials
	MaxConnections int32           // Maximum number of clients that are allowed to connect at the same time
}

OurSettings defines our settings

Jump to

Keyboard shortcuts

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