Skip to content

lavanderhoney/codecrafters-bittorrent-cpp

Repository files navigation

progress-banner

This is my C++ solutions to the "Build Your Own BitTorrent" Challenge.

In this challenge, I built a BitTorrent client that's capable of parsing a .torrent file and downloading a file from a peer. I also learnt about how torrent files are structured, HTTP trackers, BitTorrent’s Peer Protocol, pipelining and more.

Note: Head over to codecrafters.io to try the challenge.

Running the code

To test this client, you will have to seed a file using a thrid-party app like uTorrent, then get its .torrent metafile from that app. Put the metafile in the src directory to execute the commands

Building the project

  1. Clone the repository:

    git clone https://github.com/lavanderhoney/codecrafters-bittorrent-cpp.git
  2. Navigate to the project directory: cd codecrafters-bittorrent-cpp

  3. Build the project using cmake: cmake . make

Commands Implemented

The client supports several commands:

  • decode: Decodes bencoded data ./your_bittorrent decode <encoded_value>

  • info: Displays torrent metadata information ./your_bittorrent info <torrent_file>

  • peers: Lists available peers ./your_bittorrent peers <torrent_file>

  • handshake: Tests peer handshake protocol ./your_bittorrent handshake <torrent_file> <peer_ip>:<peer_port>

  • download_piece: Downloads specific pieces ./your_bittorrent download_piece -o <output_filename> <torrent_filename> <index>

  • download: Downloads complete files ./your_bittorrent download -o <output_filename> <torrent_filename>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages