Documentation
¶
Index ¶
- Constants
- type Bridge
- type PtyConfig
- type SshConfig
- func (h *SshConfig) Close()
- func (h *SshConfig) CloseBridge()
- func (h *SshConfig) CloseFirstReceiveMsg()
- func (h *SshConfig) CloseTerminal()
- func (h *SshConfig) ConnectAuthPassword() error
- func (h *SshConfig) Debugf(msg string, params ...interface{})
- func (h *SshConfig) Errof(msg string, params ...interface{})
- func (h *SshConfig) RunBridge(targetHostPort string) (string, error)
- func (h *SshConfig) RunCommand(command string) error
- func (h *SshConfig) RunCommandOnce(shell string) string
- func (h *SshConfig) RunCommandWait(command string) (string, error)
- func (h *SshConfig) RunWaitTimeout(ctx context.Context)
- func (h *SshConfig) SetCombineNum(combineNum int)
- func (h *SshConfig) SetFuncBefore(before func(string) string)
- func (h *SshConfig) SetFuncBroken(broken func())
- func (h *SshConfig) SetFuncEndCommand(f func())
- func (h *SshConfig) SetFuncReceiveMsg(receive func(string) string)
- func (h *SshConfig) SetFuncStartCommand(f func())
- func (h *SshConfig) SetFuncStreamReceive(receive func(string))
- func (h *SshConfig) SetMaxBufferSize(maxBuffer int)
- func (h *SshConfig) SetMaxRunSecond(maxRnuSecond int)
- func (h *SshConfig) SetPtyConfig(ptyConfig PtyConfig)
- func (h *SshConfig) UploadFile(remoteFilePath, fileContent, filePath string) error
- func (h *SshConfig) UploadFileProcess(remoteFilePath, localFilePath string, ...) error
- func (h *SshConfig) UploadFileProcessScp(remoteFilePath, localFilePath string, ...) error
- func (h *SshConfig) UploadFileSCP(remoteFilePath, localFilePath string, expired time.Duration) error
- type Terminal
Constants ¶
View Source
const ( RunTypeTerminal = iota + 1 RunTypeBridge )
View Source
const ( StatusWait = iota + 1 StatusRunning StatusError StatusStop )
View Source
const EndCommand = `THIS_IS_END_POINT`
View Source
const SshBroken = `notice : ssh connection is broken`
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PtyConfig ¶ added in v1.9.3
type PtyConfig struct {
Term string `json:"term" yaml:"term"` // 终端类型
Height int `json:"height" yaml:"height"` // 行数
Width int `json:"width" yaml:"width"` // 列数 会影响输出的内容是否换行
// 把常用的 TerminalModes 单独拆字段,零值即“不设置”
Echo uint32 `json:"echo" yaml:"echo"` // 把用户敲的命令回显 0 关闭,1 开启
RawMode bool `json:"raw_mode" yaml:"raw_mode"` // true 时把 ECHO、ICANON 等全部关掉
InputSpeed uint32 `json:"input_speed" yaml:"input_speed"` // 波特率
OutputSpeed uint32 `json:"output_speed" yaml:"output_speed"` // 波特率
}
type SshConfig ¶
type SshConfig struct {
Name string `json:"name"` //自定义名称
Host string `json:"host"`
Port string `json:"port"`
UserName string `json:"username"`
Password string `json:"password"`
GsSlog *gstool.GsSlog
RunType int //执行类型
MaxRunSecond int //最大执行时间 不超过40秒
PtyConfig PtyConfig //终端配置
// contains filtered or unexported fields
}
func NewSshAuthPassword ¶
NewSshAuthPassword ssh auth password 一个本地端口只允许做一次桥接
func (*SshConfig) CloseBridge ¶
func (h *SshConfig) CloseBridge()
func (*SshConfig) CloseFirstReceiveMsg ¶
func (h *SshConfig) CloseFirstReceiveMsg()
func (*SshConfig) ConnectAuthPassword ¶
ConnectAuthPassword ssh auth password
func (*SshConfig) RunBridge ¶
RunBridge execute and forward to the local port Local listening port, all connections to this port will be forwarded to the destination address
func (*SshConfig) RunCommand ¶ added in v1.9.1
RunCommand 通过终端一次性执行命令 不等待完成
func (*SshConfig) RunCommandOnce ¶
RunCommandOnce 建立一个临时session执行一次
func (*SshConfig) RunCommandWait ¶
RunCommandWait 通过终端一次性执行命令 等待完成
func (*SshConfig) RunWaitTimeout ¶ added in v1.9.5
RunWaitTimeout 运行超时处理
func (*SshConfig) SetCombineNum ¶
func (*SshConfig) SetFuncBefore ¶
func (*SshConfig) SetFuncBroken ¶
func (h *SshConfig) SetFuncBroken(broken func())
func (*SshConfig) SetFuncEndCommand ¶
func (h *SshConfig) SetFuncEndCommand(f func())
func (*SshConfig) SetFuncReceiveMsg ¶
func (*SshConfig) SetFuncStartCommand ¶
func (h *SshConfig) SetFuncStartCommand(f func())
func (*SshConfig) SetFuncStreamReceive ¶
func (*SshConfig) SetMaxBufferSize ¶ added in v1.9.8
func (*SshConfig) SetMaxRunSecond ¶
SetMaxRunSecond 设置最大执行超时时间 不能超过40秒
func (*SshConfig) SetPtyConfig ¶ added in v1.9.3
func (*SshConfig) UploadFile ¶
UploadFile 上传文件到远程
func (*SshConfig) UploadFileProcess ¶
func (h *SshConfig) UploadFileProcess(remoteFilePath, localFilePath string, progressCallback func(bytesWritten, totalBytes int64)) error
UploadFileProcess 上传文件到远程,支持进度回调
func (*SshConfig) UploadFileProcessScp ¶
Click to show internal directories.
Click to hide internal directories.