lgbo
lgbo

Reputation: 221

The token of announce_peer in DHT

In http://www.bittorrent.org/beps/bep_0005.html, the announce_peer query needs a token which has the require ,"the "token" received in response to a previous get_peers query".

Does it mean that if node A has never send a get_peer query to node B, then node A would never receive a peer_announce query from node B ?

Upvotes: 3

Views: 1254

Answers (3)

Never Sleep Again
Never Sleep Again

Reputation: 1350

The token represents a capability to announce that one is joining a swarm. It's like first you ask about the swarm -- "Hey, what's up with this swarm?" -- and the peer you ask tells you what it knows about that swarm, and it also gives you a ticket you can return, or not, if you want to join that swarm too. Fine-grained capability security for the win!

Upvotes: 0

Bora M. Alper
Bora M. Alper

Reputation: 3844

Does it mean that if node A has never send a get_peer query to node B, then node A would never receive a peer_announce query from node B ?

No, it's the other way around:

  • Node A wants to announce that it is downloading a certain torrent.
  • Node A makes a get_peers query to Node B.
  • Node B sends a response to Node A for the get_peers query that it has just sent. Node B's response includes the token.
  • Node A, now, can send an announce_peer query to Node B using the token it has just received from Node B's response.

Why all this fuss?

The return value for a query for peers includes an opaque value known as the "token." For a node to announce that its controlling peer is downloading a torrent, it must present the token received from the same queried node in a recent query for peers. When a node attempts to "announce" a torrent, the queried node checks the token against the querying node's IP address. This is to prevent malicious hosts from signing up other hosts for torrents.

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

Upvotes: 3

Matt Joiner
Matt Joiner

Reputation: 118470

Yes that's right. It ensures that someone announcing a peer is actually interested in the corresponding torrent, and has demonstrated control over the announced address.

Upvotes: -1

Related Questions