session

package
v0.1.0-alpha.17 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2016 License: Apache-2.0 Imports: 8 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

This section is empty.

Variables

This section is empty.

Functions

func Bool added in v1.0.0

func Bool(val bool) *bool

Bool returns pointer to a boolean variable

Types

type ID added in v1.0.0

type ID string

ID is a uinique session id that is based on time UUID v1

func NewID added in v1.0.0

func NewID() ID

NewID returns new session ID

func ParseID added in v1.0.0

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

ParseID parses ID and checks if it's correct

func (*ID) Check added in v1.0.0

func (s *ID) Check() error

Check checks if it's a valid UUID

func (*ID) IsZero added in v1.0.0

func (s *ID) IsZero() bool

IsZero returns true if this ID is emtpy

func (*ID) Set added in v1.0.0

func (s *ID) Set(v string) error

Set makes ID cli compatible, lets to set value from string

func (*ID) String added in v1.0.0

func (s *ID) String() string

String returns string representation of this id

func (*ID) Time added in v1.0.0

func (s *ID) Time() time.Time

Time returns time portion of this ID

func (*ID) UUID added in v1.0.0

func (s *ID) UUID() uuid.UUID

UUID returns byte representation of this ID

type Option added in v1.0.0

type Option func(s *server) error

Option is a functional option that can be given to a server

func ActiveSessionTTL added in v1.0.0

func ActiveSessionTTL(ttl time.Duration) Option

ActiveSessionTTL specifies active session ttl

func Clock added in v1.0.0

func Clock(c timetools.TimeProvider) Option

Clock sets up clock for this server, used in tests

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 added in v1.0.0

func (p *Party) String() string

String returns debug friendly representation

type Service added in v1.0.0

type Service interface {
	// GetSessions returns a list of currently active sessions
	// with all parties involved
	GetSessions() ([]Session, error)
	// GetSession returns a session with it's parties by ID
	GetSession(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
	// UpsertParty upserts active session party
	UpsertParty(id ID, p Party, ttl time.Duration) 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, opts ...Option) (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"`
	// 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"`
	// Active indicates if the session is active
	Active bool `json:"active"`
	// 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"`
}

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

type TerminalParams added in v1.0.0

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

TerminalParams holds parameters of the terminal used in session

func NewTerminalParamsFromInt added in v1.0.0

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

NewTerminalParamsFromInt returns new terminal parameters from int width and height

func NewTerminalParamsFromUint32 added in v1.0.0

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

NewTerminalParamsFromUint32 returns new terminal parameters from uint32 width and height

func (*TerminalParams) String added in v1.0.0

func (p *TerminalParams) String() string

String returns debug friendly representation of terminal

func (*TerminalParams) Winsize added in v1.0.0

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

Winsize returns low-level parameters for changing PTY

type UpdateRequest added in v1.0.0

type UpdateRequest struct {
	ID             ID              `json:"id"`
	Active         *bool           `json:"active"`
	TerminalParams *TerminalParams `json:"terminal_params"`
}

UpdateRequest is a session update request

func (*UpdateRequest) Check added in v1.0.0

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