libp2p / rust-libp2p

The Rust Implementation of the libp2p networking stack.
https://libp2p.io
MIT License
4.51k stars 934 forks source link

identify: support specifying listen addresses #5614

Closed retrohacker closed 4 hours ago

retrohacker commented 5 hours ago

Description

Currently identify sends all addresses it is aware of from the swarm. Instead we would like to be explicit about the addresses we send to remote peers.

previous exploration: #4010

Motivation

We have a network topology where all nodes participating in Mode::Server in the kad overlay network are expected to be fully connected.

To this end, we colocate our AutoNAT and DCUtR servers with our bootstrap nodes. The assumption for this topology is that the bootstrap nodes are connected to a single physical network, and that network is the network a client must be connected to in order to upgrade to Mode::Server without a relay. Every other node in the topology stays in Mode::Client or, if they need to share resources, relies on DCUtR.

We are using AutoNAT to confirm the reachability of addresses and are successfully compiling a list of external addresses that are confirmed reachable from the bootstrap nodes.

But our identify protocol is still sending all our unconfirmed addresses to peers resulting in the same dialing behaviour prior to AutoNAT.

Allowing explicit control over the addresses the identify protocol will share seems to be in-line with the modular/configurable architecture of rust-libp2p.

I understand the articulation in #4010 that we should treat the listen addresses received from identify as untrusted and do the work to verify them receiving side. That is rational; but this proposal is to give the sender more control over the addresses they choose to share with peers.

Alternatively, we could keep the coupling between identify and swarm, and instead have a flag that only sends external addresses. So the act of explicitly upgrading a listen address to an external address in the swarm would be reflected in identify.

Requirements

  1. Decouple identify's knowledge of interfaces from swarm
  2. Introduce an add_listener and remove_listener API call to control the addresses we announce

Or

  1. Add configuration option only announce external addresses

Open questions

Decoupling identify's knowledge of interfaces from the swarm would be a backwards incompatible change - maybe we can instead turn off this behaviour with a configuration flag?

Are you planning to do it yourself in a pull request ?

Yes

retrohacker commented 4 hours ago

Actually it looks like the second option (adding a configuration option) was merged in https://github.com/libp2p/rust-libp2p/pull/5507

:raised_hands:

retrohacker commented 4 hours ago

Closing this as resolved via #5507