NGHOST is a LAN-first peer-assisted file downloader written in Go.
It allows machines on the same local network to automatically share already-downloaded files with each other, reducing repeated internet downloads and improving download speeds on shared networks such as:
- college Wi-Fi
- hostels
- labs
- offices
- maker spaces
Instead of every machine downloading the same file separately from the internet, NGHOST checks whether another peer on the LAN already has the file and downloads it locally.
When downloading a file:
The client downloads only the first 1 MB from the internet
A SHA256 hash of that chunk is computed
The LAN is scanned using mDNS for NGHOST peers
Each peer is queried:
- “Do you have a file matching this hash?”
If a peer has the file:
- the full file is downloaded over LAN
Otherwise:
- download falls back to the internet
This dramatically reduces WAN bandwidth usage when many users download the same files.
- LAN peer discovery using mDNS
- SHA256 content-addressable lookup
- Partial-hash matching using first 1 MB
- SQLite-based file index
- Automatic directory scanning
- HTTP-based file serving
- Internet fallback when LAN misses
- Resume support for servers with HTTP Range requests
- Zero central server required
The daemon:
- scans a shared directory
- computes hashes
- stores metadata in SQLite
- advertises itself over mDNS
- serves files over HTTP
Endpoints:
/has/<full_sha256>/hasfirst/<first1mb_sha256>
The client:
- discovers peers over mDNS
- checks LAN availability
- downloads from peers when possible
- falls back to internet when needed
nghost/
├── client/
│ └── main.go (client code)
├── daemon/
│ ├── main.go (daemon code should be run on background with systemctl)
│ ├── conf.json │ └── files.db (generated by the daemon at runtime)
├── go.mod
└── go.sum
- Go 1.22+
- SQLite3
git clone https://github.com/lsnnt/nghost.git
cd nghost
go mod tidygo build -o daemon ./daemongo build -o client ./clientCreate conf.json inside daemon/:
{
"DDir": ["/path/to/shared/files"]
}cd daemon
./daemonMake sure conf.json is in same folder as daemon The daemon will:
- start HTTP server on port 14920 (normal ports may be occupied so)
- advertise itself via mDNS
- scan files every 30 seconds
./client -url https://example.com/file.iso./client -hash <sha256>./client -url https://example.com/file.iso -o ubuntu.isoStudent A downloads:
ubuntu-24.04.iso
The daemon indexes the file and advertises availability on the LAN.
Later, Student B runs:
./client -url https://releases.ubuntu.com/ubuntu-24.04.isoInstead of downloading from the internet again, the file is transferred directly over the LAN.
NGHOST is designed for trusted local networks and cooperative file sharing.
Current implementation:
- no authentication
- no encryption
- no access control
Do not expose the daemon directly to the public internet.
Shared networks often suffer from repeated downloads of identical large files:
- Linux ISOs
- datasets
- game installers
- lecture videos
- development tools
NGHOST reduces redundant internet traffic by turning the LAN itself into a cooperative cache.
This is a LAN project so it will only work if some other user in the same LAN is running the daemon and they have the file avaliable otherwise it will work as a normal downloader.
This code is Ai-Assisted but if you cannot understand any function just contact me.
Idea and inspiration from : https://github.com/PurviMalhotra/Ghost
