Reputation: 11012
I'm probably lacking in some fundamental understanding of how BitTorrent, DHT, and the "swarm" work, as I'm not even sure if DHT and the "swarm" are one and the same.
However, I'm trying to find peers, the number of peers, and some statistics about a torrent from its magnet link (and hash).
I've looked for some libraries to accomplish this, but they seem either outdated or unrelated, or just bencode things.
How do I go about connecting and requesting information? A brief explanation would be delightful.
Upvotes: 2
Views: 1442
Reputation: 43052
official specs: http://www.bittorrent.org/beps/bep_0000.html
non-official spec: http://wiki.theory.org/BitTorrentSpecification
BEncoding is a data serialization format used in bittorrent for several purposes
The DHT is a global, decentralized, iterative, UDP-based lookup system which can be used to locate clients participating in a particular swarm based on an infohash, which can be either obtained directly from a magnet link or calculated from a .torrent metadata file.
If you have the announce URL for a tracker (an optional part of the torrent file or the magnet link) you can obtain client addresses directly from a tracker.
Once you have obtained client addresses for a particular swarm you can connect to them - or they will connect to you if you have announced yourself to the DHT/a responsible tracker - using the bittorrent wire protocol, which is basically an asynchronous, binary messaging protocol.
To get a fully-functioning, state-of-the-art bittorrent client you have to implement the following:
This is a lot of work which to my knowledge has not been done in ruby. So either you have a lot ahead of yourself or you might want to use a bittorrent library written in a different language (e.g. libtorrent) or interface with a client providing a web service (e.g. transmission).
Upvotes: 5