Documentation
¶
Overview ¶
sshbash包是一个远程SSH SHELL执行器,它会连接远端SSH服务器,并在运行上边的bash 并在bash上执行指令
Index ¶
Constants ¶
View Source
const ( UNKNOWN = 0 STDOUT = 1 STDERR = 2 )
输入输出类型, 为OutputBuffer.buffByteType所用
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MixWriterBuffer ¶
type MixWriterBuffer struct {
// contains filtered or unexported fields
}
混合写缓存, 这个类会将STDOUT和STDERR混合成一个BUFFER,并保证顺序. 同时结果保存 为[]ResultOutput, 方便后续调用者
func (*MixWriterBuffer) Add ¶
func (buff *MixWriterBuffer) Add(resultOutput commons.ResultOutput, isLineFinished bool)
将ResultOutput加入到buffer中, 如果上一行没有完isLineFinished 为false, 这样如 果下一次加入的ResultOutput类型与上一次的相同, 会将两次的类型合并
func (*MixWriterBuffer) GetOutputSetAndClear ¶
func (buff *MixWriterBuffer) GetOutputSetAndClear() []commons.ResultOutput
获取Buffer的输出结果, 并清空
type OutputBuffer ¶
type OutputBuffer struct {
// contains filtered or unexported fields
}
输入穿冲区,这个穿冲区的读写都会多线程安全的
func (*OutputBuffer) GetOutputAndClear ¶
func (buff *OutputBuffer) GetOutputAndClear() []commons.ResultOutput
获取输出结果, 并将返回清空
type OutputBufferPiece ¶
type OutputBufferPiece struct {
// contains filtered or unexported fields
}
一次输入的片段
func NewOutputBufferPiece ¶
func NewOutputBufferPiece(buffType int, content []byte) OutputBufferPiece
创建一个新的
type SSHLoginInfo ¶
SSH的登录信息, Key和string只能有一个生效, Key如果不为nil, 将优先使用
type SshExecutor ¶
type SshExecutor struct { //执行器的登录信息, 包括SSH登录需要的所有信息 LoginInfo *SSHLoginInfo // contains filtered or unexported fields }
func (*SshExecutor) Execute ¶
func (sshe *SshExecutor) Execute(cmd string, timeout int) ([]commons.ResultOutput, error)
执行指令, 执行的指令为cmd, 如果timeout秒没有执行完成, 将会超时, 返回错误
func (*SshExecutor) IsReady ¶
func (sshe *SshExecutor) IsReady() bool
和IsLogin相同, 但这个方法是executor.Executor接口的一个方法
Click to show internal directories.
Click to hide internal directories.