Documentation
¶
Index ¶
- type SSHClient
- func (c *SSHClient) Close() error
- func (c *SSHClient) Connect(ctx context.Context) error
- func (c *SSHClient) Download(ctx context.Context, remotePath, localPath string) error
- func (c *SSHClient) Execute(ctx context.Context, command string) (string, int, error)
- func (c *SSHClient) IsConnected() bool
- func (c *SSHClient) LastUse() time.Time
- func (c *SSHClient) SessionKey() string
- func (c *SSHClient) Upload(ctx context.Context, localPath, remotePath string) error
- type SSHConfig
- type SessionInfo
- type SessionManager
- func (m *SessionManager) CleanupIdle() int
- func (m *SessionManager) Close(key string) error
- func (m *SessionManager) CloseAll()
- func (m *SessionManager) Count() int
- func (m *SessionManager) Get(key string) (*SSHClient, bool)
- func (m *SessionManager) GetOrCreate(ctx context.Context, config *SSHConfig) (*SSHClient, error)
- func (m *SessionManager) List() []SessionInfo
- func (m *SessionManager) SetMaxIdle(d time.Duration)
- func (m *SessionManager) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SSHClient ¶
type SSHClient struct {
// contains filtered or unexported fields
}
SSHClient manages SSH connections.
func NewSSHClient ¶
NewSSHClient creates a new SSH client.
func (*SSHClient) IsConnected ¶
IsConnected checks if connection is alive.
func (*SSHClient) SessionKey ¶
SessionKey returns a unique key for this session.
type SSHConfig ¶
type SSHConfig struct {
Host string
Port int
User string
KeyPath string
KeyPassphrase string
Password string // Fallback if no key
Timeout time.Duration
KnownHostsPath string
}
SSHConfig holds connection configuration.
func DefaultSSHConfig ¶
func DefaultSSHConfig() *SSHConfig
DefaultSSHConfig returns a configuration with sensible defaults.
type SessionInfo ¶
type SessionInfo struct {
Key string // "user@host:port"
Host string
Port int
User string
Connected bool
LastUse time.Time
IdleTime time.Duration
}
SessionInfo represents information about an active SSH session.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manages persistent SSH sessions with connection pooling.
func NewSessionManager ¶
func NewSessionManager() *SessionManager
NewSessionManager creates a session manager.
func (*SessionManager) CleanupIdle ¶
func (m *SessionManager) CleanupIdle() int
CleanupIdle closes sessions idle longer than maxIdle.
func (*SessionManager) Close ¶
func (m *SessionManager) Close(key string) error
Close closes a specific session.
func (*SessionManager) Count ¶
func (m *SessionManager) Count() int
Count returns the number of active sessions.
func (*SessionManager) Get ¶
func (m *SessionManager) Get(key string) (*SSHClient, bool)
Get returns an existing session if it exists and is connected.
func (*SessionManager) GetOrCreate ¶
GetOrCreate returns existing session or creates new one.
func (*SessionManager) List ¶
func (m *SessionManager) List() []SessionInfo
List returns all active sessions.
func (*SessionManager) SetMaxIdle ¶
func (m *SessionManager) SetMaxIdle(d time.Duration)
SetMaxIdle sets the maximum idle time before a session is closed.
func (*SessionManager) Stop ¶
func (m *SessionManager) Stop()
Stop stops the cleanup goroutine and closes all sessions.