client

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandDescription

type CommandDescription struct {
	Open bool           // Open to clients without auth.
	Fn   func(*Handler) // Function to handle it.
}

CommandDescription defines which function should be used and if it should be open to anyone or only logged in users.

type Context

type Context interface {
	// Path provides the path of the current connection.
	Path() string
}

Context is implemented on the server side to provide some access to few data around the client.

type Driver

type Driver interface {
	// ChangeDirectory changes the current working directory.
	ChangeDirectory(cc Context, directory string) error

	// MakeDirectory creates a directory.
	MakeDirectory(cc Context, directory string) error

	// ListFiles lists the files of a directory.
	ListFiles(cc Context, dir string) ([]os.FileInfo, error)

	// OpenFile opens a file in 3 possible modes: read, write, appending write (use appropriate flags).
	OpenFile(cc Context, path string, flag int) (FileStream, error)

	// DeleteFile deletes a file or a directory.
	DeleteFile(cc Context, path string) error

	// GetFileInfo gets some info around a file or a directory.
	GetFileInfo(cc Context, path string) (os.FileInfo, error)

	// RenameFile renames a file or a directory.
	RenameFile(cc Context, from, to string) error

	// CanAllocate gives the approval to allocate some data.
	CanAllocate(cc Context, size int) (bool, error)

	// ChmodFile changes the attributes of the file.
	ChmodFile(cc Context, path string, mode os.FileMode) error
}

Driver handles the file system access logic.

type FileStream

type FileStream interface {
	io.Writer
	io.Reader
	io.Closer
	io.Seeker
}

FileStream is a read or write closeable stream.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler driver handles the file system access logic.

func NewHandler

func NewHandler(id string, connection net.Conn, driverFactory func() Driver) *Handler

NewHandler initializes a client handler when someone connects.

func (*Handler) HandleCommands

func (c *Handler) HandleCommands()

HandleCommands reads the stream of commands.

func (*Handler) Path

func (c *Handler) Path() string

Path provides the current working directory of the client.

func (*Handler) SetPath

func (c *Handler) SetPath(path string)

SetPath changes the current working directory.

func (*Handler) TransferClose

func (c *Handler) TransferClose()

TransferClose closes transfer with handler

func (*Handler) TransferOpen

func (c *Handler) TransferOpen() (net.Conn, error)

TransferOpen opens transfer with handler

func (*Handler) WriteMessage

func (c *Handler) WriteMessage(code int, message string)

WriteMessage writes server response

Jump to

Keyboard shortcuts

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