Documentation
¶
Index ¶
- Variables
- func AcceptNewHostKeyCallback(file string) (func(string, net.Addr, ssh.PublicKey) error, error)
- func AcceptNewHostKeyCallbackWithOptions(options AcceptNewHostKeyOptions) (func(string, net.Addr, ssh.PublicKey) error, error)
- func DefaultAllowHostKeyCallback(hostname string, remote net.Addr, key ssh.PublicKey) error
- func FingerprintHostKeyCallback(fingerprints ...string) (func(string, net.Addr, ssh.PublicKey) error, error)
- func KnownHostsHostKeyCallback(files ...string) (func(string, net.Addr, ssh.PublicKey) error, error)
- func NewExecSession(client *ssh.Client) (*ssh.Session, error)
- func NewPTYSession(client *ssh.Client, config *TerminalConfig) (*ssh.Session, error)
- func NewSession(client *ssh.Client) (*ssh.Session, error)
- func NewTransferSession(client *ssh.Client) (*ssh.Session, error)
- func SFTPBool(value bool) *bool
- func SFTPDuration(value time.Duration) *time.Duration
- func SFTPInt(value int) *int
- func SedColor(str string) string
- func SftpTransferIn(src, dst string, sftpClient *sftp.Client) error
- func SftpTransferInByte(remotePath string, sftpClient *sftp.Client) ([]byte, error)
- func SftpTransferInByteWithContext(ctx context.Context, remotePath string, sftpClient *sftp.Client, ...) ([]byte, error)
- func SftpTransferInFunc(src, dst string, bufcap int, rtefunc func(float64), sftpClient *sftp.Client) error
- func SftpTransferInWithContext(ctx context.Context, src, dst string, sftpClient *sftp.Client, ...) error
- func SftpTransferOut(localFilePath, remotePath string, sftpClient *sftp.Client) error
- func SftpTransferOutByte(localData []byte, remotePath string, sftpClient *sftp.Client) error
- func SftpTransferOutByteWithContext(ctx context.Context, localData []byte, remotePath string, ...) error
- func SftpTransferOutFunc(localFilePath, remotePath string, bufcap int, rtefunc func(float64), ...) error
- func SftpTransferOutWithContext(ctx context.Context, localFilePath, remotePath string, sftpClient *sftp.Client, ...) error
- type AcceptNewHostKeyOptions
- type AuthMethodKind
- type DialContextFunc
- type DynamicForwardRequest
- type ExecExitError
- type ExecPool
- func (p *ExecPool) Acquire(ctx context.Context) (*StarSSH, error)
- func (p *ExecPool) Close() error
- func (p *ExecPool) CloseIdle() error
- func (p *ExecPool) Discard(client *StarSSH)
- func (p *ExecPool) Exec(ctx context.Context, req ExecRequest) (*ExecResult, error)
- func (p *ExecPool) ExecStream(ctx context.Context, req ExecRequest, onChunk func(ExecStreamChunk)) (*ExecResult, error)
- func (p *ExecPool) ExecString(ctx context.Context, command string) (*ExecResult, error)
- func (p *ExecPool) Release(client *StarSSH) error
- func (p *ExecPool) Stats() ExecPoolStats
- func (p *ExecPool) WarmUp(ctx context.Context, targetIdle int) error
- type ExecPoolConfig
- type ExecPoolStats
- type ExecRequest
- type ExecResult
- func (r *ExecResult) CombinedString() string
- func (r *ExecResult) CommandError() error
- func (r *ExecResult) OutputTruncated() bool
- func (r *ExecResult) StderrString() string
- func (r *ExecResult) StdoutString() string
- func (r *ExecResult) StreamOutputDropped() bool
- func (r *ExecResult) StreamOverflowError() error
- func (r *ExecResult) Success() bool
- type ExecShellDialect
- type ExecStreamChunk
- type ExecStreamOverflowError
- type ExecStreamOverflowStrategy
- type FS
- type ForwardRequest
- type HostKeyFingerprintMismatchError
- type LoginInput
- type PortForwarder
- type ProxyConfig
- type ProxyType
- type SFTPClientOptions
- type SFTPErrorCategory
- type SFTPFileSystem
- func (fs *SFTPFileSystem) MkdirAll(ctx context.Context, remotePath string) error
- func (fs *SFTPFileSystem) ReadDir(ctx context.Context, remotePath string) ([]os.FileInfo, error)
- func (fs *SFTPFileSystem) ReadFile(ctx context.Context, remotePath string, options *SFTPTransferOptions) ([]byte, error)
- func (fs *SFTPFileSystem) Remove(ctx context.Context, remotePath string) error
- func (fs *SFTPFileSystem) RemoveAll(ctx context.Context, remotePath string) error
- func (fs *SFTPFileSystem) Rename(ctx context.Context, oldPath string, newPath string) error
- func (fs *SFTPFileSystem) Stat(ctx context.Context, remotePath string) (os.FileInfo, error)
- func (fs *SFTPFileSystem) WriteFile(ctx context.Context, remotePath string, data []byte, ...) error
- type SFTPTransferError
- type SFTPTransferOptions
- type SSHAgentDebugEvent
- type SSHAgentDebugFunc
- type ShellExitError
- type ShellRequest
- type StarSSH
- func (s *StarSSH) Close() error
- func (star *StarSSH) CreateSftpClient() (*sftp.Client, error)
- func (s *StarSSH) DialTCP(network string, address string) (net.Conn, error)
- func (s *StarSSH) DialTCPContext(ctx context.Context, network string, address string) (net.Conn, error)
- func (s *StarSSH) DialTCPContextCloseOnCancel(ctx context.Context, network string, address string) (net.Conn, error)
- func (s *StarSSH) Exec(ctx context.Context, req ExecRequest) (*ExecResult, error)
- func (s *StarSSH) ExecStream(ctx context.Context, req ExecRequest, onChunk func(ExecStreamChunk)) (*ExecResult, error)
- func (s *StarSSH) ExecString(ctx context.Context, command string) (*ExecResult, error)
- func (s *StarSSH) Exists(filepath string) bool
- func (star *StarSSH) FS() *SFTPFileSystem
- func (s *StarSSH) GetGid() string
- func (s *StarSSH) GetGroup() string
- func (s *StarSSH) GetUid() string
- func (s *StarSSH) GetUser() string
- func (s *StarSSH) IsFile(filepath string) bool
- func (s *StarSSH) IsFolder(filepath string) bool
- func (star *StarSSH) MkdirAll(remotePath string) error
- func (star *StarSSH) MkdirAllContext(ctx context.Context, remotePath string) error
- func (s *StarSSH) NewExecSession() (*ssh.Session, error)
- func (s *StarSSH) NewPTYSession(config *TerminalConfig) (*ssh.Session, error)
- func (s *StarSSH) NewSession() (*ssh.Session, error)
- func (s *StarSSH) NewShell() (shell *StarShell, err error)
- func (s *StarSSH) NewTerminal(config *TerminalConfig) (*TerminalSession, error)
- func (s *StarSSH) Ping() error
- func (s *StarSSH) PingContext(ctx context.Context) error
- func (s *StarSSH) PingContextCloseOnCancel(ctx context.Context) error
- func (star *StarSSH) ReadDir(remotePath string) ([]os.FileInfo, error)
- func (star *StarSSH) ReadDirContext(ctx context.Context, remotePath string) ([]os.FileInfo, error)
- func (star *StarSSH) ReadFile(remotePath string) ([]byte, error)
- func (star *StarSSH) ReadFileContext(ctx context.Context, remotePath string, options *SFTPTransferOptions) ([]byte, error)
- func (star *StarSSH) Remove(remotePath string) error
- func (star *StarSSH) RemoveAll(remotePath string) error
- func (star *StarSSH) RemoveAllContext(ctx context.Context, remotePath string) error
- func (star *StarSSH) RemoveContext(ctx context.Context, remotePath string) error
- func (star *StarSSH) Rename(oldPath string, newPath string) error
- func (star *StarSSH) RenameContext(ctx context.Context, oldPath string, newPath string) error
- func (s *StarSSH) RequestAgentForwarding(session *ssh.Session) error
- func (star *StarSSH) SftpTransferIn(src, dst string) error
- func (star *StarSSH) SftpTransferInByte(remotePath string) ([]byte, error)
- func (star *StarSSH) SftpTransferInByteContext(ctx context.Context, remotePath string, options *SFTPTransferOptions) ([]byte, error)
- func (star *StarSSH) SftpTransferInContext(ctx context.Context, src, dst string, options *SFTPTransferOptions) error
- func (star *StarSSH) SftpTransferInFunc(src, dst string, bufcap int, rtefunc func(float64)) error
- func (star *StarSSH) SftpTransferOut(localFilePath, remotePath string) error
- func (star *StarSSH) SftpTransferOutByte(localData []byte, remotePath string) error
- func (star *StarSSH) SftpTransferOutByteContext(ctx context.Context, localData []byte, remotePath string, ...) error
- func (star *StarSSH) SftpTransferOutContext(ctx context.Context, localFilePath, remotePath string, ...) error
- func (star *StarSSH) SftpTransferOutFunc(localFilePath, remotePath string, bufcap int, rtefunc func(float64)) error
- func (s *StarSSH) ShellOne(cmd string) (string, error)
- func (s *StarSSH) ShellOneShowScreen(cmd string) (string, error)
- func (s *StarSSH) ShellOneShowScreenResult(cmd string) (*ExecResult, error)
- func (s *StarSSH) ShellOneToFunc(cmd string, callback func(string)) (string, error)
- func (s *StarSSH) ShellOneToFuncResult(cmd string, callback func(string)) (*ExecResult, error)
- func (s *StarSSH) StartDynamicForward(req DynamicForwardRequest) (*PortForwarder, error)
- func (s *StarSSH) StartDynamicForwardDetached(req DynamicForwardRequest) (*PortForwarder, error)
- func (s *StarSSH) StartLocalForward(req ForwardRequest) (*PortForwarder, error)
- func (s *StarSSH) StartLocalForwardDetached(req ForwardRequest) (*PortForwarder, error)
- func (s *StarSSH) StartLocalTCPForward(listenAddr string, targetAddr string) (*PortForwarder, error)
- func (s *StarSSH) StartLocalTCPForwardDetached(listenAddr string, targetAddr string) (*PortForwarder, error)
- func (s *StarSSH) StartLocalTCPToUnixForward(listenAddr string, targetPath string) (*PortForwarder, error)
- func (s *StarSSH) StartLocalTCPToUnixForwardDetached(listenAddr string, targetPath string) (*PortForwarder, error)
- func (s *StarSSH) StartLocalUnixForward(listenPath string, targetAddr string) (*PortForwarder, error)
- func (s *StarSSH) StartLocalUnixForwardDetached(listenPath string, targetAddr string) (*PortForwarder, error)
- func (s *StarSSH) StartLocalUnixToUnixForward(listenPath string, targetPath string) (*PortForwarder, error)
- func (s *StarSSH) StartLocalUnixToUnixForwardDetached(listenPath string, targetPath string) (*PortForwarder, error)
- func (s *StarSSH) StartRemoteForward(req ForwardRequest) (*PortForwarder, error)
- func (s *StarSSH) StartRemoteTCPForward(listenAddr string, targetAddr string) (*PortForwarder, error)
- func (s *StarSSH) StartRemoteTCPToUnixForward(listenAddr string, targetPath string) (*PortForwarder, error)
- func (s *StarSSH) StartRemoteUnixForward(listenPath string, targetAddr string) (*PortForwarder, error)
- func (s *StarSSH) StartRemoteUnixToUnixForward(listenPath string, targetPath string) (*PortForwarder, error)
- func (star *StarSSH) Stat(remotePath string) (os.FileInfo, error)
- func (star *StarSSH) StatContext(ctx context.Context, remotePath string) (os.FileInfo, error)
- func (star *StarSSH) WriteFile(remotePath string, data []byte) error
- func (star *StarSSH) WriteFileContext(ctx context.Context, remotePath string, data []byte, ...) error
- type StarShell
- func (s *StarShell) Clear()
- func (s *StarShell) Close() error
- func (s *StarShell) GetGid() string
- func (s *StarShell) GetGroup() string
- func (s *StarShell) GetResult(sleep int) ([]byte, []byte, error)
- func (s *StarShell) GetUid() string
- func (s *StarShell) GetUser() string
- func (s *StarShell) Run(ctx context.Context, req ShellRequest) (*ExecResult, error)
- func (s *StarShell) RunString(ctx context.Context, command string) (*ExecResult, error)
- func (s *StarShell) SetFunc(funcs func(string))
- func (s *StarShell) Shell(cmd string, sleep int) (string, string, error)
- func (s *StarShell) ShellClear(cmd string, sleep int) (string, string, error)
- func (s *StarShell) ShellWait(cmd string) (string, string, error)
- func (s *StarShell) SwitchEcho(run bool)
- func (s *StarShell) SwitchFunc(run bool)
- func (s *StarShell) SwitchNoColor(run bool)
- func (s *StarShell) SwitchPrint(run bool)
- func (s *StarShell) TrimColor(str string) string
- func (s *StarShell) Write(bstr []byte) error
- func (s *StarShell) WriteCommand(cmd string) error
- type TerminalCloseReason
- type TerminalConfig
- type TerminalControl
- type TerminalExitInfo
- type TerminalInputAdapter
- type TerminalInputCanceler
- type TerminalInputSourceProvider
- type TerminalSession
- func (t *TerminalSession) AttachIO(stdin io.Reader, stdout io.Writer, stderr io.Writer)
- func (t *TerminalSession) Close() error
- func (t *TerminalSession) ExitInfo() TerminalExitInfo
- func (t *TerminalSession) Interrupt() error
- func (t *TerminalSession) Resize(columns int, rows int) error
- func (t *TerminalSession) Run(ctx context.Context) error
- func (t *TerminalSession) SendControl(control TerminalControl) error
- func (t *TerminalSession) Signal(sig ssh.Signal) error
- func (t *TerminalSession) StderrReader() io.Reader
- func (t *TerminalSession) StdinWriter() io.Writer
- func (t *TerminalSession) StdoutReader() io.Reader
- func (t *TerminalSession) Wait() error
- func (t *TerminalSession) WaitResult() (TerminalExitInfo, error)
- func (t *TerminalSession) Write(data []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
var ErrExecPoolClosed = errors.New("exec pool is closed")
var ErrHostFingerprintRequired = errors.New("host key fingerprint is required")
var ErrHostKeyCallbackRequired = errors.New("host key callback is required; use DefaultAllowHostKeyCallback to explicitly allow any host key")
var ErrKnownHostsFileRequired = errors.New("known_hosts file is required")
var ErrSSHAgentTimeout = errors.New("ssh-agent timeout")
Functions ¶
func NewPTYSession ¶
func SftpTransferInByte ¶
func SftpTransferInFunc ¶
func SftpTransferOut ¶
func SftpTransferOutByte ¶
func SftpTransferOutFunc ¶
Types ¶
type AcceptNewHostKeyOptions ¶
type AuthMethodKind ¶
type AuthMethodKind string
const ( AuthMethodPrivateKey AuthMethodKind = "private_key" AuthMethodPassword AuthMethodKind = "password" AuthMethodKeyboardInteractive AuthMethodKind = "keyboard_interactive" AuthMethodSSHAgent AuthMethodKind = "ssh_agent" )
type DialContextFunc ¶
type DynamicForwardRequest ¶
type DynamicForwardRequest struct {
ListenAddr string
}
type ExecExitError ¶
func (*ExecExitError) Error ¶
func (e *ExecExitError) Error() string
func (*ExecExitError) ExitStatus ¶
func (e *ExecExitError) ExitStatus() int
type ExecPool ¶
type ExecPool struct {
// contains filtered or unexported fields
}
func NewExecPool ¶
func NewExecPool(config ExecPoolConfig) *ExecPool
func (*ExecPool) Exec ¶
func (p *ExecPool) Exec(ctx context.Context, req ExecRequest) (*ExecResult, error)
func (*ExecPool) ExecStream ¶
func (p *ExecPool) ExecStream(ctx context.Context, req ExecRequest, onChunk func(ExecStreamChunk)) (*ExecResult, error)
func (*ExecPool) ExecString ¶
func (*ExecPool) Stats ¶
func (p *ExecPool) Stats() ExecPoolStats
type ExecPoolConfig ¶
type ExecPoolStats ¶
type ExecRequest ¶
type ExecRequest struct {
Command string
Stdin []byte
Env map[string]string
Dir string
ShellDialect ExecShellDialect
Timeout time.Duration
PTY *TerminalConfig
DiscardOutput bool
MaxOutputBytes int
StreamMaxPendingChunks int
StreamMaxPendingBytes int
StreamOverflowStrategy ExecStreamOverflowStrategy
}
type ExecResult ¶
type ExecResult struct {
Command string
Stdout []byte
Stderr []byte
Combined []byte
StdoutTruncated bool
StderrTruncated bool
CombinedTruncated bool
StreamDroppedChunks int
StreamDroppedBytes int
ExitCode int
ExitSignal string
ExitMessage string
Duration time.Duration
}
func (*ExecResult) CombinedString ¶
func (r *ExecResult) CombinedString() string
func (*ExecResult) CommandError ¶
func (r *ExecResult) CommandError() error
func (*ExecResult) OutputTruncated ¶
func (r *ExecResult) OutputTruncated() bool
func (*ExecResult) StderrString ¶
func (r *ExecResult) StderrString() string
func (*ExecResult) StdoutString ¶
func (r *ExecResult) StdoutString() string
func (*ExecResult) StreamOutputDropped ¶
func (r *ExecResult) StreamOutputDropped() bool
func (*ExecResult) StreamOverflowError ¶
func (r *ExecResult) StreamOverflowError() error
func (*ExecResult) Success ¶
func (r *ExecResult) Success() bool
type ExecShellDialect ¶
type ExecShellDialect string
const ( ExecShellDialectPOSIX ExecShellDialect = "posix" ExecShellDialectPowerShell ExecShellDialect = "powershell" ExecShellDialectCMD ExecShellDialect = "cmd" ExecShellDialectRaw ExecShellDialect = "raw" )
type ExecStreamChunk ¶
type ExecStreamOverflowError ¶
func (*ExecStreamOverflowError) Error ¶
func (e *ExecStreamOverflowError) Error() string
type ExecStreamOverflowStrategy ¶
type ExecStreamOverflowStrategy string
const ( ExecStreamOverflowDropOldest ExecStreamOverflowStrategy = "drop_oldest" ExecStreamOverflowDropNewest ExecStreamOverflowStrategy = "drop_newest" ExecStreamOverflowFail ExecStreamOverflowStrategy = "fail" )
type FS ¶
type FS interface {
Stat(context.Context, string) (os.FileInfo, error)
ReadDir(context.Context, string) ([]os.FileInfo, error)
ReadFile(context.Context, string, *SFTPTransferOptions) ([]byte, error)
WriteFile(context.Context, string, []byte, *SFTPTransferOptions) error
MkdirAll(context.Context, string) error
Remove(context.Context, string) error
RemoveAll(context.Context, string) error
Rename(context.Context, string, string) error
}
type ForwardRequest ¶
type ForwardRequest struct {
// Keep the exported shape compatible with older positional literals:
// ForwardRequest{listenAddr, targetAddr, dialContext}.
//
// Non-default networks can be encoded with an explicit scheme-like prefix:
// "tcp4://127.0.0.1:22", "tcp6://[::1]:22", "unix:///tmp/socket".
// Bare values default to the "tcp" network.
ListenAddr string
TargetAddr string
DialContext DialContextFunc
}
type HostKeyFingerprintMismatchError ¶
type HostKeyFingerprintMismatchError struct {
Expected []string
ActualSHA256 string
ActualLegacyMD5 string
}
func (*HostKeyFingerprintMismatchError) Error ¶
func (e *HostKeyFingerprintMismatchError) Error() string
type LoginInput ¶
type LoginInput struct {
KeyExchanges []string
Ciphers []string
MACs []string
User string
Password string
PasswordCallback func() (string, error)
KeyboardInteractiveCallback ssh.KeyboardInteractiveChallenge
Prikey string
PrikeyPwd string
DisableSSHAgent bool
ForwardSSHAgent bool
AuthOrder []AuthMethodKind
// IdentityAgent overrides the local ssh-agent endpoint used for authentication
// and agent forwarding. Empty uses SSH_AUTH_SOCK, or the platform default where
// one exists.
IdentityAgent string
Addr string
Port int
// Timeout limits the SSH handshake/authentication phase after a TCP connection has
// already been established. Zero means no authentication timeout.
Timeout time.Duration
// DialTimeout limits outbound dial steps such as TCP connect, proxy connect, and
// local ssh-agent socket connect. Zero falls back to Timeout when set, otherwise
// uses the package default dial timeout. Negative disables the default dial timeout.
DialTimeout time.Duration
// SSHAgentTimeout limits ssh-agent protocol operations such as listing keys and
// signing challenges. Zero uses the package default, and negative disables the
// per-operation deadline. This is intentionally separate from Timeout and
// DialTimeout because hardware-backed agents may require a PIN or touch confirmation.
SSHAgentTimeout time.Duration
// SSHAgentForwardTimeout limits idle reads and writes on forwarded agent
// channels. Zero or negative leaves forwarded channels without an idle deadline.
SSHAgentForwardTimeout time.Duration
// SSHAgentDebug receives structured ssh-agent dial/protocol events. It is nil by
// default and must not log private key material.
SSHAgentDebug SSHAgentDebugFunc
DialContext DialContextFunc
Proxy *ProxyConfig
Jump *LoginInput
KeepAliveInterval time.Duration
KeepAliveTimeout time.Duration
HostKeyCallback func(string, net.Addr, ssh.PublicKey) error
BannerCallback func(string) error
}
type PortForwarder ¶
type PortForwarder struct {
// contains filtered or unexported fields
}
func (*PortForwarder) Addr ¶
func (f *PortForwarder) Addr() net.Addr
func (*PortForwarder) Close ¶
func (f *PortForwarder) Close() error
func (*PortForwarder) Err ¶
func (f *PortForwarder) Err() error
func (*PortForwarder) Wait ¶
func (f *PortForwarder) Wait() error
type ProxyConfig ¶
type SFTPClientOptions ¶ added in v0.1.4
type SFTPClientOptions struct {
MaxPacketSize int
MaxConcurrentRequestsPerFile int
ConcurrentReads *bool
ConcurrentWrites *bool
}
SFTPClientOptions controls the underlying SFTP protocol client.
These options only apply when StarSSH creates the SFTP client internally. They are intentionally separate from BufferSize, which only controls the local copy buffer used by transfer progress reporting.
type SFTPErrorCategory ¶
type SFTPErrorCategory string
const ( SFTPErrorRetryable SFTPErrorCategory = "retryable" SFTPErrorPermanent SFTPErrorCategory = "permanent" )
type SFTPFileSystem ¶
type SFTPFileSystem struct {
// contains filtered or unexported fields
}
func (*SFTPFileSystem) MkdirAll ¶
func (fs *SFTPFileSystem) MkdirAll(ctx context.Context, remotePath string) error
func (*SFTPFileSystem) ReadFile ¶
func (fs *SFTPFileSystem) ReadFile(ctx context.Context, remotePath string, options *SFTPTransferOptions) ([]byte, error)
func (*SFTPFileSystem) Remove ¶
func (fs *SFTPFileSystem) Remove(ctx context.Context, remotePath string) error
func (*SFTPFileSystem) RemoveAll ¶
func (fs *SFTPFileSystem) RemoveAll(ctx context.Context, remotePath string) error
func (*SFTPFileSystem) WriteFile ¶
func (fs *SFTPFileSystem) WriteFile(ctx context.Context, remotePath string, data []byte, options *SFTPTransferOptions) error
type SFTPTransferError ¶
type SFTPTransferError struct {
Operation string
LocalPath string
RemotePath string
Attempt int
Category SFTPErrorCategory
Err error
}
func (*SFTPTransferError) Error ¶
func (e *SFTPTransferError) Error() string
func (*SFTPTransferError) Unwrap ¶
func (e *SFTPTransferError) Unwrap() error
type SFTPTransferOptions ¶
type SFTPTransferOptions struct {
BufferSize int
Progress func(float64)
RetryCount *int
RetryInitialBackoff *time.Duration
AtomicUpload *bool
AtomicDownload *bool
VerifySize *bool
VerifyChecksum *bool
TempSuffix string
Client SFTPClientOptions
}
func DefaultSFTPTransferOptions ¶
func DefaultSFTPTransferOptions() SFTPTransferOptions
func ThroughputSFTPTransferOptions ¶ added in v0.1.4
func ThroughputSFTPTransferOptions() SFTPTransferOptions
type SSHAgentDebugEvent ¶ added in v0.1.3
type SSHAgentDebugFunc ¶ added in v0.1.3
type SSHAgentDebugFunc func(SSHAgentDebugEvent)
type ShellExitError ¶
type ShellExitError = ExecExitError
type ShellRequest ¶
type StarSSH ¶
type StarSSH struct {
Client *ssh.Client
PublicKey ssh.PublicKey
PubkeyBase64 string
Hostname string
RemoteAddr net.Addr
Banner string
LoginInfo LoginInput
// contains filtered or unexported fields
}
func Login ¶
func Login(info LoginInput) (*StarSSH, error)
func LoginContext ¶
func LoginContext(ctx context.Context, info LoginInput) (*StarSSH, error)
func LoginSimple ¶
func (*StarSSH) DialTCPContext ¶
func (*StarSSH) DialTCPContextCloseOnCancel ¶
func (*StarSSH) Exec ¶
func (s *StarSSH) Exec(ctx context.Context, req ExecRequest) (*ExecResult, error)
func (*StarSSH) ExecStream ¶
func (s *StarSSH) ExecStream(ctx context.Context, req ExecRequest, onChunk func(ExecStreamChunk)) (*ExecResult, error)
func (*StarSSH) ExecString ¶
func (*StarSSH) FS ¶
func (star *StarSSH) FS() *SFTPFileSystem
func (*StarSSH) MkdirAllContext ¶
func (*StarSSH) NewPTYSession ¶
func (s *StarSSH) NewPTYSession(config *TerminalConfig) (*ssh.Session, error)
func (*StarSSH) NewShell ¶
NewShell creates the legacy prompt-driven POSIX shell helper. For raw interactive terminal flows, prefer NewTerminal.
func (*StarSSH) NewTerminal ¶
func (s *StarSSH) NewTerminal(config *TerminalConfig) (*TerminalSession, error)
func (*StarSSH) PingContextCloseOnCancel ¶
func (*StarSSH) ReadDirContext ¶
func (*StarSSH) ReadFileContext ¶
func (*StarSSH) RemoveAllContext ¶
func (*StarSSH) RemoveContext ¶
func (*StarSSH) RenameContext ¶
func (*StarSSH) RequestAgentForwarding ¶ added in v0.1.1
func (*StarSSH) SftpTransferIn ¶
func (*StarSSH) SftpTransferInByte ¶
func (*StarSSH) SftpTransferInByteContext ¶
func (*StarSSH) SftpTransferInContext ¶
func (*StarSSH) SftpTransferInFunc ¶
func (*StarSSH) SftpTransferOut ¶
func (*StarSSH) SftpTransferOutByte ¶
func (*StarSSH) SftpTransferOutByteContext ¶
func (*StarSSH) SftpTransferOutContext ¶
func (*StarSSH) SftpTransferOutFunc ¶
func (*StarSSH) ShellOneShowScreen ¶
func (*StarSSH) ShellOneShowScreenResult ¶
func (s *StarSSH) ShellOneShowScreenResult(cmd string) (*ExecResult, error)
func (*StarSSH) ShellOneToFunc ¶
func (*StarSSH) ShellOneToFuncResult ¶
func (s *StarSSH) ShellOneToFuncResult(cmd string, callback func(string)) (*ExecResult, error)
func (*StarSSH) StartDynamicForward ¶
func (s *StarSSH) StartDynamicForward(req DynamicForwardRequest) (*PortForwarder, error)
func (*StarSSH) StartDynamicForwardDetached ¶
func (s *StarSSH) StartDynamicForwardDetached(req DynamicForwardRequest) (*PortForwarder, error)
func (*StarSSH) StartLocalForward ¶
func (s *StarSSH) StartLocalForward(req ForwardRequest) (*PortForwarder, error)
func (*StarSSH) StartLocalForwardDetached ¶
func (s *StarSSH) StartLocalForwardDetached(req ForwardRequest) (*PortForwarder, error)
func (*StarSSH) StartLocalTCPForward ¶ added in v0.1.1
func (s *StarSSH) StartLocalTCPForward(listenAddr string, targetAddr string) (*PortForwarder, error)
func (*StarSSH) StartLocalTCPForwardDetached ¶ added in v0.1.1
func (s *StarSSH) StartLocalTCPForwardDetached(listenAddr string, targetAddr string) (*PortForwarder, error)
func (*StarSSH) StartLocalTCPToUnixForward ¶ added in v0.1.1
func (s *StarSSH) StartLocalTCPToUnixForward(listenAddr string, targetPath string) (*PortForwarder, error)
func (*StarSSH) StartLocalTCPToUnixForwardDetached ¶ added in v0.1.1
func (s *StarSSH) StartLocalTCPToUnixForwardDetached(listenAddr string, targetPath string) (*PortForwarder, error)
func (*StarSSH) StartLocalUnixForward ¶ added in v0.1.1
func (s *StarSSH) StartLocalUnixForward(listenPath string, targetAddr string) (*PortForwarder, error)
func (*StarSSH) StartLocalUnixForwardDetached ¶ added in v0.1.1
func (s *StarSSH) StartLocalUnixForwardDetached(listenPath string, targetAddr string) (*PortForwarder, error)
func (*StarSSH) StartLocalUnixToUnixForward ¶ added in v0.1.1
func (s *StarSSH) StartLocalUnixToUnixForward(listenPath string, targetPath string) (*PortForwarder, error)
func (*StarSSH) StartLocalUnixToUnixForwardDetached ¶ added in v0.1.1
func (s *StarSSH) StartLocalUnixToUnixForwardDetached(listenPath string, targetPath string) (*PortForwarder, error)
func (*StarSSH) StartRemoteForward ¶
func (s *StarSSH) StartRemoteForward(req ForwardRequest) (*PortForwarder, error)
func (*StarSSH) StartRemoteTCPForward ¶ added in v0.1.1
func (s *StarSSH) StartRemoteTCPForward(listenAddr string, targetAddr string) (*PortForwarder, error)
func (*StarSSH) StartRemoteTCPToUnixForward ¶ added in v0.1.1
func (s *StarSSH) StartRemoteTCPToUnixForward(listenAddr string, targetPath string) (*PortForwarder, error)
func (*StarSSH) StartRemoteUnixForward ¶ added in v0.1.1
func (s *StarSSH) StartRemoteUnixForward(listenPath string, targetAddr string) (*PortForwarder, error)
func (*StarSSH) StartRemoteUnixToUnixForward ¶ added in v0.1.1
func (s *StarSSH) StartRemoteUnixToUnixForward(listenPath string, targetPath string) (*PortForwarder, error)
func (*StarSSH) StatContext ¶
func (*StarSSH) WriteFileContext ¶
type StarShell ¶
type StarShell struct {
Keyword string
UseWaitDefault bool
WaitTimeout time.Duration
Session *ssh.Session
// contains filtered or unexported fields
}
StarShell keeps the legacy prompt-driven helper for POSIX-style scripted shell interactions. It is not a generic cross-shell abstraction; for product-grade interactive terminals, prefer TerminalSession.
func (*StarShell) Run ¶
func (s *StarShell) Run(ctx context.Context, req ShellRequest) (*ExecResult, error)
func (*StarShell) ShellClear ¶
func (*StarShell) SwitchEcho ¶
func (*StarShell) SwitchFunc ¶
本函数控制是否立即处理远程Shell输出每一行内容[true|false]
func (*StarShell) SwitchNoColor ¶
func (*StarShell) SwitchPrint ¶
本函数控制是否在本地屏幕上打印远程Shell的输出内容[true|false]
func (*StarShell) WriteCommand ¶
type TerminalCloseReason ¶
type TerminalCloseReason string
const ( TerminalCloseReasonUnknown TerminalCloseReason = "" TerminalCloseReasonExit TerminalCloseReason = "exit" TerminalCloseReasonSignal TerminalCloseReason = "signal" TerminalCloseReasonClosed TerminalCloseReason = "closed" TerminalCloseReasonContextCanceled TerminalCloseReason = "context_canceled" TerminalCloseReasonDeadlineExceeded TerminalCloseReason = "deadline_exceeded" TerminalCloseReasonTransportError TerminalCloseReason = "transport_error" )
type TerminalConfig ¶
type TerminalConfig struct {
Term string
Rows int
Columns int
Modes ssh.TerminalModes
}
type TerminalControl ¶
type TerminalControl byte
const ( TerminalControlInterrupt TerminalControl = 0x03 TerminalControlEOF TerminalControl = 0x04 TerminalControlBell TerminalControl = 0x07 TerminalControlBackspace TerminalControl = 0x08 TerminalControlLineKill TerminalControl = 0x15 TerminalControlQuit TerminalControl = 0x1c TerminalControlSuspend TerminalControl = 0x1a TerminalControlPauseOutput TerminalControl = 0x13 TerminalControlResumeOutput TerminalControl = 0x11 )
type TerminalExitInfo ¶
type TerminalExitInfo struct {
ExitCode int
ExitSignal string
ExitMessage string
Reason TerminalCloseReason
}
func (TerminalExitInfo) CommandError ¶
func (info TerminalExitInfo) CommandError() error
func (TerminalExitInfo) Success ¶
func (info TerminalExitInfo) Success() bool
type TerminalInputAdapter ¶
TerminalInputAdapter adapts wrapper readers into a cancelable terminal input source. Reader is what TerminalSession consumes, Source is the closer-friendly underlying reader when available.
func (TerminalInputAdapter) TerminalInputCancel ¶
func (a TerminalInputAdapter) TerminalInputCancel() error
func (TerminalInputAdapter) TerminalInputSource ¶
func (a TerminalInputAdapter) TerminalInputSource() io.Reader
type TerminalInputCanceler ¶
type TerminalInputCanceler interface {
TerminalInputCancel() error
}
TerminalInputCanceler lets wrapper readers expose an explicit cancellation hook. It is useful for line editors or custom buffered readers that cannot safely expose a raw io.ReadCloser.
type TerminalInputSourceProvider ¶
TerminalInputSourceProvider lets wrapper readers expose a closer-friendly source reader. Implementations that buffer data should return a source that already includes any prefetched bytes.
type TerminalSession ¶
type TerminalSession struct {
Session *ssh.Session
ID string
Label string
Metadata map[string]string
// contains filtered or unexported fields
}
func (*TerminalSession) Close ¶
func (t *TerminalSession) Close() error
func (*TerminalSession) ExitInfo ¶
func (t *TerminalSession) ExitInfo() TerminalExitInfo
func (*TerminalSession) Interrupt ¶
func (t *TerminalSession) Interrupt() error
func (*TerminalSession) SendControl ¶
func (t *TerminalSession) SendControl(control TerminalControl) error
func (*TerminalSession) StderrReader ¶
func (t *TerminalSession) StderrReader() io.Reader
func (*TerminalSession) StdinWriter ¶
func (t *TerminalSession) StdinWriter() io.Writer
func (*TerminalSession) StdoutReader ¶
func (t *TerminalSession) StdoutReader() io.Reader
func (*TerminalSession) Wait ¶
func (t *TerminalSession) Wait() error
func (*TerminalSession) WaitResult ¶
func (t *TerminalSession) WaitResult() (TerminalExitInfo, error)