Dream is a peer-to-peer streaming platform powered by BitTorrent and a decentralized tracker with Kademlia DHT.
The current video streaming ecosystem is dominated by centralized platforms. While convenient, these systems come with significant drawbacks:
- Bottlenecks: Centralized servers can struggle under high demand.
- Censorship: Content can be removed or restricted due to external pressures.
- High Costs: Maintaining large-scale server infrastructure is expensive.
Dream addresses these challenges by decentralizing video streaming. By leveraging the efficiency of BitTorrent and the robustness of Kademlia DHT, Dream empowers users to share and stream content directly without intermediaries. The result? A more open, democratic, and scalable streaming solution.
- Decentralized Tracker: Uses Kademlia DHT for peer discovery, eliminating the need for central servers.
- Efficient Streaming: Streams video directly from peers using the BitTorrent protocol for seamless playback.
- On-Demand HTTP Streaming: Fully compatible with any video player that supports HTTP.
- Private Networks: Enables private deployments for home or institutional use.
- Simple CLI Interface:
dream-cli
provides an intuitive command-line tool for browsing, uploading, and streaming videos.
Here are a couple prerequisites to get setup before moving on:
- ElasticSearch server running on port 9200
- Rust toolchain
- A video player like mpv
Follow these steps to set up Dream:
- Clone the repository and build the project:
git clone https://github.com/kamui-fin/dream.git
cd dream
cargo build --release cp target/release/dream-dht /usr/local/bin
cp target/release/dream-torrent /usr/local/bin
cp target/release/dream-cli /usr/local/bin
- Configure settings:
mkdir ~/.config/dream
cp config.toml ~/.config/dream
Update the following variables in ~/.config/dream/config.toml
:
bootstrap_ip
: IP of the bootstrap server (uselocalhost
if starting a new network).output_dir
: Directory where downloaded video files are stored.private_dht
: Enable this if you want to restrict the network to private use.
- Forward necessary ports on your router:
- BitTorrent (default: 6881)
- DHT (default: 8999)
- ElasticSearch (default: 9200) if acting as a bootstrap node.
- Start the required services:
dream-dht &
dream-torrent
The architecture of dream is relatively simple. There are mainly three services that should be ran 24/7:
- Kademlia DHT (
dream-dht
) - This functions as the decentralized BitTorrent tracker, allowing the BT engine to fetch peers associated with a video to download and upload. It essentially manages the p2p network by itself. - BitTorrent engine (
dream-torrent
) - Similar totransmission
, just another BitTorrent client. Essentially ensures that only the necessary data is downloaded from peers. - HTTP Stream server (part of
dream-torrent
) It gets video data from the BT engine on-demand, and supplies it to any video player supporting HTTP.
The CLI simplifies interaction with Dream's network. Examples:
- Upload a video file:
dream-cli upload video.mp4 "title"
- Upload an external torrent file:
dream-cli upload video.torrent "title"
- Stream a video by searching its title:
dream-cli stream "query"
A bootstrap node serves as the entry point to a Dream network by providing peers with initial connection information. In addition to this role, bootstrap nodes currently maintain an index of all available videos for search functionality (e.g., fuzzy search). Future updates aim to decentralize this indexing process for greater scalability.
By no means did we include fully featured implementations of the protocols, so feel free to open a PR and contribute! We're also open to any bug reports or feature ideas.
There's a lot of potential and work to be done in the p2p space, so we're excited to discover more!
Here’s what’s next for Dream:
- Optimize speed through caching and dynamic load balancing
- Modularize codebase for easier integration into other projects
- Improve error handling for better debugging experiences
- Add support for UDP trackers
- Reduce required port forwarding to a single port
- Decentralize the video index for improved scalability
Distributed under the GPLv3 License. See LICENSE
for more information.