config

package
v0.0.9 Latest Latest
Warning

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

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

Documentation

Overview

Package config resolves the server's runtime settings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindChrome

func FindChrome() string

FindChrome locates a usable Chrome binary, preferring an explicit override.

func StateDir

func StateDir() string

StateDir returns the per-user directory holding the browser profile and logs.

Resolving this against the working directory would mean the same command picked up a different, usually empty, profile depending on where it was launched from, and then asked for a fresh login.

Types

type Config

type Config struct {
	// ListenAddr is the HTTP bind address. It stays on loopback unless the
	// operator deliberately changes it; see Validate.
	ListenAddr string

	// StateDir holds the Chrome profile and the audit log. It is keyed to the
	// user rather than the working directory.
	StateDir    string
	ProfileName string

	ChromePath string
	Headless   bool

	// AllowWrites gates every mutating action. When false the write tools are
	// never registered, so a model cannot see or call them.
	AllowWrites bool

	// StatusTTL caches a login verdict. Each uncached check drives a real
	// browser at X, so checking more often makes losing the session likelier.
	StatusTTL time.Duration
	ResultTTL time.Duration

	ReadPace  Pace
	WritePace Pace

	FetchTimeout time.Duration
	LoginTimeout time.Duration

	// AllowedHosts are further names the server answers to, beyond loopback and
	// whatever ListenAddr binds.
	//
	// Every request has to address the server by name, which is what keeps a web
	// page from reaching it after re-resolving a domain to this machine. A bind
	// beyond loopback that is reached by hostname needs that name listed here,
	// because no client sends "0.0.0.0" and this cannot guess the rest.
	AllowedHosts []string

	// WriteTimeout bounds one mutating action. It is separate from FetchTimeout
	// because a write is not a fetch: it starts a browser of its own, presses a
	// control, waits for X's request to finish, and then reloads the post to
	// confirm the action survived. Sharing the read budget meant the confirmation
	// could be cut off by the deadline and reported as a timeout rather than as
	// what it found.
	WriteTimeout time.Duration

	// BrowserIdle is how long a browser stays warm with no reads before it is
	// closed. Zero disables warming, opening a browser per read.
	BrowserIdle time.Duration
}

Config is the fully resolved server configuration.

func Default

func Default() Config

Default returns the configuration used when no flags are supplied.

func (Config) AuditLogPath

func (c Config) AuditLogPath() string

AuditLogPath is the append-only record of attempted write actions.

func (Config) EnsureStateDir

func (c Config) EnsureStateDir() error

EnsureStateDir creates the state directory with permissions that keep the session private to this user.

func (Config) LoopbackOnly

func (c Config) LoopbackOnly() bool

LoopbackOnly reports whether the listen address is reachable only from this machine.

func (Config) ProfileDir

func (c Config) ProfileDir() string

ProfileDir is the Chrome --user-data-dir.

func (Config) Validate

func (c Config) Validate() error

Validate reports configuration that would fail at runtime.

type Pace

type Pace struct {
	MinInterval time.Duration
	Window      time.Duration
	Max         int

	// Jitter spreads the gap over MinInterval..MinInterval+Jitter, so actions
	// do not arrive at a fixed cadence no human would produce. Used for writes;
	// reads are not engagement and do not need it.
	Jitter time.Duration
}

Pace describes how often an operation may touch X: a floor between calls and a ceiling within a rolling window.

Jump to

Keyboard shortcuts

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