sshbash

package
v0.0.0-...-42f112a Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2016 License: GPL-3.0 Imports: 9 Imported by: 0

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 BufferWriter

type BufferWriter struct {
	// contains filtered or unexported fields
}

输出的缓存写对象

func (*BufferWriter) Write

func (w *BufferWriter) Write(p []byte) (int, error)

BufferWriter的写方法

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

获取输出结果, 并将返回清空

func (*OutputBuffer) Write

func (buff *OutputBuffer) Write(piece OutputBufferPiece)

写入一个缓冲区数据

type OutputBufferPiece

type OutputBufferPiece struct {
	// contains filtered or unexported fields
}

一次输入的片段

func NewOutputBufferPiece

func NewOutputBufferPiece(buffType int, content []byte) OutputBufferPiece

创建一个新的

type SSHLoginInfo

type SSHLoginInfo struct {
	Ip       string
	Port     string
	Username string
	Password string
	Key      []byte
}

SSH的登录信息, Key和string只能有一个生效, Key如果不为nil, 将优先使用

type SshExecutor

type SshExecutor struct {

	//执行器的登录信息, 包括SSH登录需要的所有信息
	LoginInfo *SSHLoginInfo
	// contains filtered or unexported fields
}

func (*SshExecutor) Destory

func (sshe *SshExecutor) Destory()

销毁执行器

func (*SshExecutor) Execute

func (sshe *SshExecutor) Execute(cmd string, timeout int) ([]commons.ResultOutput, error)

执行指令, 执行的指令为cmd, 如果timeout秒没有执行完成, 将会超时, 返回错误

func (*SshExecutor) Init

func (sshe *SshExecutor) Init()

初始化SSH执行器

func (*SshExecutor) IsLogin

func (sshe *SshExecutor) IsLogin() bool

SshExcutor是否完成了登录

func (*SshExecutor) IsReady

func (sshe *SshExecutor) IsReady() bool

和IsLogin相同, 但这个方法是executor.Executor接口的一个方法

Jump to

Keyboard shortcuts

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