config

package
v0.0.0-...-d55067e Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	AuthTokenSourceNone   = ""
	AuthTokenSourceConfig = "config"
	AuthTokenSourceEnv    = "env"
	AuthTokenSourceFile   = "file"
)

Variables

This section is empty.

Functions

func LegacyVaultConfigExists

func LegacyVaultConfigExists(vaultRoot string) bool

func LegacyVaultConfigPath

func LegacyVaultConfigPath(vaultRoot string) string

func NormalizeBasePath

func NormalizeBasePath(raw string) string

NormalizeBasePath coerces a raw base-path string into the form the server uses everywhere: empty (meaning "serve at root") or a path that starts with `/` and has no trailing slash, e.g. "/zennotes". Multiple adjacent slashes are collapsed.

func SaveHost

func SaveHost(cfg Config) error

func SessionsPath

func SessionsPath() string

SessionsPath is where opt-in persisted browser sessions live — next to the host config file (e.g. /data/sessions.json alongside /data/server.json).

Types

type Config

type Config struct {
	VaultPath           string   `json:"vaultPath"`
	DefaultVaultPath    string   `json:"-"`
	BrowseRoots         []string `json:"-"`
	AllowedOrigins      []string `json:"-"`
	Bind                string   `json:"bind"`
	BasePath            string   `json:"basePath"`
	AuthToken           string   `json:"authToken"`
	AuthTokenSource     string   `json:"-"`
	AllowUnscopedBrowse bool     `json:"-"`
	AllowInsecureNoAuth bool     `json:"-"`
	DevMode             bool     `json:"-"`
	// DisableWatcher turns off the inotify file watcher (ZENNOTES_DISABLE_WATCHER).
	// Live updates stop; the vault is still fully served. Useful where inotify is
	// restricted and can hang the process (e.g. unprivileged LXC). (#179)
	DisableWatcher bool `json:"-"`

	// Limits and security knobs.
	MaxAssetBytes int64 `json:"-"`
	MaxNoteBytes  int64 `json:"-"`
	BehindTLS     bool  `json:"-"`
	// PersistSessions saves browser sessions to <data>/sessions.json so they
	// survive a server restart. Opt-in via ZENNOTES_PERSIST_SESSIONS.
	PersistSessions bool        `json:"-"`
	TrustedProxies  []net.IPNet `json:"-"`
	VaultFileMode   fs.FileMode `json:"-"`
	VaultDirMode    fs.FileMode `json:"-"`

	// AllowedHosts are Host names a loopback bind with no auth token answers to
	// besides localhost and IP addresses (ZENNOTES_ALLOWED_HOSTS), such as the
	// public name a proxy on the same machine forwards.
	AllowedHosts []string `json:"-"`
}

func Load

func Load() Config

type MCPConfig

type MCPConfig struct {
	Enabled        bool
	Credentials    []MCPCredential
	AllowedOrigins []string
}

MCPConfig is the built-in MCP endpoint. It is off unless ZENNOTES_MCP_ENABLED says otherwise, and with it off nothing below is read.

func LoadMCP

func LoadMCP() (MCPConfig, error)

LoadMCP reads the MCP settings. An error is a setting someone meant to work and that cannot, and the server refuses to start: a mistyped scope must never become a wider one. Errors name variables and files, never a token.

type MCPCredential

type MCPCredential struct {
	Name        string
	TokenSHA256 [sha256.Size]byte
	Access      string
	Allow, Deny []string
}

MCPCredential is one MCP token, held only as its hash, and the scope it grants.

Jump to

Keyboard shortcuts

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