Live data from Hacker News

Show HN: I wrote a BitTorrent Client from scratch

github.com

61–68 of 68 posts

Re: Show HN: I wrote a BitTorrent Client from scratch

#61

How hard would it be to add a GUI to this? I don't think I've seen a lot of GO Gui implementations in the past

There's a bunch https://github.com/go-graphics/go-gui-projects My personal favourite is an ImGui wrapper https://github.com/AllenDang/giu The most featureful is probably unison, although I'm uncertain if anyone uses it outside of their own project ( https://gurpscharactersheet.com ), meaning documentation will be sparse https://github.com/richardwilkes/unison Gio uses a different way of thinking about GUIs, used by T…

I would like to echo performance (and other issues) with Fyne. Every time I try it again, I'm actually kind of baffled that it's so popular.

Last week I came across these Qt bindings: https://github.com/mappu/miqt

I have no personal experience with it yet, but am excited to try it out.

Re: Show HN: I wrote a BitTorrent Client from scratch

#62

This is cool! I’ve been thinking about something like this as well. How hard was it, and do you have a sense for how “complete” it is? Does it handle DHT and Magnet and all the crazy NAT traversal stuff? I’m guessing the main obstacle for me has always been that I’m not sure what the complete list of features is to have a client that will just work for the majority of torrents in the wild. It seems like there are doz…

How hard it is depends a lot on your experience, how comfortable you are with the programming language, and if you have an experimentation mindset. To offer a perspective, I also decided to build a Bittorrent client in Go last week, and I'm about 80% of the way of the posted project in a week. But then again I have a lot of experience with Go, extensive knowledge about protocols and networking, and experimentation has become a kind of second nature for me.

If you're interested, the main Bittorrent spec is actually quite small, you can easily read and understand it in an hour or so: https://www.bittorrent.org/beps/bep_0003.html

There's a lot of stuff "around" Bittorrent, like protocol extensions. But in my experience so far, many clients have different levels of support. E.g. they would try communicating using Protocol Encryption (obfuscation, actually) and if it doesn't work fall back to the regular protocol (if configured in the settings).

If you just want to download a Linux distribution (e.g. Debian) using the .torrent file on their website, it's relatively straight forward. It has just one file, there's a tracker, plenty of peers using the regular protocol, and you could get away not listening for connections when you're behind a NAT.

Naturally when you get into the grey area of content, then you'd need to parse magnet links, use DHT to discover peers, and perhaps you'd want to implement UPnP to try and automatically map a port on your modem. But that is also an iterative process, you can just build out one by one. The more features, the more peers you'll be able to discover and have successful exchanges with.

Re: Show HN: I wrote a BitTorrent Client from scratch

#63

Could this be used as a library?

I am not the one who created the post, but currently it doesn't seem to be usable as a library because most of the code is in a directory called "internal", which isn't accessible when using the repository as a dependency in another project.

Re: Show HN: I wrote a BitTorrent Client from scratch

#65
post #56

As a non go developer, may I ask why you're using older go version 1.21? Is there a reason to stay with older releases? EDIT: It seems like it was deprecated 10 months ago

The README is likely AI-generated. The actual go.mod file lists 1.23.1 as the Go version[1], which implies a requirement of Go 1.23.1 or higher[2]. [1] https://github.com/piyushgupta53/go-torrent-client/blob/6130... [2] https://go.dev/doc/modules/gomod-ref#go-notes

Go 1.21 includes an internal auto-updater that can compile later Go versions by looking in the go mod file itself.

So the README is correct.

Re: Show HN: I wrote a BitTorrent Client from scratch

#66
post #65
post #56

Earlier quoted context omitted.

The README is likely AI-generated. The actual go.mod file lists 1.23.1 as the Go version[1], which implies a requirement of Go 1.23.1 or higher[2]. [1] https://github.com/piyushgupta53/go-torrent-client/blob/6130... [2] https://go.dev/doc/modules/gomod-ref#go-notes

Go 1.21 includes an internal auto-updater that can compile later Go versions by looking in the go mod file itself. So the README is correct.

Automatic toolchain switching does not trigger compilation of later Go toolchains; it only attempts fetching a blob (if available) and using that to perform builds[1]. If a system supports Go 1.21 but not 1.23.1 (e.g. Windows 7, mentioned in a sibling comment), then this project will fail to build on said system. Likewise, if a user on Go 1.21 has disabled automatic toolchain switching, the Go CLI refuses to build the project at all.

Overall, I would say the minimum required Go version is indeed the Go version declared in the go.mod, since that is the declared minimum required toolchain.

[1] https://go.dev/doc/toolchain#select

Re: Show HN: I wrote a BitTorrent Client from scratch

#67
It's a great kind of project to try! I did something similar and I was humbled when looking at other people's bencode encoders/decoders. It's also a great way to check out language features! Of course it is quite futile to try to match all the features of large libraries, and I believe the compatibility between clients is already lacking...
Post reply on HN