sftp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFileSys

func NewFileSys(Sessions *Sessions) sftp.Handlers

Types

type ListerAt

type ListerAt []os.FileInfo

func (ListerAt) ListAt

func (f ListerAt) ListAt(ls []os.FileInfo, offset int64) (int, error)

ListAt Modeled after strings.Reader's ReadAt() implementation

type Server

type Server struct {
	Addr string
	// contains filtered or unexported fields
}

func NewSFTPServer

func NewSFTPServer(addr string, fs filesystem.FSWithReadWriteAt, users Users) *Server

func (*Server) AuthHandler

func (s *Server) AuthHandler(conn net.Conn) func(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error)

AuthHandler is called by the SSH server when a client attempts to authenticate.

func (*Server) Close

func (s *Server) Close()

Close closes the server.

func (*Server) GetPrivateKeys added in v0.1.20

func (s *Server) GetPrivateKeys() map[string][]byte

GetPrivateKeys returns the private key for the server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

func (*Server) Logger

func (s *Server) Logger() *slog.Logger

Logger returns the logger for the server.

func (*Server) SetLogger

func (s *Server) SetLogger(l *slog.Logger)

SetLogger sets the logger for the server.

func (*Server) SetPrivateKey

func (s *Server) SetPrivateKey(name string, pk []byte)

SetPrivateKey sets the private key for the server. if not called the server will generate a new key

func (*Server) SetPrivateKeyFile

func (s *Server) SetPrivateKeyFile(pk string) error

func (*Server) TryListenAndServe

func (s *Server) TryListenAndServe(d time.Duration) (err error)

TryListenAndServe tries to start the FTP server if there isn't an error after a certain time it returns nil

type Sessions added in v0.1.18

type Sessions struct {
	UserInfo ssh.ConnMetadata
	// contains filtered or unexported fields
}

func (*Sessions) Filecmd added in v0.1.18

func (s *Sessions) Filecmd(request *sftp.Request) error

func (*Sessions) Filelist added in v0.1.18

func (s *Sessions) Filelist(request *sftp.Request) (sftp.ListerAt, error)

func (*Sessions) Fileread added in v0.1.18

func (s *Sessions) Fileread(request *sftp.Request) (io.ReaderAt, error)

func (*Sessions) Filewrite added in v0.1.18

func (s *Sessions) Filewrite(request *sftp.Request) (io.WriterAt, error)

func (*Sessions) PosixRename added in v0.1.18

func (s *Sessions) PosixRename(request *sftp.Request) error

func (*Sessions) StatVFS added in v0.1.18

func (s *Sessions) StatVFS(request *sftp.Request) (*sftp.StatVFS, error)

type Users

type Users interface {
	// FindUser returns a user by username and password, if the user is not found it returns an error
	FindUser(ctx context.Context, username, password, ipaddr string) (any, error)
}

Users is the interface to find a user by username and password and return it

Jump to

Keyboard shortcuts

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