Documentation
¶
Overview ¶
Package truenasshell bridges honey web terminals to TrueNAS /websocket/shell.
Index ¶
- Constants
- func APIWSURL(raw string, insecure bool) (string, error)
- func BridgeWebSocket(_ context.Context, browser *websocket.Conn, sess *Session, rec Recorder)
- func PumpStdio(parentCtx context.Context, shell *Session, stdin io.Reader, stdout io.Writer, ...) error
- func RecordSupportsAPIShell(rec hosts.Record) bool
- func RunRemoteCommand(ctx context.Context, b hostexec.TrueNASBackendRuntime, rec hosts.Record, ...) (output []byte, exitCode int, err error)
- func ShellWSURL(apiWSURL string) (string, error)
- func ShouldUseTrueNASShell(rec hosts.Record, console string) bool
- func StdinChunkToShell(sess *Session, p []byte, rec Recorder) (detached bool, err error)
- type Recorder
- type Session
Constants ¶
const ConsoleTrueNASAPI = "truenas_api"
ConsoleTrueNASAPI selects the TrueNAS middleware web shell instead of SSH.
const CtrlBracketDetach = byte(0x1d)
CtrlBracketDetach is ASCII GS (Ctrl+]); honey closes the session without forwarding it.
Variables ¶
This section is empty.
Functions ¶
func BridgeWebSocket ¶
BridgeWebSocket copies between a browser websocket and an opened TrueNAS shell session.
func PumpStdio ¶
func PumpStdio(parentCtx context.Context, shell *Session, stdin io.Reader, stdout io.Writer, rec Recorder) error
PumpStdio copies stdin to the TrueNAS shell websocket and shell output to stdout until ctx ends, EOF, or error. Terminal resize is handled by the caller via Session.Resize (e.g. SIGWINCH).
func RecordSupportsAPIShell ¶
RecordSupportsAPIShell reports whether rec has the metadata shape for TrueNAS /websocket/shell.
func RunRemoteCommand ¶
func RunRemoteCommand(ctx context.Context, b hostexec.TrueNASBackendRuntime, rec hosts.Record, remoteCmd string) (output []byte, exitCode int, err error)
RunRemoteCommand runs one non-interactive shell command over an API shell session.
func ShellWSURL ¶
ShellWSURL returns the wss URL for /websocket/shell on the same host as apiWSURL.
func ShouldUseTrueNASShell ¶
ShouldUseTrueNASShell reports whether the web terminal should bridge to TrueNAS /websocket/shell.
Types ¶
type Recorder ¶
type Recorder interface {
RecordData(direction string, payload []byte)
RecordResize(cols, rows int)
RecordError(err error)
}
Recorder receives optional TTY telemetry (implemented by *ui.SessionRecorder).
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session bridges a TrueNAS /websocket/shell PTY; resize uses the JSON-RPC API connection.
func OpenSession ¶
func OpenSession(ctx context.Context, b hostexec.TrueNASBackendRuntime, rec hosts.Record, rows, cols int) (*Session, error)
OpenSession authenticates to TrueNAS, opens /websocket/shell for rec, and applies initial resize.
func (*Session) ReadMessage ¶
ReadMessage reads the next message from the shell websocket.
func (*Session) SetReadDeadline ¶
SetReadDeadline sets the read deadline on the shell websocket.
func (*Session) WriteBinary ¶
WriteBinary sends stdin bytes to the TrueNAS shell websocket.