Categorygithub.com/Clever/sftp
modulepackage
0.0.0-20240730000841-3b6780a639c1
Repository: https://github.com/clever/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.

This is a fork of github.com/pkg/sftp that changes the server to allow for a plugable backend and adds an S3 and file system backend. The file system backend is mostly used for tests and is similar to the previous behavior. Additionally, this adds a ManagedServer component that can be used to easily create a server with an arbitrary backend.

Tests that depend on the details of the file system server (mostly client tests) are being skipped.

usage and examples

See godoc.org/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.

# Packages

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

# Functions

MaxPacket sets the maximum size of the payload.
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.
NewConn is used to wrap a net.Conn that may be speaking the proxy protocol into a proxyproto.Conn.
NewManagedServer creates a new ManagedServer which conditionally serves requests based on the output of driverGenerator.
No description provided by the author
NewS3Driver creates a new S3Driver with the AWS credentials and S3 parameters.
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.
translatePath takes in a S3 root prefix, a home directory, and either an absolute or relative path to append, and returns a cleaned and validated path.
WithDebug enables Server debugging output to the supplied io.Writer.

# Variables

No description provided by the author
ErrInvalidUpstream returned if connection fails or is not accepted.

# Structs

Client represents an SFTP session on a *ssh.ClientConn SSH connection.
Conn is used to wrap and underlying connection which may be speaking the Proxy Protocol.
File represents a remote file.
FileStat holds the original unmarshalled values from a call to READDIR or *STAT.
Listener is used to wrap an underlying listener, whose connections may be using the HAProxy Proxy Protocol (version 1).
LoginRequest is the metadata associated with a login request that is passed to the driverGenerator function in order for it to approve/deny the request.
ManagedServer is our term for the SFTP server.
Mock of S3API interface.
No description provided by the author
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.
No description provided by the author

# Interfaces

Logger is an abstraction for how logging will be performed by the server.
No description provided by the author
No description provided by the author

# Type aliases

Alerter is the function signature for an optional alerting function to be called in error cases.
DriverGenerator is a function that creates an SFTP ServerDriver if the login request is valid.
A ServerOption is a function which applies configuration to a Server.
SourceChecker can be used to decide whether to trust the PROXY info or pass the original connection address through.