Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrFileFingerNotMatch = errors.New("file finger not match")
ErrFileFingerNotMatch 文件指纹不匹配
View Source
var ErrLocalFileExisted = errors.New("local file already exist")
ErrLocalFileExisted 本地已经存在该文件
View Source
var ErrRemoteFileExisted = errors.New("remote file already exist")
ErrRemoteFileExisted 远程服务器已经存在该文件
View Source
var ErrSessionCanceled = errors.New("session canceled because context canceled")
ErrSessionCanceled 会话因为上下文对象的取消而被取消
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { ReceiveFile(dest string, src string, override bool, consistencyCheck bool) (written int64, err error) ReceiveFileOverride(destFilepath string, srcFilepath string) (written int64, err error) ReadFile(src string) ([]byte, error) SendFile(destFilepath string, srcFilepath string, override bool, consistencyCheck bool) (written int64, err error) SendFileOverride(destFilepath string, srcFilepath string) (written int64, err error) WriteFile(destFilepath string, dataReader io.Reader, override bool) (written int64, err error) WriteFileOverride(destFilepath string, dataReader io.Reader) (written int64, err error) Command(ctx context.Context, cmd string, opts ...SessionOption) ([]byte, error) Handle(handler Handler) error }
type Credential ¶
type Credential struct { User string Password string PrivateKey string PrivateKeyPath string PrivateKeyPassphrase string }
Credential Command 连接配置 优先级: Password > PrivateKey > PrivateKeyPath
type DefaultLogger ¶
type DefaultLogger struct{}
DefaultLogger is a default logger
func (DefaultLogger) DebugEnabled ¶
func (DefaultLogger) DebugEnabled() bool
func (DefaultLogger) Debugf ¶
func (DefaultLogger) Debugf(format string, v ...interface{})
type EnhanceClient ¶
type EnhanceClient interface { ReceiveFile(dest string, src string, override bool, consistencyCheck bool) (written int64, err error) ReceiveFileOverride(destFilepath string, srcFilepath string) (written int64, err error) ReadFile(src string) ([]byte, error) SendFile(destFilepath string, srcFilepath string, override bool, consistencyCheck bool) (written int64, err error) SendFileOverride(destFilepath string, srcFilepath string) (written int64, err error) WriteFile(destFilepath string, dataReader io.Reader, override bool) (written int64, err error) WriteFileOverride(destFilepath string, dataReader io.Reader) (written int64, err error) SendDirectory(destDirectory string, srcDirectory string) error SendFiles(destDirectory string, srcFiles ...string) error TempWriteFile(dataReader io.Reader, fn func(tempFilepath string) error) error TempSendFile(srcFilepath string, fn func(tempFilepath string) error) error Command(ctx context.Context, cmd string, opts ...SessionOption) ([]byte, error) Create(path string) (*sftp.File, error) Walk(root string) *fs.Walker ReadDir(p string) ([]os.FileInfo, error) Stat(p string) (os.FileInfo, error) Lstat(p string) (os.FileInfo, error) ReadLink(p string) (string, error) Link(oldname, newname string) error Symlink(oldname, newname string) error Chtimes(path string, atime time.Time, mtime time.Time) error Chown(path string, uid, gid int) error Chmod(path string, mode os.FileMode) error Truncate(path string, size int64) error Open(path string) (*sftp.File, error) OpenFile(path string, f int) (*sftp.File, error) StatVFS(path string) (*sftp.StatVFS, error) Join(elem ...string) string Remove(path string) error RemoveDirectory(path string) error Rename(oldname, newname string) error PosixRename(oldname, newname string) error Getwd() (string, error) Mkdir(path string) error MkdirAll(path string) error Glob(pattern string) (matches []string, err error) }
type Handler ¶
type Handler func(sub EnhanceClient) error
type Option ¶
type Option func(server *sshClient) error
Option 用于设置连接配置
func SetEstablishTimeout ¶
SetEstablishTimeout 设置 ssh 连接建立超时时间
func SetMd5sumBinInServer ¶
SetMd5sumBinInServer 设置远端用于检查文件校验值的命令
type SessionOption ¶
func RequestPty ¶
func RequestPty(width int, height int, terminalModes ...ssh.TerminalModes) SessionOption
Click to show internal directories.
Click to hide internal directories.