This is a custom BitTorrent client built from scratch using Go. The client is capable of downloading torrents based on .torrent files. It utilizes several custom packages to handle torrent metadata parsing, peer connections, and file downloading. Future plans include running the client in a browser using WebAssembly.
.torrent files using the bencode encoding.git clone https://github.com/peterkwesiansah/bitty
cd bitty
Install the required Go packages:
go mod tidy
To run the BitTorrent client, you need to provide a source .torrent file and a destination path where the downloaded content will be stored.
go run main.go -src /path/to/source.torrent -dst /path/to/destination
Example:
go run main.go -src debian-12.5.0-amd64-netinst.iso.torrent -dst ./debian-12.5.0-amd64-netinst.iso
-src: Path to the source .torrent file. (Required)-dst: Path where the downloaded content should be saved. (Required)If the src or dst flags are missing, the program will prompt you to use the correct format.
run instead: go run main.go -src /path/to/source -dst /path/to/destination
bencode decoding and prepares the necessary information for downloading.Torrent struct to manage the process.bencodeTorrent: Handles parsing of the .torrent file and decoding the bencode format.peers: Manages peer discovery and P2P communication.torrentfile: Manages the actual downloading of the torrent data, ensuring that pieces are correctly ordered and written to the destination.One of the future goals is to compile this BitTorrent client to WebAssembly (Wasm), allowing it to run in a browser environment. The major steps involved in achieving this include:
FileSystem API for writing downloaded content, so the current file-writing logic will need to be adjusted for WebAssembly.magnet links.Contributions are welcome! If you have ideas for new features or improvements, feel free to fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.
$ claude mcp add bitty \
-- python -m otcore.mcp_server <graph>