Documentation
¶
Index ¶
- Constants
- func DecodeAdminAction(data []byte) (action byte, connID uint64)
- func EncodeAdminAction(action byte, connID uint64) []byte
- func EncodeAdminState(s *AdminState) []byte
- func Render(sess *Session, totalCols, totalRows int, hud *HUDInfo) []byte
- func RenderAdmin(state *AdminState, cols, rows int) []byte
- func RenderScroll(sess *Session, totalCols, totalRows, offset int) []byte
- func RenderScrollIndicator(buf []byte, offset, total, cols, rows int) []byte
- func ValidateSessionName(name string) error
- type AdminConn
- type AdminState
- type CellSnapshot
- type HUDInfo
- type Pane
- func (p *Pane) AddWriter(w io.Writer)
- func (p *Pane) Close()
- func (p *Pane) CursorPos() image.Point
- func (p *Pane) CursorVisible() bool
- func (p *Pane) Dead() bool
- func (p *Pane) DrainBell() bool
- func (p *Pane) DrainClipboard() []byte
- func (p *Pane) PlainText() string
- func (p *Pane) Redraw()
- func (p *Pane) RemoveWriter(w io.Writer)
- func (p *Pane) Resize(cols, rows int)
- func (p *Pane) Screen() ScreenState
- func (p *Pane) ScrollScreen(offset, viewW, viewH int) ScreenState
- func (p *Pane) ScrollbackLen() int
- func (p *Pane) Snapshot() []byte
- func (p *Pane) Title() string
- func (p *Pane) Wait()
- func (p *Pane) WriteInput(data []byte) (int, error)
- type Rect
- type ScreenState
- type Session
- func (s *Session) ActiveWindow() *Window
- func (s *Session) ActiveWindowIndex() int
- func (s *Session) AllowAPI() bool
- func (s *Session) AllowRelay() bool
- func (s *Session) AllowSSH() bool
- func (s *Session) AllowWeb() bool
- func (s *Session) Close()
- func (s *Session) CloseActiveWindow() bool
- func (s *Session) Dead() bool
- func (s *Session) NewWindow() error
- func (s *Session) NextWindow()
- func (s *Session) Pane() *Pane
- func (s *Session) PrevWindow()
- func (s *Session) ReapDead() bool
- func (s *Session) Resize(cols, rows int)
- func (s *Session) SelectWindow(idx int)
- func (s *Session) SetAllowAPI(v bool)
- func (s *Session) SetAllowRelay(v bool)
- func (s *Session) SetAllowSSH(v bool)
- func (s *Session) SetAllowWeb(v bool)
- func (s *Session) Title() string
- func (s *Session) Windows() []*Window
- type Window
Constants ¶
const ( AdminToggleSSH byte = 0x01 AdminToggleRelay byte = 0x02 AdminKick byte = 0x03 AdminToggleWeb byte = 0x06 // Per-session access toggles. AdminSessionToggleSSH byte = 0x07 AdminSessionToggleWeb byte = 0x08 AdminSessionToggleRelay byte = 0x09 AdminToggleAPI byte = 0x0A AdminSessionToggleAPI byte = 0x0B )
Admin action types sent from client to server.
const ( ScrollUp byte = 0x01 // one line up ScrollDown byte = 0x02 // one line down ScrollHalfUp byte = 0x03 // half page up ScrollHalfDown byte = 0x04 // half page down ScrollTop byte = 0x05 // jump to top of scrollback ScrollBottom byte = 0x06 // jump to bottom (exit scroll) )
Scroll actions sent in MsgScrollAction payloads.
Variables ¶
This section is empty.
Functions ¶
func DecodeAdminAction ¶
DecodeAdminAction deserializes an admin action.
func EncodeAdminAction ¶
EncodeAdminAction serializes an admin action. Format: [action:1][id:8] (id only used for kick)
func EncodeAdminState ¶
func EncodeAdminState(s *AdminState) []byte
EncodeAdminState serializes AdminState for proto transport. Format: [ssh:1][web:1][relay:1][sessSSH:1][sessWeb:1][sessRelay:1][selected:1][nconns:1]
then per conn: [id:8][srcLen:1][src][addrLen:1][addr][commentLen:1][comment][sessionLen:1][session][durLen:1][dur]
func RenderAdmin ¶
func RenderAdmin(state *AdminState, cols, rows int) []byte
RenderAdmin draws a centered admin panel overlay.
func RenderScroll ¶
RenderScroll composites a scrolled view of the active pane. offset is the number of lines scrolled up from the bottom.
func RenderScrollIndicator ¶
RenderScrollIndicator appends a right-aligned "[scroll: LINE/TOTAL]" bar on the last row of the terminal.
func ValidateSessionName ¶
ValidateSessionName checks that a session name is non-empty, printable ASCII, and at most 64 bytes.
Types ¶
type AdminConn ¶
type AdminConn struct {
ID uint64
Source string
RemoteAddr string
KeyComment string
Session string
Duration string // pre-formatted
}
AdminConn describes a connection for display in the admin panel.
type AdminState ¶
type AdminState struct {
Conns []AdminConn
SSHEnabled bool
WebEnabled bool
RelayEnabled bool
Selected int
// Per-session access flags for the attached session.
SessionAllowSSH bool
SessionAllowWeb bool
SessionAllowRelay bool
APIEnabled bool
SessionAllowAPI bool
// RelayConfigured is true when the user has a relay account set up.
RelayConfigured bool
}
AdminState holds the data for the admin panel overlay.
func DecodeAdminState ¶
func DecodeAdminState(data []byte) *AdminState
DecodeAdminState deserializes AdminState from proto transport.
type CellSnapshot ¶
CellSnapshot holds a copied cell's content and style.
type HUDInfo ¶
type HUDInfo struct {
SSHAddr string // empty = not listening
WebAddr string // empty = not listening
RelayAddr string // empty = not connected
PrefixKey byte
}
HUDInfo holds server status for the HUD overlay.
type Pane ¶
type Pane struct {
ID int
// contains filtered or unexported fields
}
Pane is a pseudo-terminal backed by a VT emulator.
func NewPane ¶
NewPane spawns a shell in a new PTY with the given dimensions. scrollbackLines controls VT scrollback depth; 0 means default (10000).
func (*Pane) AddWriter ¶
AddWriter registers a writer to receive raw PTY output. Silently drops the registration if the per-pane writer limit is reached.
func (*Pane) CursorVisible ¶
CursorVisible returns whether the cursor should be shown.
func (*Pane) DrainClipboard ¶
DrainClipboard returns and clears any pending OSC 52 clipboard data.
func (*Pane) PlainText ¶ added in v1.0.29
PlainText returns the visible screen as plain text with trailing whitespace trimmed per line.
func (*Pane) Redraw ¶
func (p *Pane) Redraw()
Redraw sends SIGWINCH to force the child process to repaint.
func (*Pane) RemoveWriter ¶
RemoveWriter unregisters a previously added writer.
func (*Pane) Screen ¶
func (p *Pane) Screen() ScreenState
Screen returns a snapshot of the pane's visible screen under the lock. Safe to read concurrently with readLoop writing to the VT emulator.
func (*Pane) ScrollScreen ¶
func (p *Pane) ScrollScreen(offset, viewW, viewH int) ScreenState
ScrollScreen returns a screen snapshot scrolled up by offset lines into the scrollback buffer. offset=0 means the live screen. The returned ScreenState has dimensions viewW x viewH.
func (*Pane) ScrollbackLen ¶
ScrollbackLen returns the number of lines in the scrollback buffer.
type ScreenState ¶
type ScreenState struct {
Cells []CellSnapshot
Cursor image.Point
W, H int
}
ScreenState holds a snapshot of the pane's visible screen, cursor position, and dimensions. Cells is a flat slice indexed as [row*W+col].
type Session ¶
type Session struct {
Name string
ID uint64
Shell string // shell to spawn in new panes
// contains filtered or unexported fields
}
Session is a named collection of windows.
func NewSession ¶
NewSession creates a session with one window at the given dimensions.
func (*Session) ActiveWindow ¶
ActiveWindow returns the currently selected window.
func (*Session) ActiveWindowIndex ¶
ActiveWindowIndex returns the index of the active window.
func (*Session) AllowAPI ¶ added in v1.0.29
AllowAPI returns whether API access (send/screen) is permitted for this session.
func (*Session) AllowRelay ¶
AllowRelay returns whether relay access is permitted for this session.
func (*Session) CloseActiveWindow ¶
CloseActiveWindow closes the active window. Returns true if the session is empty.
func (*Session) PrevWindow ¶
func (s *Session) PrevWindow()
PrevWindow cycles to the previous window.
func (*Session) SelectWindow ¶
SelectWindow switches to the window at the given index.
func (*Session) SetAllowAPI ¶ added in v1.0.29
SetAllowAPI toggles API access for this session.
func (*Session) SetAllowRelay ¶
SetAllowRelay toggles relay access for this session.
func (*Session) SetAllowSSH ¶
SetAllowSSH toggles SSH access for this session.
func (*Session) SetAllowWeb ¶
SetAllowWeb toggles web access for this session.