Pergunta

I'd like to (via PHP) gather the info_hashes currently being downloaded or search the DHT.

I've seen BTDigg which uses DHT for a search engine and I'd like to do something similar.

Also, after I get the hashes, how do I convert the hash into a torrent so I can get the information such as title etc? (once again through the DHT using PHP).

I tried researching first - Query DHT Server tries to run a DHT Query via PHP, I tried making modifications but I had no luck. I've also tried http://projects-deim.urv.cat/trac/p2pweb/browser/trunk/dht/dht_agg?rev=1 but it gave me several errors and after many fixes it still didn't work.

Foi útil?

Solução

To implement a DHT node, you probably want to read the DHT specification:

http://www.bittorrent.org/beps/bep_0005.html

It describes the message format. If you're not familiar with the underlying DHT, you probably need to read the kademlia paper as well:

Kademlia: A Peer-to-peer Information System Based on the XOR Metric

Once you're up and running on the DHT, and you start seeing info-hashes fly by, you need to implement a bittorrent client. Or at least the bare bones of one in order to make peer connections and talk a subset of the bittorrent protocol, which is described here:

http://www.bittorrent.org/beps/bep_0003.html

You mostly just need to be able to make a TCP connection and handshake as if you don't have anything. Then, to download the metadata (or .torrent file), you need to support the ut_metadata extension, which sits on top of the general extension protocol, described here:

http://www.bittorrent.org/beps/bep_0010.html

ut_metadata extension is described here:

http://www.bittorrent.org/beps/bep_0009.html

Ones you have metadata for hashes you see, you should essentially be set. Then it's just a matter of extracting and indexing information such as names, filenames, file sizes, etc. from torrent files (you actually just end up with the info-dict of the torrent files, but that's the important part).

Given that this is quite a bit of work all together, you might want to look at using libraries that does this already and somehow pull them in to php. You may for instance want to take a look at libtorrent.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top