How veggiedefender/torrent-client works
This Go CLI downloads a single-file torrent from a .torrent file to a destination path. Its main workflow parses torrent metadata, asks an HTTP tracker for peers, downloads and verifies pieces over BitTorrent peer connections, then writes the assembled bytes. The architecture separates tracker discovery, peer-protocol handling, and piece scheduling/assembly. The README also documents the product’s limits: no magnet links, multi-file torrents, or uploading. The graph follows the sampled call paths; unsampled behavior is not inferred.
Main entry points: p2p.go Download coordinator · torrentfile.go Torrent file · client.go Peer connection · tracker.go HTTP tracker
Components 13
CLI workflow
- CLI entry
main.go
Torrent metadata
- Torrent file
torrentfile/torrentfile.go
Peer discovery
- HTTP tracker
torrentfile/tracker.go - Peer addresses
peers/peers.go
Peer transfer
- Download coordinator
p2p/p2p.go - Peer connection
client/client.go - Peer handshake
handshake/handshake.go - Wire messages
message/message.go - Piece availability
bitfield/bitfield.go
Other components
- User
- HTTP tracker service
- BitTorrent peer
- Downloaded file
Connections 15
- User → CLI entry: runs command
- CLI entry → Torrent file: opens torrent
- Torrent file → HTTP tracker: requests peers
- HTTP tracker → HTTP tracker service: queries
- HTTP tracker → Peer addresses: decodes addresses
- Torrent file → Download coordinator: starts download
- Download coordinator → BitTorrent peer: requests pieces
- Download coordinator → Peer connection: connects to peer
- Peer connection → Peer handshake: exchanges handshake
- Peer connection → Wire messages: reads and sends
- Peer connection → Peer addresses: formats address
- Download coordinator → Piece availability: checks availability
- Download coordinator → Wire messages: parses peer data
- Download coordinator → Downloaded file: assembles bytes
- Torrent file → Downloaded file: writes file