session

package
v3.2.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package session is used for bookeeping of SSH interactive sessions that happen in realtime across the teleport cluster

Index

Constants

View Source
const MaxSessionSliceLength = 1000

MaxSessionSliceLength is the maximum number of sessions per time window that the backend will return.

Variables

This section is empty.

Functions

func Bool

func Bool(val bool) *bool

Bool returns pointer to a boolean variable

func NewDiscardSessionServer

func NewDiscardSessionServer() *discardSessionServer

NewDiscardSessionServer returns a new discarding session server. It's used with the recording proxy so that nodes don't register active sessions to the backend.

Types

type ID

type ID string

ID is a unique session ID.

func NewID

func NewID() ID

NewID returns new session ID. The session ID is based on UUIDv4.

func NewLegacyID added in v3.1.12

func NewLegacyID() ID

DELETE IN: 4.1.0.

NewLegacyID creates a new session ID in the UUIDv1 legacy format.

func ParseID

func ParseID(id string) (*ID, error)

ParseID parses ID and checks if it's correct.

func (*ID) Check

func (s *ID) Check() error

Check will check that the underlying UUID is valid.

func (*ID) IsZero

func (s *ID) IsZero() bool

IsZero returns true if this ID is empty.

func (*ID) String

func (s *ID) String() string

String returns string representation of this ID.

type Party

type Party struct {
	// ID is a unique party id
	ID ID `json:"id"`
	// Site is a remote address?
	RemoteAddr string `json:"remote_addr"`
	// User is a teleport user using this session
	User string `json:"user"`
	// ServerID is an address of the server
	ServerID string `json:"server_id"`
	// LastActive is a last time this party was active
	LastActive time.Time `json:"last_active"`
}

Party is a participant a user or a script executing some action in the context of the session

func (*Party) String

func (p *Party) String() string

String returns debug friendly representation

type Service

type Service interface {
	// GetSessions returns a list of currently active sessions with all parties
	// involved.
	GetSessions(namespace string) ([]Session, error)

	// GetSession returns a session with it's parties by ID.
	GetSession(namespace string, id ID) (*Session, error)

	// CreateSession creates a new active session and it's parameters if term is
	// skipped, terminal size won't be recorded.
	CreateSession(sess Session) error

	// UpdateSession updates certain session parameters (last_active, terminal
	// parameters) other parameters will not be updated.
	UpdateSession(req UpdateRequest) error

	// DeleteSession removes an active session from the backend.
	DeleteSession(namespace string, id ID) error
}

Service is a realtime SSH session service that has information about sessions that are in-flight in the cluster at the moment.

func New

func New(bk backend.Backend) (Service, error)

New returns new session server that uses sqlite to manage active sessions

type Session

type Session struct {
	// ID is a unique session identifier
	ID ID `json:"id"`
	// Namespace is a session namespace, separating sessions from each other
	Namespace string `json:"namespace"`
	// Parties is a list of session parties.
	Parties []Party `json:"parties"`
	// TerminalParams sets terminal properties
	TerminalParams TerminalParams `json:"terminal_params"`
	// Login is a login used by all parties joining the session
	Login string `json:"login"`
	// Created records the information about the time when session
	// was created
	Created time.Time `json:"created"`
	// LastActive holds the information about when the session
	// was last active
	LastActive time.Time `json:"last_active"`
	// ServerID
	ServerID string `json:"server_id"`
}

Session is an interactive collaboration session that represents one or many SSH session started by teleport user

func (*Session) RemoveParty

func (s *Session) RemoveParty(pid ID) bool

RemoveParty helper allows to remove a party by it's ID from the session's list. Returns 'false' if pid couldn't be found

type Sessions

type Sessions []Session

Sessions type is created over []Session to implement sort.Interface to be able to sort sessions by creation time

func (Sessions) Len

func (slice Sessions) Len() int

Len is part of sort.Interface implementation for []Session

func (Sessions) Less

func (slice Sessions) Less(i, j int) bool

Less is part of sort.Interface implementation for []Session

func (Sessions) Swap

func (slice Sessions) Swap(i, j int)

Swap is part of sort.Interface implementation for []Session

type TerminalParams

type TerminalParams struct {
	W int `json:"w"`
	H int `json:"h"`
}

TerminalParams holds the terminal size in a session.

func NewTerminalParamsFromInt

func NewTerminalParamsFromInt(w int, h int) (*TerminalParams, error)

NewTerminalParamsFromInt returns new terminal parameters from int width and height

func NewTerminalParamsFromUint32

func NewTerminalParamsFromUint32(w uint32, h uint32) (*TerminalParams, error)

NewTerminalParamsFromUint32 returns new terminal parameters from uint32 width and height

func UnmarshalTerminalParams

func UnmarshalTerminalParams(s string) (*TerminalParams, error)

UnmarshalTerminalParams takes a serialized string that contains the terminal parameters and returns a *TerminalParams.

func (*TerminalParams) Serialize

func (p *TerminalParams) Serialize() string

Serialize is a more strict version of String(): it returns a string representation of terminal size, this is used in our APIs. Format : "W:H" Example: "80:25"

func (*TerminalParams) String

func (p *TerminalParams) String() string

String returns debug friendly representation of terminal

func (*TerminalParams) Winsize

func (p *TerminalParams) Winsize() *term.Winsize

Winsize returns low-level parameters for changing PTY

type UpdateRequest

type UpdateRequest struct {
	ID             ID              `json:"id"`
	Namespace      string          `json:"namespace"`
	TerminalParams *TerminalParams `json:"terminal_params"`

	// Parties allows to update the list of session parties. nil means
	// "do not update", empty list means "everybody is gone"
	Parties *[]Party `json:"parties"`
}

UpdateRequest is a session update request

func (*UpdateRequest) Check

func (u *UpdateRequest) Check() error

Check returns nil if request is valid, error otherwize

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL