Documentation ¶
Overview ¶
Package scp provides a SCP middleware for wish.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NULL = []byte{'\x00'}
NULL is an array with a single NULL byte.
Functions ¶
func Middleware ¶
func Middleware(rh CopyToClientHandler, wh CopyFromClientHandler) wish.Middleware
Middleware provides a wish middleware using the given CopyToClientHandler and CopyFromClientHandler.
Types ¶
type AppendableEntry ¶
type AppendableEntry interface { // Write the current entry in SCP format. Write(io.Writer) error // Append another entry to the current entry. Append(entry Entry) }
AppendableEntry defines a special kind of Entry, which can contain children.
type CopyFromClientHandler ¶
type CopyFromClientHandler interface { // Mkdir should created the given dir. // Note that this usually shouldn't use os.MkdirAll and the like. Mkdir(ssh.Session, *DirEntry) error // Write should write the given file. Write(ssh.Session, *FileEntry) (int64, error) }
CopyFromClientHandler is a handler that can be implemented to handle files being copied from the client to the server.
type CopyToClientHandler ¶
type CopyToClientHandler interface { // Glob should be implemented if you want to provide server-side globbing // support. // // A minimal implementation to disable it is to return `[]string{s}, nil`. // // Note: if your other functions expect a relative path, make sure that // your Glob implementation returns relative paths as well. Glob(ssh.Session, string) ([]string, error) // WalkDir must be implemented if you want to allow recursive copies. WalkDir(ssh.Session, string, fs.WalkDirFunc) error // NewDirEntry should provide a *DirEntry for the given path. NewDirEntry(ssh.Session, string) (*DirEntry, error) // NewFileEntry should provide a *FileEntry for the given path. // Users may also provide a closing function. NewFileEntry(ssh.Session, string) (*FileEntry, func() error, error) }
CopyToClientHandler is a handler that can be implemented to handle files being copied from the server to the client.
func NewFSReadHandler ¶
func NewFSReadHandler(fsys fs.FS) CopyToClientHandler
NewFSReadHandler returns a read-only CopyToClientHandler that accepts any fs.FS as input.
type DirEntry ¶
type DirEntry struct { Children []Entry Name string Filepath string Mode fs.FileMode Atime int64 Mtime int64 }
DirEntry is an Entry with mode, possibly children, and possibly a parent.
type Entry ¶
type Entry interface { // Write the current entry in SCP format. Write(io.Writer) error // contains filtered or unexported methods }
Entry defines something that knows how to write itself and its path.
type FileEntry ¶
type FileEntry struct { Name string Filepath string Mode fs.FileMode Size int64 Reader io.Reader Atime int64 Mtime int64 }
FileEntry is an Entry that reads from a Reader, defining a file and its contents.
type Handler ¶
type Handler interface { CopyFromClientHandler CopyToClientHandler }
Handler is a interface that can be implemented to handle both SCP directions.
func NewFileSystemHandler ¶
NewFileSystemHandler return a Handler based on the given dir.
type Info ¶
type Info struct { // Ok is true if the current session is a SCP. Ok bool // Recursive is true if its a recursive SCP. Recursive bool // Path is the server path of the scp operation. Path string // Op is the SCP operation kind. Op Op }
Info provides some information about the current SCP Operation.