Get the latest tech news

Building a BitTorrent client from the ground up in Go (2020)


What is the complete path between visiting thepiratebay and sublimating an mp3 file from thin air? In this post, we'll implement enough of the BitTorrent protocol to download Debian. Look at the [Source code](https://github.com/veggiedefender/torrent-client/) or skip to the [last bit](/posts/torrent#putting-it-all-together).

Your money will pay for legal aid and bail for protestors who have been arrested for standing up to police brutality, institutional racism, and the murder of Black men and women like George Floyd, Breonna Taylor, Ahmaud Arbery, and Nina Pop. We now have all the tools we need to download a torrent: we have a list of peers obtained from the tracker, and we can communicate with them by dialing a TCP connection, initiating a handshake, and sending and receiving messages. In particular, they offer a BitTorrent challenge which walks you through everything described in this post — parsing bencode, discovering peers, and downloading pieces — with test harnesses and scaffolding code for a bunch of languages.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Ground

Ground

Photo of BitTorrent

BitTorrent

Photo of BitTorrent client

BitTorrent client

Related news:

News photo

What does it mean to build in security from the ground up?

News photo

Biden's Cyber Ambassador Urges Trump Not to Cede Ground to Russia and China in Global Tech Fight

News photo

Japan’s Carmakers Vow Closer Ties to Regain Ground in China