config

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 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 IMPORTANT: GRPCStreamBuffer MUST be smaller than GRPCMaxMsgSize to leave room for protobuf framing overhead (~10-20 bytes per message)

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) are designed for small RPC messages and severely throttle large file streams on fast networks.

View Source
const BlockSize = 4 * 1024 * 1024 // 4 MiB - larger chunks = fewer 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/). Override with KEIBIDROP_CONFIG_DIR for testing 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 dir, and (except on Windows) mount_path: WinFSP makes the mount point itself and rejects an existing path, while libfuse and macFUSE require it to exist.

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 default config file with comments at the standard path. Does nothing if the file already 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"` // auto-prefetch files >= this many MB (sequential fill + on-demand jumps). Default 0 = off (pure on-demand) — aggressive prefetch saturates constrained/relay links and starves seeks. Set >0 only on a fat link. prefetch_on_open=true forces prefetch for any size.
	PushOnWrite       bool   `toml:"push_on_write"`
	LiveCollab        bool   `toml:"live_collab"`        // prioritize seeing peers' same-size in-place edits live (macFUSE auto_cache); trades off local mmap-write integrity (git). See note in template.
	PassphraseProtect bool   `toml:"passphrase_protect"` // opt into Tier 2 (Argon2id passphrase) for identity at-rest encryption
}

Config holds all user-configurable settings. Resolution 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 it exists) and applies environment variable overrides. Missing config file is not an error — defaults are used.

func (Config) Warnings added in v0.3.3

func (c Config) Warnings() []string

Warnings returns notes about flag combinations that are redundant or carry a known tradeoff, for the caller to log at startup. None are fatal — there is no combination that crashes or that the program must refuse. The cases are:

  • no_fuse disables the FUSE mount, so the mount-tuning flags prefetch_on_open and live_collab have nothing to act on (the no-FUSE AddFile/PullFile API is used instead). They are silently ignored; we surface that here.
  • live_collab on macOS enables the macFUSE auto_cache mount option, which fixes same-size live-edit visibility but can corrupt files written via mmap (notably git's index). That is a deliberate tradeoff, flagged so it is not a surprise. On Linux/Windows live_collab is a no-op (both already work).

Note prefetch_on_open and live_collab are NOT mutually exclusive: prefetch fills the local disk cache while auto_cache governs the kernel page cache — they operate at different layers and compose cleanly.

Jump to

Keyboard shortcuts

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