Skip to content

Latest commit

Β 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Distributed File Storage

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.

Features

  • 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.Reader end-to-end
  • Bootstrap nodes β€” new nodes discover the network by dialing a configurable list of peers

Project layout

.
β”œβ”€β”€ 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

Requirements

  • Go 1.25+

Build & run

make build   # produces bin/app
make run     # build and run the demo
make test    # run all tests

The 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).

How it works

  1. Store β€” FileServer.Store(key, reader) writes the file to the local disk store, then broadcasts a MessageStoreFile to all peers and streams the AES-encrypted payload to them via an io.MultiWriter.
  2. Get β€” FileServer.Get(key) returns the file from local disk if present; otherwise it broadcasts a MessageGetFile, decrypts the incoming stream from a peer, persists it locally, and returns a reader.
  3. Paths β€” keys are hashed and split into 5-character segments (e.g. abcde/fghij/...) under <listen-addr>_network/<node-id>/.

About

Underlying peer-to-peer package implemented from scratch, implements TCP (WIP 🚧)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages