Skip to content

bitTorrent client for downloading and uploading files, personal use mostly. In development

License

Notifications You must be signed in to change notification settings

JohnCarterGonzalez/myTorrent

Repository files navigation

myTorrent - BitTorrent Client

Introduction

myTorrent is a simple BitTorrent client that decodes bencoded torrent files and interacts with the BitTorrent network to download files. It’s a command-line utility written in shell script, making use of utilities like curl for HTTP requests and standard Linux tools for data manipulation.

How It Works

myTorrent works by implementing the BitTorrent protocol which includes parsing .torrent files, communicating with trackers, and handling peer connections to download files.

Bencode Decoding

Bencode is the encoding format used by the BitTorrent protocol to store and transmit loosely structured data. It supports strings, integers, lists, and dictionaries. myTorrent can decode this data into JSON format.

Torrent File Parsing

Parses .torrent files to extract key information such as announce URLs, file length, and pieces info which is essential for downloading the file.

Tracker Interaction

Communicates with trackers to get a list of peers, send periodic updates, and receive a list of potential peers to connect to.

Peer Communication

Establishes TCP connections with peers, completes handshakes, and manages data transfer including requesting pieces of the file and assembling them.

File Assembly

Once all the pieces are downloaded, myTorrent verifies each piece’s integrity with SHA-1 hash checks before assembling them into the final file.

Components Overview

myTorrent is divided into stages, each responsible for a specific aspect of the BitTorrent protocol:

  1. Bencode Decoding
  2. Torrent File Parsing
  3. Tracker Communication
  4. Peer Handshake and Data Exchange
  5. File Download and Assembly

The below graph represents the flow of data and control through the application:

[ Torrent File ]
        |
        v
[ Bencode Decoder ] ---> [ Parser ] ---> [ Tracker Requester ]
                                          |                |
                                          |                v
                                          |       [ Peer Discovery ]
                                          |                |
                                          v                v
                                    [ File Assembler ] <---+

Usage

Basic commands for interacting with the myTorrent client:

# To decode a bencoded string
./your_bittorrent.sh decode <bencoded_string>

# To parse a torrent file and print info
./your_bittorrent.sh info <path_to_torrent_file>

# To get the list of peers from the tracker
./your_bittorrent.sh peers <path_to_torrent_file>

# To perform a handshake with a peer
./your_bittorrent.sh handshake <path_to_torrent_file> <peer_ip>:<peer_port>

# To download a specific piece of the file
./your_bittorrent.sh download_piece -o <output_path> <path_to_torrent_file> <piece_index>

# To download the entire file
./your_bittorrent.sh download -o <output_path> <path_to_torrent_file>

Installation

To set up the myTorrent client on your machine, clone this repository and ensure you have the necessary dependencies installed. Instructions here…

Contributing

Contributions to myTorrent are welcome! If you want to contribute to the project, please fork the repository, make your changes, and submit a pull request.

License

myTorrent is open-sourced software licensed under the MIT license.

About

bitTorrent client for downloading and uploading files, personal use mostly. In development

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published