Peer-to-peer file transfer over QUIC. Files are split into Blake3-verified chunks; peers exchange data over TLS 1.3 with Ed25519 handshake identity.
- QUIC (Quinn) — Multiplexed streams, built-in TLS 1.3.
- Chunking & integrity — Configurable chunk size; Blake3 per chunk; hashes checked on fetch.
- Identity — Ed25519 keypairs, signed handshake with replay window.
- Wire format — Binary messages (bincode), size-capped reads.
- Manifests — Small metadata files on disk (see below).
- CLI —
share,serve,fetchwith optional parallel directory preparation (Rayon).
- Rust 1.85 or newer (2024 edition)
- Cargo (for building from source)
Optional: Nix with flakes enabled, for reproducible builds and dev shells.
git clone https://github.com/yourusername/p2rent.git
cd p2rent
cargo build --release
# Binary: target/release/p2rentnix run github:yourusername/p2rent
nix profile install github:yourusername/p2rent # optional: install into profile
nix develop # dev shell with toolchainReplace yourusername/p2rent with your fork or organization.
1. Prepare content (chunk + manifest + store)
p2rent share path/to/file.zip
p2rent share ./directory --parallel
p2rent share large.iso --chunk-size 41943042. Serve chunks
p2rent serve
p2rent serve --addr 0.0.0.0:50003. Fetch using the manifest path
p2rent fetch --addr 192.168.1.10:5000 --manifest manifests/file.manifest.json
p2rent fetch --addr peer:5000 --manifest ./file.manifest.json --out ./out.zipFlow in short: share writes chunks and a manifest; serve exposes chunks; fetch reads the manifest locally, pulls chunks over QUIC, verifies hashes, writes the output file.
| Layer | Format | Role |
|---|---|---|
| On-disk manifest | JSON (.manifest.json) |
Human-readable metadata: filename, size, chunk size, ordered Blake3 digests. Shared out-of-band like a small “torrent descriptor.” |
| Peer messages over QUIC | Bincode (binary) | RequestChunk, Chunk payloads, etc. Not JSON — avoids huge encoding overhead for megabyte-scale chunk bodies. |
Run p2rent --help and p2rent <command> --help for the full, up-to-date interface.
| Command | Purpose |
|---|---|
share <PATH> |
Chunk files, write manifest + chunk store |
serve |
Listen for QUIC peers and serve chunks |
fetch |
Connect to a peer and assemble a file from a manifest |
Common flags: --addr, --manifest, --out, --stem, --chunk-size, --storage-dir, --manifest-dir, --parallel.
| Path | Responsibility |
|---|---|
src/main.rs |
CLI entrypoint |
src/chunk.rs |
Split / combine files |
src/crypto.rs |
Keys, signing, node id |
src/manifest.rs |
Read/write manifest files |
src/storage.rs |
Chunk files on disk |
src/net/protocol.rs |
Message types (serialized with bincode on the wire) |
src/net/quic.rs |
QUIC client/server |
tests/ |
Integration tests |
- Transport: QUIC over TLS 1.3 (self-signed server cert today; client does not pin that cert to a public CA).
- Handshake: Ed25519 signatures over a canonical payload; timestamps limited to a replay window.
- Content: Chunk Blake3 hashes in the manifest are checked after download.
- Reads: Incoming application messages are bounded (e.g. 16 MB cap) to limit memory use.
- Keys: Default path
~/.config/p2rent/keys.jsonwith restrictive permissions where supported.
This is suitable for controlled or LAN-style sharing; it is not a full public-internet anonymity or trust model.
cargo fmt
cargo clippy --all-targets -- -D warnings
cargo testCI runs format, clippy, tests, and builds on push/PR; tagged releases publish cross-compiled binaries (see .github/workflows/).
- Peer discovery (e.g. DHT)
- Multi-source / swarm downloads
- NAT traversal
- Rate limiting and resumable transfers
- Selective files from directory manifests
Issues and pull requests are welcome. Please run cargo fmt, cargo clippy, and cargo test before submitting.
This project is licensed under the MIT License — see LICENSE.
