Documentation ¶
Index ¶
- Constants
- type Pool
- func (p *Pool) Close()
- func (p *Pool) ExecCombinedOutput(host string, command string) ([]byte, error)
- func (p *Pool) ExecCombinedOutputString(host string, command string) (string, error)
- func (p *Pool) ExecOutput(host string, command string) ([]byte, error)
- func (p *Pool) ExecOutputString(host string, command string) (string, error)
- func (p *Pool) Get(host string) (*Session, error)
- func (p *Pool) GetSFTP(host string) (*SFTPSession, error)
- func (p *Pool) Tunnel(host string, local, remote string) (*Tunnel, error)
- type PoolConfig
- type SFTPSession
- type Session
- type Tunnel
Constants ¶
View Source
const ( // DefaultMaxSessions is set to the default /etc/ssh/sshd_config value. // Most servers have not set MaxSessions, so they get the default limit of 10. DefaultMaxSessions = 10 // DefaultMaxConnections is a bit arbitrary. It's a tradeoff between how long // you wait for dials, and how long you wait for concurrent operations to finish. DefaultMaxConnections = 10 // DefaultSessionCloseDelay was found by testing. 10ms was ALMOST enough. (3 / 1000 would fail) DefaultSessionCloseDelay = time.Millisecond * 20 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func New ¶
func New(config *ssh.ClientConfig, poolconfig *PoolConfig) *Pool
func (*Pool) ExecCombinedOutput ¶
func (*Pool) ExecCombinedOutputString ¶
func (*Pool) ExecOutputString ¶
func (*Pool) Get ¶
Get() creates a session to a specific host. If successful, err will be nil and you must call Put() on the returned *ssh.Session to ensure cleanup. If the host connection already has MaxSessions sessions and MaxConnections is met, Get() will block until another connection somewhere calls Put().
type PoolConfig ¶
type PoolConfig struct { Debug bool // MaxSessions defines the maximum sessions per-connection. If left at 0, // DefaultMaxSessions is used. MaxSessions int // MaxConnections limits the number of connections to the same host. If // left at 0, DefaultMaxConnections is used. (Note each connection can have up to // MaxSessions concurrent things happening on it.) Setting this to 1 is not // a bad idea if you want to be gentle to your servers. MaxConnections int // SSH seems to take a moment to actually clean up a session after you close // it. This delay seems to prevent "no more sessions" errors from happening // by giving a very slight delay after closing but before allowing another // connection. If 0, DefaultSessionCloseDelay is used. SessionCloseDelay time.Duration }
type SFTPSession ¶ added in v0.0.6
func (*SFTPSession) Put ¶ added in v0.0.6
func (s *SFTPSession) Put()
func (*SFTPSession) String ¶ added in v0.0.8
func (s *SFTPSession) String() string
Click to show internal directories.
Click to hide internal directories.