fiorenzo-rutschmann / PHP-K-DHT

A PHP implementation of the Bittorrent DHT protocol
BSD 2-Clause "Simplified" License
24 stars 9 forks source link

get_peers() #1

Open XJIOP opened 11 years ago

XJIOP commented 11 years ago

how to decode output?

0Array ( [id] => d4i2bc1a6g78f53h9e0j [info_hash] => E% ��C��i���ј38/S6 ) Array ( [q] => get_peers [t] => fb [y] => q ) construct_bencode output = d1:ad2:id20:d4i2bc1a6g78f53h9e0j9:info_hash20:E% ��C��i���ј38/S6e1:q9:getpeers1:t2:fb1:y1:qe 0here d1:rd2:id20:r-��7�o��y{���C��B5:nodes208:����ߖT$�x�p����fD�8�� BV��Ӎw�X�� ��p����;�Y�V M�����f�)��\a�-0kft`�/${-�xu���DY^A��rWj\ ���p�>؈;�*�q^)j�� n��f�QqX�j<� �J:�v�O�.k�Tĺ�����Sq�_ �U1�>)��k-p�(�x�����1�cOf�<��e1:t2:fb1:v4:UT�1:y1:re

fiorenzo-rutschmann commented 11 years ago

Hi XJIOP

Thanks for taking interest in my project.

I have half written a decoding class for the nodes, ill see if i can work on get_peers() for you tonight.

Can i ask what you are wanting to-do with my project, so i can focus on coding it for your needs first?

Thanks Fiorenzo Rustchmann.

XJIOP commented 11 years ago

Hi fiorenzo-rutschmann,

Thanks for you code!

get peers per info_hash from DHT is a very interesting idea, i have long been looking for a way to do this on php.

I will test your code

XJIOP commented 11 years ago

should return the number of peers in the string "values", but it is not here

how to connect to nodes to get a number of peers?

0Array ( [id] => a5ebdhg0846ji92173fc [info_hash] => E% ��C��i���ј38/S6 ) Array ( [q] => get_peers [t] => q2 [y] => q ) construct_bencode output = d1:ad2:id20:a5ebdhg0846ji92173fc9:info_hash20:E% ��C��i���ј38/S6e1:q9:getpeers1:t2:q21:y1:qe d1:rd2:id20:r-��7�o��y{���C��B5:nodes208:�f$ [Il5��6��]�*V��~��n�X�����6K5�� l�%��m@ �;k�d{s�Yx(�z�ON���N��$#s���� $\�H���B_�i�BQ� {' 2tT�M B��ĥ;�T�$MO���6�v��|�e�P��6��Ox�k�Ã���+�zh+YA�R�W����lQ'f�K�� �B(Á���P�6�p��87�Т$��e1:t2:q21:v4:UT�1:y1:re

fiorenzo-rutschmann commented 11 years ago

I have not yet finished implementing get_peers() yet, sorry about the confusion. as with the bittorrent dht protocol the get_peers query can return dht nodes or bittorrent peers, I will need to implement a recursive algorithm for the times that get_peers returns dht nodes, what i will do tonight is get the situation where bittorrent peers are returned implemented.

thanks Fiorenzo Rutschmann

fiorenzo-rutschmann commented 11 years ago

I have made another commit focusing my work on get_peers(), it now returns an array of nodes or peers depends on what the server will give me, also changed the bootstrap node to transmission's one which is more forgiving. with the next commit ill focus on re-cursing over these returned nodes to find some peers. should be out in 24hrs :D.

if you are interested we could create a little "get_peers for torrent magnet link library" in php together?