Documentation
¶
Index ¶
Constants ¶
const ( MinPeerPort = 26000 MaxPeerPort = 27000 )
Peer connection ports must fall in this range. Handshake and relay registration reject anything outside it.
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)
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.
const BlockSize = 4 * 1024 * 1024 // 4 MiB - larger chunks = fewer gRPC round-trips over WAN
const DefaultBridge = "bridge.keibisoft.com:26600"
const DefaultRelay = "https://keibidroprelay.keibisoft.com/"
const InboundPort = 26431
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 EnsureDirectories ¶
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
Save writes the config to the standard path (~/.config/keibidrop/config.toml).
func ValidPeerPort ¶ added in v0.3.3
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.
ReadAheadWindowMB int `toml:"read_ahead_window_mb"` // cap for predictive sequential read-ahead on on-demand reads: keep up to this many MB of upcoming blocks in flight so a high-RTT link does not stall at each 16 MiB block boundary (video playback, sequential reads). The in-use window self-tunes by hit/miss feedback and never exceeds this; a slow consumer settles well below it. Default 64. Set 0 to disable (pure on-demand, no look-ahead).
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 Load ¶
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
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.