BitTorrent peers with zero ports

335 Views Asked by At

Occasionally trackers, DHT nodes, and PEX peers offer peer addresses with a port of 0. What does this mean? In the context of submitting one's own port to a tracker, or in DHT, sending a port of 0 means that the recipient should use the sender's apparent port, due to NAT or similar. But when receiving a list of possible peers for a torrent, how do you interpret a port of 0 then?

2

There are 2 best solutions below

3
On

In the context of submitting one's own port to a tracker, or in DHT, sending a port of 0 means that the recipient should use the sender's apparent port

I am curious from which specification you're deriving that.

But when receiving a list of possible peers for a torrent, how do you interpret a port of 0 then?

Have you considered that it simply might be bogus data, not sanitized by the sender?

Rejecting port zero is not a requirement, since it's technically a valid port (although in practice not really usable) and even if it were you cannot rely on others to sanitize data for you.

2
On

I suspect you've stumbled on a bug in your tracker or other. You will not be able to connect to a peer's port 0 so reject those peers as not actually legit.