Documentation
¶
Index ¶
- func KeepAlive(c *ssh.Client) error
- func NewSSHClient(user, host string, port int, opts ...ClientCfgOption) (*ssh.Client, error)
- type ClientCfgOption
- type Item
- type Pool
- func (p *Pool) Close()
- func (p *Pool) Delete(key string)
- func (p *Pool) Get(key string) (*ssh.Client, bool)
- func (p *Pool) GetWithNew(key, user, host string, port int, opts ...ClientCfgOption) (c *ssh.Client, err error)
- func (p *Pool) Len() int
- func (p *Pool) Put(key string, c *ssh.Client) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSSHClient ¶
Types ¶
type ClientCfgOption ¶
type ClientCfgOption func(c *ssh.ClientConfig)
func SetPassword ¶
func SetPassword(password string) ClientCfgOption
func SetPrivateKey ¶
func SetPrivateKey(privateKey, passPhrase string) ClientCfgOption
func SetTimeout ¶
func SetTimeout(seconds int) ClientCfgOption
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func NewPool ¶
NewPool creates a new pool. defaultExpiration: The default expiration time. cleanupInterval: How often the pool is checked for expired items. maxConn: The maximum number of connections that can be held by the pool. eachKeyMaxConn: The maximum number of connections that can be held by the pool for each key.
func (*Pool) Get ¶
Get return ssh client from the pool by the key, and the ssh client will be removed from the pool.
func (*Pool) GetWithNew ¶
func (p *Pool) GetWithNew(key, user, host string, port int, opts ...ClientCfgOption) (c *ssh.Client, err error)
GetWithNew return ssh client from the pool, if there is no client in the pool, it will create a new one.
Click to show internal directories.
Click to hide internal directories.