Categorygithub.com/pkg/sftp
modulepackage
1.13.7
Repository: https://github.com/pkg/sftp.git
Documentation: pkg.go.dev

# README

sftp

The sftp package provides support for file system operations on remote ssh servers using the SFTP subsystem. It also implements an SFTP server for serving files from the filesystem.

CI Status Go Reference

usage and examples

See https://pkg.go.dev/github.com/pkg/sftp for examples and usage.

The basic operation of the package mirrors the facilities of the os package.

The Walker interface for directory traversal is heavily inspired by Keith Rarick's fs package.

roadmap

  • There is way too much duplication in the Client methods. If there was an unmarshal(interface{}) method this would reduce a heap of the duplication.

contributing

We welcome pull requests, bug fixes and issue reports.

Before proposing a large change, first please discuss your change by raising an issue.

For API/code bugs, please include a small, self contained code example to reproduce the issue. For pull requests, remember test coverage.

We try to handle issues and pull requests with a 0 open philosophy. That means we will try to address the submission as soon as possible and will work toward a resolution. If progress can no longer be made (eg. unreproducible bug) or stops (eg. unresponsive submitter), we will close the bug.

Thanks.

# Packages

No description provided by the author
No description provided by the author

# Functions

InMemHandler returns a Hanlders object with the test handlers.
Join joins any number of path elements into a single path, separating them with slashes.
Match reports whether name matches the shell pattern.
MaxConcurrentRequestsPerFile sets the maximum concurrent requests allowed for a single file.
MaxPacket sets the maximum size of the payload, measured in bytes.
MaxPacketChecked sets the maximum size of the payload, measured in bytes.
MaxPacketUnchecked sets the maximum size of the payload, measured in bytes.
NewClient creates a new SFTP client on conn, using zero or more option functions.
NewClientPipe creates a new SFTP client given a Reader and a WriteCloser.
NewRequest creates a new Request object.
NewRequestServer creates/allocates/returns new RequestServer.
NewServer creates a new Server instance around the provided streams, serving content from the root of the filesystem.
ReadOnly configures a Server to serve files in read-only mode.
SetSFTPExtensions allows to customize the supported server extensions.
Split splits the path p immediately following the final slash, separating it into a directory and file name component.
UseConcurrentReads allows the Client to perform concurrent Reads.
UseConcurrentWrites allows the Client to perform concurrent Writes.
UseFstat sets whether to use Fstat or Stat when File.WriteTo is called (usually when copying files).
WithAllocator enable the allocator.
WithDebug enables Server debugging output to the supplied io.Writer.
WithMaxTxPacket sets the maximum size of the payload returned to the client, measured in bytes.
WithRSAllocator enable the allocator.
WithRSMaxTxPacket sets the maximum size of the payload returned to the client, measured in bytes.
WithServerWorkingDirectory sets a working directory to use as base for relative paths.
WithStartDirectory sets a start directory to use as base for relative paths.

# Constants

No description provided by the author
Deprecated error types, these are aliases for the new ones, please use the new ones directly.
Error types that match the SFTP's SSH_FXP_STATUS codes.
Deprecated error types, these are aliases for the new ones, please use the new ones directly.
Error types that match the SFTP's SSH_FXP_STATUS codes.
Deprecated error types, these are aliases for the new ones, please use the new ones directly.
Error types that match the SFTP's SSH_FXP_STATUS codes.
Deprecated error types, these are aliases for the new ones, please use the new ones directly.
Error types that match the SFTP's SSH_FXP_STATUS codes.
Deprecated error types, these are aliases for the new ones, please use the new ones directly.
Error types that match the SFTP's SSH_FXP_STATUS codes.
Deprecated error types, these are aliases for the new ones, please use the new ones directly.
Error types that match the SFTP's SSH_FXP_STATUS codes.
Deprecated error types, these are aliases for the new ones, please use the new ones directly.
Error types that match the SFTP's SSH_FXP_STATUS codes.
Deprecated error types, these are aliases for the new ones, please use the new ones directly.
Error types that match the SFTP's SSH_FXP_STATUS codes.
Deprecated error types, these are aliases for the new ones, please use the new ones directly.
Error types that match the SFTP's SSH_FXP_STATUS codes.
S_IFMT is a legacy export, and was brought in to support GOOS environments whose sysconfig.S_IFMT may be different from the value used internally by SFTP standards.
SftpServerWorkerCount defines the number of workers for the SFTP server.

# Variables

ErrBadPattern indicates a globbing pattern was malformed.
ErrInternalInconsistency indicates the packets sent and the data queued to be written to the file don't match up.
InternalInconsistency alias for ErrInternalInconsistency.
MaxFilelist is the max number of files to return in a readdir batch.

# Structs

Client represents an SFTP session on a *ssh.ClientConn SSH connection.
File represents a remote file.
FileAttrFlags that indicate whether SFTP file attributes were passed.
FileOpenFlags defines Open and Write Flags.
FileStat holds the original unmarshalled values from a call to READDIR or *STAT.
Handlers contains the 4 SFTP server request handlers.
Request contains the data and state for the incoming service request.
RequestServer abstracts the sftp protocol with an http request-like protocol.
Server is an SSH File Transfer Protocol (sftp) server.
StatExtended contains additional, extended information for a FileStat.
A StatusError is returned when an SFTP operation fails, and provides additional information about the failure.
A StatVFS contains statistics about a filesystem.

# Interfaces

FileCmder should return an error Note in cases of an error, the error text will be sent to the client.
FileInfoUidGid extends os.FileInfo and adds a callbacks for extended data retrieval.
FileInfoUidGid extends os.FileInfo and adds callbacks for Uid and Gid retrieval, as an alternative to *syscall.Stat_t objects on unix systems.
FileLister should return an object that fulfils the ListerAt interface Note in cases of an error, the error text will be sent to the client.
FileReader should return an io.ReaderAt for the filepath Note in cases of an error, the error text will be sent to the client.
FileWriter should return an io.WriterAt for the filepath.
ListerAt does for file lists what io.ReaderAt does for files, i.e.
LstatFileLister is a FileLister that implements the Lstat method.
NameLookupFileLister is a FileLister that implmeents the LookupUsername and LookupGroupName methods.
OpenFileWriter is a FileWriter that implements the generic OpenFile method.
PosixRenameFileCmder is a FileCmder that implements the PosixRename method.
ReadlinkFileLister is a FileLister that implements the Readlink method.
RealPathFileLister is a FileLister that implements the Realpath method.
StatVFSFileCmder is a FileCmder that implements the StatVFS method.
TransferError is an optional interface that readerAt and writerAt can implement to be notified about the error causing Serve() to exit with the request still open.
WriterAtReaderAt defines the interface to return when a file is to be opened for reading and writing.

# Type aliases

A ClientOption is a function which applies configuration to a Client.
A RequestServerOption is a function which applies configuration to a RequestServer.
A ServerOption is a function which applies configuration to a Server.