flock

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 1 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.

README

Flock

Agent-first file transfer over native QUIC/UDP, with JSON Lines events, automatic pairing invitations, deadlines, and verified receive results.

Early release. Directly reachable IPv4 peers work on a LAN or an overlay such as Tailscale. Internet NAT discovery, UDP relay fallback, and geographic WAN qualification are future work. Performance comparisons are still pending.

Install

Homebrew (macOS and Linux)
brew install mhadifilms/tap/flock
flock --version

This tap installs a checksum-verified native binary. No Go or Python runtime is required. To upgrade: brew upgrade mhadifilms/tap/flock.

Go

With Go 1.27 or newer:

go install github.com/mhadifilms/flock@v0.1.0
flock --version

Prebuilt macOS, Linux, and Windows binaries and SHA256SUMS are available from Flock releases. PyPI is not needed for this native Go tool.

From source
git clone https://github.com/mhadifilms/flock.git
cd flock
go build -o flock .
./flock schema

Two agents, two processes

Start the sender with an IPv4 address the recipient can reach. It automatically hosts a temporary TCP control relay and opens a UDP listener:

flock send --advertise 100.64.0.10 ./folder

Read stdout as JSON Lines. The invitation event contains an invite object. Pass that object, or the whole event, to the recipient over your existing trusted agent channel. Keep the sender process running.

On the other computer:

flock receive --out ./received --invite-file invitation.json
# Or pass the same JSON object on stdin:
flock receive --out ./received < invitation.json

There is no human code to choose or type, no clipboard dependency, and no confirmation prompt. The invitation is a generated 256-bit bearer capability with an expiry, control address, relative paths, sizes, and SHA-256 hashes. It grants access to this transfer: treat it as a secret when handing it off.

For example, an agent reading a sender subprocess can extract the invitation:

for line in sender.stdout:
    event = json.loads(line)
    if event["event"] == "invitation":
        handoff = json.dumps(event["invite"])
        # Deliver handoff to the recipient agent; continue draining sender.stdout.

Do not pipe the entire sender event stream into the recipient. Hand over the single invitation object and continue consuming each process's events.

Agent contract

Stdout always contains JSON Lines, including argument errors and help. Stderr is reserved for diagnostics. flock schema describes commands, event names, and exit codes. All events have version: 1 and event fields.

Event Meaning
preparing Inventory and hash source files
invitation Generated transfer capability and expected file manifest
connecting Recipient is pairing
transport QUIC listener/connection state
progress Cumulative application bytes transferred
completed Role-specific result, manifest, and byte count
error Stable error code and diagnostic message
ready Standalone control relay is listening

The recipient emits completed with sha256_verified: true only after every received file has passed full SHA-256 and size verification, and expected empty directories exist. A sender's completed reports transport completion with sha256_verified: false; consume the recipient's result for verified delivery. The sender does not yet receive a separate post-verification receipt.

Exit status is 0 for success, 1 for failure, 124 for timeout, and 130 for cancellation. --timeout defaults to 30m, includes invitation input and verification, and accepts positive durations up to 24h. SIGINT/SIGTERM cancel the process. A broken stdout pipe cancels the transfer.

Receive destinations must be new directories. This first agent interface does not expose resume or overwrite. Failed transfers can leave partial files in the new destination. Symlinks and special files are rejected. Invitations are limited to 4 MiB and 10,000 file/directory entries.

Transport

Flock uses PAKE, encrypted control messages, chunk framing, file handling, and authenticated transport negotiation. It adds a QUIC adapter using quic-go, with TLS 1.3 mutual authentication bound to the PAKE session. The authenticated control channel exchanges UDP endpoints; repeated outbound probes help establish bidirectional UDP traffic. The default is eight bidirectional streams on one QUIC connection; set --streams 1 through --streams 16 to experiment.

TCP carries pairing/control only. File data requires QUIC and does not silently fall back to TCP. The peer must advertise Flock support. Both peers must run Flock for this file-data mode.

The advertised IPv4 address must be reachable at the actual UDP listener port. The default embedded control listener uses a random TCP port; both that TCP port and the UDP port must be reachable. To pin them for firewall rules:

flock send --advertise 100.64.0.10 \
  --control-listen 0.0.0.0:9009 --udp-listen 0.0.0.0:9010 ./folder

An existing compatible control relay can be selected with --relay HOST:PORT. Flock also provides a control-only relay:

flock relay --listen 0.0.0.0:9009
flock send --relay relay.example:9009 --advertise 100.64.0.10 ./folder

If configured, set the same FLOCK_RELAY_PASSWORD on the relay and both peers. The relay carries encrypted control messages; no file-data relay is started by flock relay. A control relay does not make an unreachable UDP endpoint reachable. Public NAT traversal and QUIC relaying are not implemented in this first slice.

Validation and performance

go test ./...
go test -race ./internal/flockcli ./src/codephrase ./src/croc \
  -run 'Flock|Agent|Invitation|ReceiveDeadline|TailcatMultiStreamEndToEnd'

Integration tests launch independent sender, receiver, and control relay processes with real TCP control and UDP data sockets. They cover one/eight streams, an embedded control relay, nested/empty entries, JSON-only errors, changed manifests, bad final checksums, expired/unsafe invitations, and blocked UDP without TCP data fallback. Session-authentication tests reject altered endpoint offers and wrong TLS session keys.

The first native macOS-to-macOS LAN check transferred an incompressible 64 MiB file plus nested/empty entries in 2.598 seconds end to end (24.64 MiB/s), including startup and SHA-256 work. Both processes exited successfully; a separate remote shasum -a 256 matched the source. This is a single functional measurement, not a comparative benchmark or a WAN performance result. Benchmarking and tuning remain necessary before making speed claims.

License and provenance

Flock is MIT-licensed. Original copyright notices remain in LICENSE; UPSTREAM.md records the fork's provenance. Go module dependencies retain their respective licenses, included with the release archives.

Building releases

python3 packaging/flock_release.py --version 0.1.0 --output dist creates native archives for macOS, Linux, and Windows on ARM64 and AMD64, plus SHA256SUMS. The version must match internal/flockcli.Release. The script builds and packages only; publishing and updating the Homebrew formula are separate steps. Inherited upstream packaging scripts are kept as source history and are not used for Flock distribution.

Documentation

Overview

Flock provides agent-first file transfers over native QUIC/UDP.

Directories

Path Synopsis
cmd
croc-legacy command
croc-web command
flock command
Flock provides agent-first file transfers over native QUIC/UDP.
Flock provides agent-first file transfers over native QUIC/UDP.
internal
cli
Package cli provides a minimal framework for creating and organizing command line Go applications.
Package cli provides a minimal framework for creating and organizing command line Go applications.
flockcli
Package flockcli implements the versioned, non-interactive Flock interface.
Package flockcli implements the versioned, non-interactive Flock interface.
sshclient
Package sshclient contains the transport-independent half of croc's SSH client.
Package sshclient contains the transport-independent half of croc's SSH client.
tailcat
Package tailcat implements a control-plane-free network pipe built on Tailscale's data plane which provides encryption (WireGuard) and NAT traversal.
Package tailcat implements a control-plane-free network pipe built on Tailscale's data plane which provides encryption (WireGuard) and NAT traversal.
src
cli
codephrase
Package codephrase generates croc codes and resolves them into relay-room and PAKE components.
Package codephrase generates croc codes and resolves them into relay-room and PAKE components.
croc
ctx.go
ctx.go
install command
logger
Package logger provides the process-wide logging API used by croc.
Package logger provides the process-wide logging API used by croc.
pakekey
Package pakekey binds croc's peer PAKE exchanges to their participants, session, purpose, and exact wire transcript.
Package pakekey binds croc's peer PAKE exchanges to their participants, session, purpose, and exact wire transcript.
publicrelay
Package publicrelay defines and measures croc's ordered public relay pool.
Package publicrelay defines and measures croc's ordered public relay pool.
receivefs
Package receivefs validates untrusted receive paths and provides filesystem operations rooted at a directory handle.
Package receivefs validates untrusted receive paths and provides filesystem operations rooted at a directory handle.
redact
Package redact removes exact secret values from diagnostic text while preserving error identity for errors.Is and errors.As callers.
Package redact removes exact secret values from diagnostic text while preserving error identity for errors.Is and errors.As callers.
sshshare
Package sshshare implements croc's authenticated, reconnectable SSH sharing protocol and shared-terminal lifecycle.
Package sshshare implements croc's authenticated, reconnectable SSH sharing protocol and shared-terminal lifecycle.
store
Package store implements croc's anonymous, encrypted, download-limited temporary storage service.
Package store implements croc's anonymous, encrypted, download-limited temporary storage service.
storeclient
Package storeclient implements the client side of croc-store-v1 for the CLI.
Package storeclient implements the client side of croc-store-v1 for the CLI.
storecrypto
Package storecrypto defines the versioned, client-side encrypted format used by croc's asynchronous stored transfers.
Package storecrypto defines the versioned, client-side encrypted format used by croc's asynchronous stored transfers.
tailcattransport
Package tailcattransport binds croc's authenticated session key to an in-process Tailcat data plane.
Package tailcattransport binds croc's authenticated session key to an in-process Tailcat data plane.
tcp
ctx.go
ctx.go
termui
Package termui provides terminal-safe styling for croc's command-line output.
Package termui provides terminal-safe styling for croc's command-line output.
utils
ctx.go
ctx.go
version
Package version contains the version shared by the croc executables.
Package version contains the version shared by the croc executables.
webassets
Package webassets contains the production croc web client embedded into the standalone croc-web binary.
Package webassets contains the production croc web client embedded into the standalone croc-web binary.
webcli
Package webcli implements the standalone croc-web server command.
Package webcli implements the standalone croc-web server command.
webrelay
Package webrelay serves the embedded croc web client and exposes its deliberately small WebSocket-to-TCP bridge.
Package webrelay serves the embedded croc web client and exposes its deliberately small WebSocket-to-TCP bridge.
web
sshwasm command
wasm command

Jump to

Keyboard shortcuts

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