A peer-to-peer distributed file storage system written in Go. Files written to any node are replicated to connected peers over TCP, encrypted in transit with AES-CTR, and stored on disk using content-addressed paths.
- Peer-to-peer networking over a pluggable TCP transport
- Content-addressed storage β keys are hashed (SHA-1) and sharded into nested directories
- AES-CTR encryption of data streamed between peers (per-file random IV)
- Per-node isolation β each node stores files under its own ID namespace
- Streaming reads/writes β files are piped through
io.Readerend-to-end - Bootstrap nodes β new nodes discover the network by dialing a configurable list of peers
.
βββ main.go # Entry point β spins up three sample nodes
βββ server.go # FileServer: Store / Get, broadcast, peer handling
βββ store.go # Disk store with CAS path transform
βββ crypto.go # AES-CTR encrypt/decrypt stream helpers, ID + key generation
βββ p2p/ # Transport, Peer, RPC, handshake, encoding
βββ transport.go
βββ tcp_transport.go
βββ message.go
βββ encoding.go
βββ handshake.go
- Go 1.25+
make build # produces bin/app
make run # build and run the demo
make test # run all testsThe demo in main.go starts three nodes on :3000, :4000, :7000, stores a file from one node, deletes it locally, then reads it back (pulling it from a peer).
- Store β
FileServer.Store(key, reader)writes the file to the local disk store, then broadcasts aMessageStoreFileto all peers and streams the AES-encrypted payload to them via anio.MultiWriter. - Get β
FileServer.Get(key)returns the file from local disk if present; otherwise it broadcasts aMessageGetFile, decrypts the incoming stream from a peer, persists it locally, and returns a reader. - Paths β keys are hashed and split into 5-character segments (e.g.
abcde/fghij/...) under<listen-addr>_network/<node-id>/.