config

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MPL-2.0 Imports: 7 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 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
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 Save added in v0.2.0

func Save(cfg Config) error

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

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.
	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 (receiver courtesy).
	PreserveMetadata  bool   `toml:"preserve_metadata"`    // Apply the origin's mode and timestamps to files saved on disk.
}

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