config

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package config loads and validates Turnwire configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath returns the per-user JSON configuration path.

func DefaultDataDir

func DefaultDataDir() string

DefaultDataDir returns the per-user directory for durable relay state.

func Write

func Write(path string, cfg Config, force bool) error

Write creates a restrictive JSON config file. Existing files are replaced only when force is true.

func WriteGuarded

func WriteGuarded(path string, cfg Config, force bool, guard DestinationGuard) error

WriteGuarded writes a restrictive JSON config file only when guard accepts the destination selected by the same parent descriptor retained for the create or rename. Platforms without descriptor-secured writes fail closed.

Types

type Config

type Config struct {
	Identity   IdentityConfig   `json:"identity"`
	Deployment DeploymentConfig `json:"deployment"`
	Guard      GuardConfig      `json:"guard"`
	Limits     LimitsConfig     `json:"limits"`
	AuditDir   string           `json:"audit_dir,omitempty"`
}

Config is the complete Turnwire configuration.

func Default

func Default() Config

Default returns the fail-closed OpenAI guard configuration used by init.

func Load

func Load(explicitPath string) (Config, error)

Load reads an explicit JSON config file, or the user config file when it exists. A missing default file is not an error. File values overlay safe defaults; no configuration is discovered from the working directory.

func (Config) Validate

func (c Config) Validate() error

Validate rejects unsafe endpoints and invalid resource limits.

type DeploymentConfig

type DeploymentConfig struct {
	ID string `json:"id"`
}

DeploymentConfig identifies the tunnel/app association represented in startup attestations and signed checkpoints.

type DestinationGuard

type DestinationGuard func(parent *os.File, name string) error

DestinationGuard authorizes a config destination after its parent directory has been securely opened. The parent descriptor is borrowed and must not be closed by the guard.

type GuardConfig

type GuardConfig struct {
	API                  string `json:"api"`
	Endpoint             string `json:"endpoint"`
	Model                string `json:"model"`
	APIKeyEnv            string `json:"api_key_env,omitempty"`
	AllowRemote          bool   `json:"allow_remote,omitempty"`
	PolicyVersion        string `json:"policy_version"`
	Policy               string `json:"policy"`
	PromptCacheRetention string `json:"prompt_cache_retention,omitempty"`
}

GuardConfig configures the mandatory OpenAI Responses policy classifier.

type IdentityConfig

type IdentityConfig struct {
	Name  string       `json:"name"`
	Peers []PeerConfig `json:"peers"`
}

IdentityConfig names this endpoint and lists the public keys it trusts.

type LimitsConfig

type LimitsConfig struct {
	MaxMessageBytes      int    `json:"max_message_bytes"`
	MaxAuditBytes        int64  `json:"max_audit_bytes"`
	Timeout              string `json:"timeout"`
	MaxMessageAge        string `json:"max_message_age"`
	MaxConcurrent        int    `json:"max_concurrent"`
	MaxRequestsPerMinute int    `json:"max_requests_per_minute"`
	MaxGuardCallsPerHour int    `json:"max_guard_calls_per_hour"`
}

LimitsConfig bounds message size, request duration, and concurrent work.

type PeerConfig

type PeerConfig struct {
	Name      string `json:"name"`
	PublicKey string `json:"public_key"`
}

PeerConfig binds a peer name to an Ed25519 public key.

Jump to

Keyboard shortcuts

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