transfer

package
v0.0.0-...-f332f66 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package transfer implements SCP (one-shot copy) and SFTP (interactive REPL) over an existing *ssh.Client. Reuses sshc's ConnectAlias chain (proxy_jump, proxy_command, password backends) so transfers go through the same tunnels as interactive shells.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadDir

func DownloadDir(sc *sftp.Client, remote, local, alias string) error

DownloadDir recursively downloads remote directory to local path.

func DownloadFile

func DownloadFile(sc *sftp.Client, remote, local, alias string) error

DownloadFile copies a single remote file to local path via sc, logging the transfer under alias (which appears in TransferHistory).

func HumanBytes

func HumanBytes(n int64) string

HumanBytes formats a byte count with KiB/MiB/GiB suffix. Exported so the TUI and CLI can share one implementation.

func SCP

func SCP(client *ssh.Client, src, dst string, recursive bool) error

func SFTP

func SFTP(client *ssh.Client, alias string) error

SFTP starts an interactive SFTP REPL over client. Supported commands:

help / ?
ls [path]               list remote dir
lls [path]              list local dir
cd <path>               change remote dir
lcd <path>              change local dir
pwd                     print remote cwd
lpwd                    print local cwd
get <remote> [local]    download file
put <local>  [remote]   upload file
rm <path>               remove remote file
mkdir <path>            create remote directory
rmdir <path>            remove remote (empty) directory
exit / quit / bye       leave

func UploadDir

func UploadDir(sc *sftp.Client, local, remote, alias string) error

UploadDir recursively uploads local directory to remote path.

func UploadFile

func UploadFile(sc *sftp.Client, local, remote, alias string) error

UploadFile copies a single local file to remote path via sc.

Types

type Direction

type Direction int

SCP copies a single file (or, with recursive=true, a directory tree) between the local filesystem and a remote host reached through client. Direction is inferred from src/dst — exactly one must be of the form alias:/path; alias here is informational (the actual client is already connected).

Both paths use forward slashes; remote paths are interpreted relative to the SSH user's home if not absolute.

const (
	Upload Direction = iota
	Download
)

type Logger

type Logger func(direction, alias, local, remote string, bytes int64, when time.Time)

Logger receives a record for every completed file transfer. The default is a no-op; main wires this to persist into config.TransferHistory.

var Log Logger = func(string, string, string, string, int64, time.Time) {}

Log is the package-level transfer logger. Replace at process start.

Jump to

Keyboard shortcuts

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