Documentation
¶
Overview ¶
Package session provides session lifecycle management for ShellGate.
Index ¶
- type Manager
- type ManagerConfig
- type Recorder
- type RecorderConfig
- type Session
- type SessionInfo
- type ShareLink
- type ShareManager
- func (sm *ShareManager) BroadcastToSession(sessionID string, data []byte)
- func (sm *ShareManager) Close()
- func (sm *ShareManager) Create(sessionID string, ttl time.Duration, maxViewers int) (*ShareLink, error)
- func (sm *ShareManager) Get(token string) (*ShareLink, bool)
- func (sm *ShareManager) Remove(token string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager tracks active sessions with lifecycle controls.
func NewManager ¶
func NewManager(cfg ManagerConfig) *Manager
NewManager creates a new session manager.
func (*Manager) Close ¶
func (m *Manager) Close()
Close shuts down the manager and all active sessions.
func (*Manager) Create ¶
func (m *Manager) Create(id, clientIP, userAgent string, ptySess *pty.Session, rec *Recorder) (*Session, error)
Create registers a new session. Returns an error if max sessions exceeded.
func (*Manager) List ¶
func (m *Manager) List() []SessionInfo
List returns info about all active sessions.
type ManagerConfig ¶
ManagerConfig holds configuration for the session manager.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder records terminal I/O in asciicast v2 format.
func NewRecorder ¶
func NewRecorder(cfg RecorderConfig) (*Recorder, error)
NewRecorder creates a new session recorder that writes asciicast v2 files.
func (*Recorder) WriteInput ¶
WriteInput records terminal input data.
func (*Recorder) WriteOutput ¶
WriteOutput records terminal output data.
func (*Recorder) WriteResize ¶
WriteResize records a terminal resize event.
type RecorderConfig ¶
type RecorderConfig struct {
Dir string
SessionID string
Width int
Height int
Shell string
Title string
}
RecorderConfig holds configuration for session recording.
type Session ¶
type Session struct {
ID string
StartedAt time.Time
ClientIP string
UserAgent string
PTY *pty.Session
Recorder *Recorder
LastInput time.Time
// contains filtered or unexported fields
}
Session represents an active terminal session.
func (*Session) UpdateLastInput ¶
func (s *Session) UpdateLastInput()
UpdateLastInput records the timestamp of the last input.
type SessionInfo ¶
type SessionInfo struct {
ID string `json:"id"`
StartedAt time.Time `json:"started_at"`
ClientIP string `json:"client_ip"`
UserAgent string `json:"user_agent"`
Duration string `json:"duration"`
}
SessionInfo is a serializable snapshot of session metadata.
type ShareLink ¶
type ShareLink struct {
// contains filtered or unexported fields
}
ShareLink represents a shareable read-only terminal link.
func (*ShareLink) AddViewer ¶
AddViewer increments the viewer count. Returns false if max viewers reached.
func (*ShareLink) Close ¶
func (sl *ShareLink) Close()
Close closes the share link broadcast channel.
func (*ShareLink) RemoveViewer ¶
func (sl *ShareLink) RemoveViewer()
RemoveViewer decrements the viewer count.
func (*ShareLink) ViewerCount ¶
ViewerCount returns the current viewer count.
type ShareManager ¶
type ShareManager struct {
// contains filtered or unexported fields
}
ShareManager manages shareable read-only session links.
func NewShareManager ¶
func NewShareManager() *ShareManager
NewShareManager creates a new share link manager.
func (*ShareManager) BroadcastToSession ¶
func (sm *ShareManager) BroadcastToSession(sessionID string, data []byte)
BroadcastToSession sends output data to all share links associated with a session.
func (*ShareManager) Create ¶
func (sm *ShareManager) Create(sessionID string, ttl time.Duration, maxViewers int) (*ShareLink, error)
Create generates a new share link for a session.
func (*ShareManager) Get ¶
func (sm *ShareManager) Get(token string) (*ShareLink, bool)
Get retrieves a share link by token.
func (*ShareManager) Remove ¶
func (sm *ShareManager) Remove(token string)
Remove deletes a share link.