Documentation
¶
Index ¶
- Variables
- type SSHConfig
- type SSHConsole
- func (c *SSHConsole) Attach(clientID string) chan []byte
- func (c *SSHConsole) Detach(clientID string)
- func (c *SSHConsole) ReopenLog()
- func (c *SSHConsole) Run(ctx context.Context)
- func (c *SSHConsole) UpdateCreds(creds compcredentials.CompCredentials)
- func (c *SSHConsole) Write(p []byte) (int, error)
- type SSHConsoleManager
- func (m *SSHConsoleManager) Attach(nodeID, clientID string) (chan []byte, error)
- func (m *SSHConsoleManager) Detach(nodeID, clientID string)
- func (m *SSHConsoleManager) ReopenLogs()
- func (m *SSHConsoleManager) Shutdown()
- func (m *SSHConsoleManager) UpdateCredentials(passwords map[string]compcredentials.CompCredentials)
- func (m *SSHConsoleManager) UpdateNodes(ctx context.Context, nodes map[string]*nodes.NodeConsoleInfo) error
- func (m *SSHConsoleManager) Wait()
- func (m *SSHConsoleManager) Write(nodeID string, p []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNotConnected = errors.New("ssh console node not connected")
ErrNotConnected means a managed node is temporarily disconnected. Write discards input and returns this error until reconnect.
Functions ¶
This section is empty.
Types ¶
type SSHConfig ¶
type SSHConfig struct {
TerminalType string `desc:"Terminal type for SSH PTY requests"`
TCPKeepAlive time.Duration `desc:"TCP keepalive interval for SSH connections (0 disables)"`
ConnectTimeout time.Duration `desc:"Deadline for the TCP dial and SSH handshake"`
ReconnectMinInterval time.Duration `flag:"-"`
ReconnectMaxInterval time.Duration `flag:"-"`
}
SSHConfig configures SSH consoles.
func DefaultSSHConfig ¶
func DefaultSSHConfig() SSHConfig
DefaultSSHConfig returns the default SSH console settings.
type SSHConsole ¶
type SSHConsole struct {
// contains filtered or unexported fields
}
SSHConsole manages one SSH node and persists across connections. Run owns log and client channel writes and reconnects until cancelled.
func (*SSHConsole) Attach ¶
func (c *SSHConsole) Attach(clientID string) chan []byte
Attach registers a buffered client channel.
func (*SSHConsole) Detach ¶
func (c *SSHConsole) Detach(clientID string)
Detach deregisters a client channel. Idempotent.
func (*SSHConsole) ReopenLog ¶
func (c *SSHConsole) ReopenLog()
ReopenLog signals the Run goroutine to reopen the log file (after rotation).
func (*SSHConsole) Run ¶
func (c *SSHConsole) Run(ctx context.Context)
Run connects, broadcasts output, and reconnects until cancelled. The manager controls its lifetime and must not retain a stopped console.
func (*SSHConsole) UpdateCreds ¶
func (c *SSHConsole) UpdateCreds(creds compcredentials.CompCredentials)
UpdateCreds updates stored credentials and forces a reconnect so the new credentials take effect.
type SSHConsoleManager ¶
type SSHConsoleManager struct {
// contains filtered or unexported fields
}
SSHConsoleManager manages one console for each SSH node.
func NewSSHConsoleManager ¶
func NewSSHConsoleManager(cfg SSHConfig, keyPath, logsPath string) *SSHConsoleManager
NewSSHConsoleManager creates a manager from validated configuration. keyPath may be empty when all nodes use password authentication. logsPath stores per-node console logs.
func (*SSHConsoleManager) Attach ¶
func (m *SSHConsoleManager) Attach(nodeID, clientID string) (chan []byte, error)
Attach connects a client and fails if the node is unmanaged.
func (*SSHConsoleManager) Detach ¶
func (m *SSHConsoleManager) Detach(nodeID, clientID string)
Detach disconnects a client and ignores unmanaged nodes.
func (*SSHConsoleManager) ReopenLogs ¶
func (m *SSHConsoleManager) ReopenLogs()
ReopenLogs signals all active consoles to reopen their log files after rotation.
func (*SSHConsoleManager) Shutdown ¶
func (m *SSHConsoleManager) Shutdown()
Shutdown stops all consoles and waits for their cleanup.
func (*SSHConsoleManager) UpdateCredentials ¶
func (m *SSHConsoleManager) UpdateCredentials(passwords map[string]compcredentials.CompCredentials)
UpdateCredentials reconnects managed nodes whose credentials changed. UpdateNodes handles membership and never changes authentication. Missing entries leave existing credentials unchanged because reads may be partial, and entries for unmanaged nodes are ignored. An empty password selects key authentication.
func (*SSHConsoleManager) UpdateNodes ¶
func (m *SSHConsoleManager) UpdateNodes( ctx context.Context, nodes map[string]*nodes.NodeConsoleInfo, ) error
UpdateNodes syncs managed consoles with the complete inventory. It starts new SSH nodes and stops removed or retyped nodes. Connection changes restart a console with its existing credentials, while new nodes wait for UpdateCredentials before connecting. ctx controls console lifetime.
func (*SSHConsoleManager) Wait ¶
func (m *SSHConsoleManager) Wait()
Wait blocks until all Run goroutines exit but does not stop them. Callers cancel their contexts first and then wait for log cleanup.