session

package
v0.6.1-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DBFilename is the default filename of the session database.
	DBFilename = "session.db"

	// DefaultSessionDBTimeout is the default maximum time we wait for the
	// session bbolt database to be opened. If the database is already
	// opened by another process, the unique lock cannot be obtained. With
	// the timeout we error out after the given time instead of just
	// blocking for forever.
	DefaultSessionDBTimeout = 5 * time.Second
)
View Source
const Subsystem = "SESS"

Variables

View Source
var (

	// ErrDBReversion is returned when detecting an attempt to revert to a
	// prior database version.
	ErrDBReversion = errors.New("cannot revert to prior version")
)
View Source
var (

	// ErrSessionNotFound is an error returned when we attempt to retrieve
	// information about a session but it is not found.
	ErrSessionNotFound = errors.New("session not found")
)

Functions

func SerializeSession

func SerializeSession(w io.Writer, session *Session) error

SerializeSession binary serializes the given session to the writer using the tlv format.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type DB

type DB struct {
	*bbolt.DB
}

DB is a bolt-backed persistent store.

func NewDB

func NewDB(dir, fileName string) (*DB, error)

NewDB creates a new bolt database that can be found at the given directory.

func (*DB) ListSessions

func (db *DB) ListSessions() ([]*Session, error)

ListSessions returns all sessions currently known to the store.

func (*DB) RevokeSession

func (db *DB) RevokeSession(key *btcec.PublicKey) error

RevokeSession updates the state of the session with the given local public key to be revoked.

func (*DB) StoreSession

func (db *DB) StoreSession(session *Session) error

StoreSession stores a session in the store. If a session with the same local public key already exists, the existing record is updated/ overwritten instead.

type GRPCServerCreator

type GRPCServerCreator func(opts ...grpc.ServerOption) *grpc.Server

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(serverCreator GRPCServerCreator) *Server

func (*Server) StartSession

func (s *Server) StartSession(session *Session, authData []byte) error

func (*Server) Stop

func (s *Server) Stop()

func (*Server) StopSession

func (s *Server) StopSession(localPublicKey *btcec.PublicKey) error

type Session

type Session struct {
	Label           string
	State           State
	Type            Type
	Expiry          time.Time
	ServerAddr      string
	DevServer       bool
	MacaroonRootKey uint64
	Macaroon        *macaroon.Macaroon
	PairingSecret   [mailbox.NumPasswordBytes]byte
	LocalPrivateKey *btcec.PrivateKey
	LocalPublicKey  *btcec.PublicKey
	RemotePublicKey *btcec.PublicKey
}

Session is a struct representing a long-term Terminal Connect session.

func DeserializeSession

func DeserializeSession(r io.Reader) (*Session, error)

DeserializeSession deserializes a session from the given reader, expecting the data to be encoded in the tlv format.

func NewSession

func NewSession(label string, typ Type, expiry time.Time, serverAddr string,
	devServer bool) (*Session, error)

NewSession creates a new session with the given user-defined parameters.

type State

type State uint8

State represents the state of a session.

const (
	StateCreated State = 0
	StateInUse   State = 1
	StateRevoked State = 2
	StateExpired State = 3
)

type Store

type Store interface {
	// StoreSession stores a session in the store. If a session with the
	// same local public key already exists, the existing record is updated/
	// overwritten instead.
	StoreSession(*Session) error

	// ListSessions returns all sessions currently known to the store.
	ListSessions() ([]*Session, error)

	// RevokeSession updates the state of the session with the given local
	// public key to be revoked.
	RevokeSession(*btcec.PublicKey) error
}

Store is the interface a persistent storage must implement for storing and retrieving Terminal Connect sessions.

type Type

type Type uint8

Type represents the type of session.

const (
	TypeMacaroonReadonly Type = 0
	TypeMacaroonAdmin    Type = 1
	TypeMacaroonCustom   Type = 2
	TypeUIPassword       Type = 3
)

Jump to

Keyboard shortcuts

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