rules

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package rules implements Warden's rule engine: an in-memory, disk-backed store of firewall rules keyed by process identity, with the lookup that the network extension consults for every new flow. Mirrors Warden's Extension/Rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine is a concurrency-safe rule store keyed by process identity (signing id or path). The network extension reads it on the flow path; the XPC daemon mutates it in response to app requests and user alert decisions.

func New

func New(path string) *Engine

New returns an empty engine persisting to path (pass "" for memory-only).

func (*Engine) Add

func (e *Engine) Add(r *shared.Rule)

Add inserts a rule under its Key.

func (*Engine) All

func (e *Engine) All() []*shared.Rule

All returns a flat snapshot copy of every rule.

func (*Engine) Delete

func (e *Engine) Delete(key, uuid string) bool

Delete removes the rule with uuid under key, returning whether it was found.

func (*Engine) Find

func (e *Engine) Find(key, remoteAddr, remotePort string) shared.RuleState

Find returns the verdict for a flow from process key to remoteAddr:remotePort: RuleStateAllow, RuleStateBlock, or RuleStateNotFound when no rule matches (the caller then prompts the user). Endpoint-specific rules win over process-wide ones because they are matched first.

func (*Engine) Load

func (e *Engine) Load() error

Load reads the rule set from disk. A missing file is not an error.

func (*Engine) MarshalJSON

func (e *Engine) MarshalJSON() ([]byte, error)

MarshalJSON serializes the whole store (used by the daemon's getRules reply).

func (*Engine) Save

func (e *Engine) Save() error

Save writes the rule set to disk (no-op for a memory-only engine).

func (*Engine) Toggle

func (e *Engine) Toggle(key, uuid string, disabled bool) bool

Toggle enables/disables the rule with uuid under key.

Jump to

Keyboard shortcuts

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