maidsafe / sn_routing

Routing - specialised storage DHT
Other
278 stars 81 forks source link

Make sure that for any two nodes a connection between them can be established in both directions #2282

Closed madadam closed 3 years ago

madadam commented 3 years ago

Currently when a node is joining the network, it sends a JoinRequest message to some existing nodes. This implicitly creates connections from the joining node to the existing nodes. When the existing nodes send back a response, that response is likely sent over the existing connection created by the joining node. This is potentially a problem, because it can be that the joining node is behind a NAT or similar setup and so while it can create connections to existing node, the existing node might not be able to create connection to it. Accepting such node might have potentially catastrophic consequences because after the initial connection is dropped (due to inactivity or any other reason), the other nodes won't be able to open a new connection to it and so it would appear dead.

A solution is to make sure the existing nodes can open a connection to the joining node before processing the JoinRequest. This can be as simple as just trying to open a connection and checking that it succeeds. In case that's not sufficient, we might want to send a message over a new connection and check the send succeeded. In case even that is not sufficient, we might need to use some kind of two-way exchange - send a message to the joining node and wait for the node to send us some response back.