state

package
v0.0.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

README

Persistent State

Persistent state, stored between runs. Holds the task queue, etc.

Documentation

Overview

Package state - Persistent state

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(dir string, sl *slog.Logger, onError func(error)) (*jpersist.Manager[State], error)

New returns a new State wrapped in a jpersist.Manager which is persisted to the directory d. Write errors will be logged via sl.

func NewTestState

func NewTestState(t *testing.T) *jpersist.Manager[State]

NewTestState returns a new state suitable for testing. If an error is encountered, NewTestState calls t.Fatalf.

Types

type State

type State struct {
	/* Tasking holds the per-implant task queues. */
	TaskQ map[string][]string

	/* LastSeen holds the N last-seen implants. */
	LastSeen def.EDSeen
}

State stores the state which persists between executions. It should not be created directly; use New instead.

func (*State) Saw

func (s *State) Saw(id, from string)

Saw updates s.LastSeen to note the ImplantID was just seen and from where. It is the caller's responsibilty to ensure s's manager is properly locked.

Jump to

Keyboard shortcuts

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