recording

package module
v0.0.0-...-3d3bb95 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

README

This package allows reading and writing bettercap's session recordings.

A recording archive is a gzip file containing reference Session and Events JSON objects and their changes stored as patches in order to keep the file size as small as possible. Loading a session file implies generating all the frames starting from the reference one by iteratively applying those "state patches" until all recorded frames are stored in memory. This is done to allow, UI side, to skip forward to a specific frame index without all intermediate states being computed at runtime.

Example

See the examples folder.

License

This package is made with ♥ by evilsocket and it's released under the GPL 3 license.

Documentation

Overview

Package recording allows writing and reading of bettercap's session recordings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive struct {
	sync.Mutex

	Session *Record `json:"session"`
	Events  *Record `json:"events"`
	// contains filtered or unexported fields
}

func Load

func Load(fileName string, cb LoadProgress) (*Archive, error)

func New

func New(fileName string) *Archive

func (*Archive) Flush

func (r *Archive) Flush() error

func (*Archive) NewState

func (r *Archive) NewState(session []byte, events []byte) error

type LoadProgress

type LoadProgress func(perc float64, done int, total int)

type Record

type Record struct {
	sync.Mutex

	Head    []byte  `json:"data"`
	Patches []patch `json:"states"`
	// contains filtered or unexported fields
}

func NewRecord

func NewRecord(progress progressCallback) *Record

func (*Record) AddState

func (e *Record) AddState(state []byte) error

func (*Record) Compile

func (e *Record) Compile() error

func (*Record) Duration

func (e *Record) Duration() time.Duration

func (*Record) Frames

func (e *Record) Frames() int

func (*Record) Index

func (e *Record) Index() int

func (*Record) Next

func (e *Record) Next() []byte

func (*Record) OnProgress

func (e *Record) OnProgress(cb progressCallback)

func (*Record) Over

func (e *Record) Over() bool

func (*Record) Reset

func (e *Record) Reset()

func (*Record) SetFrom

func (e *Record) SetFrom(from int)

func (*Record) StartedAt

func (e *Record) StartedAt() time.Time

func (*Record) StoppedAt

func (e *Record) StoppedAt() time.Time

func (*Record) TimeOf

func (e *Record) TimeOf(idx int) time.Time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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