config

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinPeerPort = 26000
	MaxPeerPort = 27000
)

Peer connection ports must fall in this range. Handshake and relay registration reject anything outside it.

View Source
const (
	GRPCMaxMsgSize   = 20 * 1024 * 1024                  // 20 MiB - max gRPC message size
	GRPCStreamBuffer = 16 * 1024 * 1024                  // 16 MiB - buffer for streaming reads
	GRPCOverheadRoom = GRPCMaxMsgSize - GRPCStreamBuffer // 4 MiB headroom
)

gRPC message size limits. GRPCStreamBuffer must stay below GRPCMaxMsgSize to leave room for protobuf framing overhead.

View Source
const (
	GRPCWindowSize   = 16 << 20 // 16 MiB - per-stream and per-connection HTTP/2 window
	GRPCIOBufferSize = 4 << 20  // 4 MiB  - read/write buffer for gRPC transport
)

HTTP/2 flow-control tuning for bulk transfer. Go gRPC defaults (64 KiB window, 32 KiB buffers) throttle large file streams on fast networks.

View Source
const AgentInboundPort = 26441

One pair per surface. The app, the agent and the MCP server get installed on the same machine, and one pair meant the second to start could not bind.

View Source
const AgentOutboundPort = 26442
View Source
const BlockSize = 4 * 1024 * 1024 // 4 MiB. Larger chunks reduce gRPC round-trips over WAN.
View Source
const DefaultBridge = "bridge.keibisoft.com:26600"
View Source
const DefaultRelay = "https://keibidroprelay.keibisoft.com/"
View Source
const InboundPort = 26431

The desktop app's default port pair.

View Source
const LogRotateBytes = 32 << 20

LogRotateBytes caps one log file. Past it the file becomes <path>.1, replacing the previous .1, and a fresh file starts, so an install keeps at most two of them. Nothing trimmed the log before: five months of the desktop app at debug level had reached 151 MB in one file (2026-09-15).

View Source
const MCPInboundPort = 26451
View Source
const MCPOutboundPort = 26452
View Source
const OutboundPort = 26432

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() string

ConfigDir returns the config directory path (~/.config/keibidrop/). KEIBIDROP_CONFIG_DIR overrides it, so tests can run multiple instances on one machine.

func ConfigPath

func ConfigPath() string

ConfigPath returns the config file path.

func EnsureDirectories

func EnsureDirectories(cfg Config) error

EnsureDirectories creates save_path, the log directory, and, except on Windows, mount_path. WinFSP creates the mount point itself and rejects an existing path; libfuse and macFUSE require it.

func OpenLogFile added in v0.4.8

func OpenLogFile(path string) (io.WriteCloser, error)

OpenLogFile opens path for appending and rotates it as it grows. Every binary that writes a log file opens it here.

func Save added in v0.2.0

func Save(cfg Config) error

Save writes the config to the standard path (~/.config/keibidrop/config.toml).

func UseAgentPorts added in v0.4.8

func UseAgentPorts(cfg *Config)

UseAgentPorts is UseSurfacePorts for the kd agent.

func UseMCPPorts added in v0.4.8

func UseMCPPorts(cfg *Config)

UseMCPPorts is UseSurfacePorts for the MCP server.

func UseSurfacePorts added in v0.4.8

func UseSurfacePorts(cfg *Config, inbound, outbound int)

UseSurfacePorts moves a config off the app's default port pair on to another surface's. Every surface reads the same config.toml, which the app writes with its own defaults, so a port still equal to the app default counts as unchosen. Anything else, and KD_INBOUND_PORT or KD_OUTBOUND_PORT, is left alone.

func ValidPeerPort added in v0.3.3

func ValidPeerPort(port int) bool

ValidPeerPort reports whether port is within the allowed peer port range.

func WriteDefault

func WriteDefault() error

WriteDefault creates a commented default config file at the standard path. It does nothing when the file exists.

Types

type Config

type Config struct {
	Relay               string `toml:"relay"`
	SavePath            string `toml:"save_path"`
	MountPath           string `toml:"mount_path"`
	LogFile             string `toml:"log_file"`
	InboundPort         int    `toml:"inbound_port"`
	OutboundPort        int    `toml:"outbound_port"`
	BridgeAddr          string `toml:"bridge_addr"` // TCP bridge relay address
	StrictMode          bool   `toml:"strict_mode"` // Disable data relay fallback
	NoFUSE              bool   `toml:"no_fuse"`
	Incognito           bool   `toml:"incognito"`
	PrefetchOnOpen      bool   `toml:"prefetch_on_open"`
	PrefetchAutoMB      int    `toml:"prefetch_auto_mb"`     // Prefetch files at or above this many MB. Default 0 is off because prefetch saturates slow links and starves seeks.
	ReadAheadWindowMB   int    `toml:"read_ahead_window_mb"` // Cap in MB for sequential read-ahead; prevents stalls at block boundaries on high-RTT links. Self-tunes below the cap. Default 64; 0 disables.
	PushOnWrite         bool   `toml:"push_on_write"`
	LiveCollab          bool   `toml:"live_collab"`           // Show peers' same-size in-place edits live (macFUSE auto_cache); risks local mmap-write integrity (git).
	PassphraseProtect   bool   `toml:"passphrase_protect"`    // Enable Tier 2 identity at-rest encryption with an Argon2id passphrase.
	ScanSharedOnStart   bool   `toml:"scan_shared_on_start"`  // Announce files already in save_path when a session starts.
	RescanSharedSeconds int    `toml:"rescan_shared_seconds"` // With scan_shared_on_start: re-walk save_path this often while a session runs. 0 = off.
	AutoConnectPeer     string `toml:"auto_connect_peer"`     // Saved contact (name or fingerprint) to connect to on startup, with retry.
	ShareReadOnly       bool   `toml:"share_read_only"`       // Refuse every peer mutation of this node's data (origin-enforced).
	MountReadOnly       bool   `toml:"mount_read_only"`       // Local FUSE mount returns EROFS on write ops. Keeps the local view equal to the origin.
	PreserveMetadata    bool   `toml:"preserve_metadata"`     // Apply the origin's mode and timestamps to files saved on disk.
	UpdateCheck         bool   `toml:"update_check"`          // Fetch the newest version number from keibidrop.com at start and show a notice when this build is older.
}

Config holds all user-configurable settings. Values resolve in this order: built-in defaults, config file, environment variables.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns platform-aware defaults.

func Load

func Load() (Config, error)

Load reads the config file, if present, and applies environment variable overrides. A missing config file is not an error; defaults apply.

func (Config) Warnings added in v0.3.3

func (c Config) Warnings() []string

Warnings returns startup notes for redundant or tradeoff flag combinations; none are fatal. prefetch_on_open and live_collab act on different cache layers and compose cleanly.

Jump to

Keyboard shortcuts

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