Giter Club home page Giter Club logo

rustbit's Introduction

rust_bit

CI clippy

Toy project of a BitTorrent client implementation. I was curious to see how hard could be to build a BitTorrent client from scratch.

Usage

Start the server

cargo run --release

Call the API at /add/magnet whith whatever HTTP client you have and fill the data part with your magnet

curl --location 'localhost:8080/add/magnet' \
--header 'Content-Type: text/plain' \
--data '***'

To verify everything is working as expected you can take a look at test.log file

Architecture

I made some architectural decision during my exploration of the BitTorrent protocal that I will summarize below:

  • The BitTorrent encoding called Bencode is implemented without using any external crate. The reason was simple: it's way more fun this way.
  • The orchestration between the different concurrent compoments in this create are handled through an Actor model. I did test other options, but the Actor model made really easy to make the code readable and maintanable.
  • Only the client side of the protocol is implemented. Less work for me.
  • Minimal API interface, basically I only allow to add a magnet to download. The objective was to study and experiment with the protocol, having an APIs was not necessary.

Missing features

For lack of time and resources I cut some corners during the developement, thus some features are missing. No DHT protocol is present to locate available peers. Integration testing is missing, but looking at other similar repos I'm not alone. Doing integration tests with the BitTorrent protocol is challenging and require a not so trivial infrastructure management to fit everything inside the CI.

Code organization

The code is organized in the following folders:

  • actors: Collection of all actors that take part in the Actor model and the messages that they exchange each others.
  • bencode: Custom implementation of Bencode encoding.
  • messages: Rust structs representing the messages that peers exchange to each other in the protocol.
  • peer: Utilities to manage the connection between peers and the download of pieces.
  • torrent: Torrent representation in Rust.
  • tracker: Utilities to manage the communication with the trackers through UDP or TCP.

rustbit's People

Contributors

succodipompelmo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.