Autonat doesn't support multiple addresses well
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.
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.