state

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package state persists private accepted state and a bounded acknowledged traffic journal.

Index

Constants

View Source
const MaxStoreBytes = 64 << 20

Variables

This section is empty.

Functions

func AtomicWrite

func AtomicWrite(path string, b []byte, mode os.FileMode) error

func ID

func ID() string

Types

type Batch

type Batch struct {
	ID      string  `json:"id"`
	Traffic Traffic `json:"traffic"`
}

type Data

type Data struct {
	AgentID        string                      `json:"agent_id"`
	Revision       uint64                      `json:"revision"`
	ConfigRevision uint64                      `json:"config_revision"`
	Config         *protocol.Config            `json:"config,omitempty"`
	Users          []protocol.User             `json:"users"`
	Bans           map[int]time.Time           `json:"bans,omitempty"`
	IPBlocks       map[string]protocol.IPBlock `json:"ip_blocks,omitempty"`
	Sequence       uint64                      `json:"sequence"`
	Pending        *Batch                      `json:"pending,omitempty"`
	Accumulated    Traffic                     `json:"accumulated,omitempty"`
}

type Store

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

func Open

func Open(dir string) (*Store, error)

func (*Store) Accept

func (s *Store) Accept(c protocol.Config, revision uint64) error

func (*Store) Ack

func (s *Store) Ack(id string) error

func (*Store) AddTraffic

func (s *Store) AddTraffic(delta Traffic) error

func (*Store) Authorize

func (s *Store) Authorize(users []protocol.User, revision uint64) error

func (*Store) Ban

func (s *Store) Ban(id int, until time.Time) error

func (*Store) Batch

func (s *Store) Batch() (*Batch, error)

func (*Store) BlockIP

func (s *Store) BlockIP(key string, block protocol.IPBlock) error

func (*Store) Snapshot

func (s *Store) Snapshot() Data

type Traffic

type Traffic map[int][2]uint64

Jump to

Keyboard shortcuts

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