Documentation
¶
Overview ¶
Package terminalservice manages local PTY-backed shell sessions.
Index ¶
Constants ¶
View Source
const DefaultIdleTimeout = 30 * time.Minute
Variables ¶
View Source
var ( // ErrDisabled is returned when the terminal feature is off. ErrDisabled = errors.New("terminal: disabled") // ErrNotImplemented is returned on platforms without PTY support. ErrNotImplemented = errors.New("terminal: not implemented on this platform") // ErrSessionNotFound is returned for unknown session IDs. ErrSessionNotFound = errors.New("terminal: session not found") // ErrTooManySessions is returned when the per-process session slot is occupied. ErrTooManySessions = errors.New("terminal: too many concurrent sessions") )
Functions ¶
func CwdUnderRoot ¶
CwdUnderRoot ensures cwd is the same as allowedRoot or a subdirectory.
func ResolveCwdUnderRoot ¶
ResolveCwdUnderRoot returns a cleaned, real cwd after validating it is inside allowedRoot.
func ValidateShell ¶
Types ¶
type Config ¶
type Config struct {
Enabled bool
AllowedRoot string
DefaultShell string
// IdleTimeout is the maximum time a detached session is kept alive.
// Zero disables idle reaping.
IdleTimeout time.Duration
}
Config holds terminal service settings.
type CreateResponse ¶
type CreateResponse struct {
ID string
}
type Service ¶
type Service interface {
Create(ctx context.Context, principal string, req CreateRequest) (*CreateResponse, error)
Close(ctx context.Context, principal, id string) error
CloseAll(ctx context.Context) error
Attach(ctx context.Context, principal, id string, conn io.ReadWriteCloser, resizeCh <-chan ResizeMsg) error
Get(ctx context.Context, principal, id string) (*SessionInfo, error)
List(ctx context.Context, principal string, createdAtCursor *time.Time, limit int) ([]*SessionInfo, error)
UpdateGeometry(ctx context.Context, principal, id string, cols, rows int) error
ReapIdle(ctx context.Context) error
}
func NewDisabled ¶
func NewDisabled() Service
func WithActivityTracker ¶
func WithActivityTracker(svc Service, tracker libtracker.ActivityTracker) Service
type SessionInfo ¶
type SessionInfo = terminalstore.Session
Click to show internal directories.
Click to hide internal directories.