mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-07 13:41:35 +00:00
protocols/dcutr/examples: Wait to tell relay its public addr (#2659)
As a listening client, when requesting a reservation with a relay, the relay responds with its public addresses. The listening client can then use the public addresses of the relay to advertise itself as reachable under a relayed address (`/<public-relay-addr>/p2p-circuit/p2p/<listening-client-peer-id>`). The above operates under the assumption that the relay knows its public address. A relay learns its public address from remote peers, via the identify protocol. In the case where the relay just started up, the listening client might be the very first node to connect to it. Such scenario allows for a race condition. The listening client requests a reservation from the relay, while the relay requests its public address from the listening client. The former needs to contain the response from the latter. This commit serializes the two requests, making sure, in the case of a freshly started relay, that the listening client tells the relay its public address before requesting a reservation from the relay. Co-authored-by: Elena Frank <elena.frank@protonmail.com>
This commit is contained in:
@ -136,8 +136,10 @@
|
||||
//! [2022-05-11T10:38:52Z INFO client] Local peer id: PeerId("XXX")
|
||||
//! [2022-05-11T10:38:52Z INFO client] Listening on "/ip4/127.0.0.1/tcp/44703"
|
||||
//! [2022-05-11T10:38:52Z INFO client] Listening on "/ip4/XXX/tcp/44703"
|
||||
//! [2022-05-11T10:38:54Z INFO client] Relay told us our public address: "/ip4/XXX/tcp/53160"
|
||||
//! [2022-05-11T10:38:54Z INFO client] Told relay its public address.
|
||||
//! [2022-05-11T10:38:54Z INFO client] Relay accepted our reservation request.
|
||||
//! [2022-05-11T10:38:54Z INFO client] Relay observes us under the address: "/ip4/XXX/tcp/53160"
|
||||
//! [2022-05-11T10:38:54Z INFO client] Listening on "/ip4/$RELAY_SERVER_IP/tcp/4001/p2p/12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN/p2p-circuit/p2p/XXX"
|
||||
//! ```
|
||||
//!
|
||||
//! Now let's make sure that the listening client is not public, in other words let's make sure one
|
||||
|
Reference in New Issue
Block a user