lbryio / lbry-sdk

The LBRY SDK for building decentralized, censorship resistant, monetized, digital content apps.
https://lbry.com
MIT License
7.19k stars 483 forks source link

UDP port is always guessed for blob peers #3299

Closed keikari closed 3 years ago

keikari commented 3 years ago

In https://github.com/lbryio/lbry-sdk/blob/master/lbry/dht/node.py#L226 The results always have upd_port = None, which always makes the program guess which UDP port to use based on the TCP port.

So only nodes which ports are set by following rule, can be accessed for blob downloads.

if 3332 < tcp_port < 3400:
    udp_port = tcp_port + 1111
else:
    udp_port = tcp_port

Peers with different ports aren't detected as hosts, but are otherwise able to communicate with other nodes.

keikari commented 3 years ago

Used lbrynet 0.92 for testing and also checked with build of a current master branch. Added log.info(<what-case-it's-in and node-info-stuff>), to all cases in this loop https://github.com/lbryio/lbry-sdk/blob/master/lbry/dht/node.py#L228

Result: UDP port was always None. And so far I didn't find any peers which would've been is_good == true

For example ports TCP 3344 and UDP 3344 wouldn't work because it would try to use UDP 4455. I tried to make special case for TCP port 3344 to try with UDP port 3344 and that worked.

lyoshenka commented 3 years ago

The reason this happens is that we only store the TCP port on DHT nodes. Then we guess the UDP port based on the TCP port.

We should use the same port for TCP and UDP. We haven't donet this yet because some routers don't allow port mappings for both TCP and UDP on the same port.

If/when we switch to QUIC, this will stop being a problem at all because it will all be UDP