Documentation
¶
Overview ¶
Package ssh provides simple SSH operations for SoundTouch speakers.
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect() error
- func (c *Client) ReadDir(remotePath string) (map[string][]byte, error)
- func (c *Client) ReadFile(remotePath string) ([]byte, error)
- func (c *Client) Run(command string) (string, error)
- func (c *Client) UploadContent(content []byte, remotePath string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client wraps an SSH client to perform operations on SoundTouch speakers.
func (*Client) Close ¶ added in v0.125.0
Close closes the persistent connection opened by Connect, if any. Safe to call even when Connect was never called (e.g. every Run/UploadContent call so far used its own one-off connection).
func (*Client) Connect ¶ added in v0.125.0
Connect opens a persistent SSH connection reused by subsequent Run/UploadContent calls, instead of each dialing its own. Call Close when done with it. Idempotent — calling Connect again while already connected is a no-op. Skip this for a single (or a rare few) command — dialing once and reusing it is only worth the extra Close bookkeeping when several calls follow in quick succession.
func (*Client) ReadDir ¶
ReadDir downloads all regular files under remotePath, returning a map of absolute remote path → file content. Missing or unreadable files are skipped.
func (*Client) ReadFile ¶
ReadFile downloads the content of a file on the remote host. An empty file that causes cat to exit non-zero (a firmware quirk on some devices) is returned as empty bytes rather than an error.