开发者

Talking with a Bittorrent client listening on a port?

I have one of my computers seeding a torrent file on port 45000. I am trying to write a small client in python (or perhaps perl) that helps me to determine the types of messages this client supports for which I need to perhaps do a handshake with the client. In Azureus, this is done using a call like peer.getSupportedMessages(). Is it开发者_如何学Go possible to do this using some library in python or perl?

An example of the returned messages would look like this:

BT_KEEP_ALIVE
BT_PIECE
BT_REQUEST
BT_UNCHOKE
BT_UNINTERESTED
BT_SUGGEST_PIECE
BT_HAVE_ALL
BT_HAVE_NONE
BT_REJECT_REQUEST
BT_ALLOWED_FAST
BT_LT_EXT_MESSAGE
BT_DHT_PORT
lt_handshake
ut_pex


From what I can tell, the list of supported messages is a part of a custom handshake message supported only by Azureus (and possibly some Azureus-compliant tools) and is not part of the official BitTorrent system. However, you can probably craft a bencoded AZ handshake, send it to your seeder, decode the response, and see what the supported messages are.

AZHandshake.java has the details of what the message should look like.

Using the Bencode module from CPAN, you could do something like:

  my $handshake = bencode { 
    identity => '', client => '', ... }; # All fields from AZHandshake.java

  # send handshake to seeder and get a response
  my $handshake_response = ...

  my $dictionary = bdecode $handshake_response;

  print join "\n", @{$dictionary->{messages}}, "\n";

Of course, the trick will be in setting up a proper handshake that will elicit a valid response from the seeder. Unfortunately, I don't know of anything that will just do it without requiring a little bit of programming work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜