rust-libp2p icon indicating copy to clipboard operation
rust-libp2p copied to clipboard

Autonat doesn't support multiple addresses well

Open nazar-pc opened this issue 2 years ago • 3 comments

Right now autonat sends concatenation of other_addresses and listen_addresses, which are always processed in the same order by receiving side: https://github.com/libp2p/rust-libp2p/blob/caf9da4a69f1cce8183d4b17c792476ee44c37bc/protocols/autonat/src/behaviour/as_client.rs#L188-L206

If my understanding of the code is correct, only the first successfully dialed address will be returned.

This is problematic in case of multiple addresses though:

  • out of multiple public addresses only the first one will be confirmed
  • mix of public and private addresses doesn't seem to play very nicely with this either

I think the solution here is that either sender of the probe or receiver should shuffle addresses such that we check different addresses.

I'm not very familiar with autonat right now to understand if it is architecturally supposed to support this use case at all since confirmations will be done for different addresses in different calls.

nazar-pc avatar Nov 16 '23 08:11 nazar-pc

AutoNATv2 will allow us to probe addresses individually.

Instead of optimizing AutoNATv1, I suggest we tackle this as part of https://github.com/libp2p/rust-libp2p/issues/4524.

mxinden avatar Nov 16 '23 14:11 mxinden