mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-29 02:31:20 +00:00
Previously a `Listener` would return its own address as the `remote_addr` in the `ListenerEvent::Upgrade` event. With this commit a `Listener` returns the dialer address as the `remote_addr` in the `ListenerEvent::Upgrade` event. To do so a `DialFuture` registers a port with the global `HUB` at construction which is later on unregistered in the `Drop` implementation of the dialer's `Chan`. The sending side of the `mpsc::channel` registered in the `HUB` is dropped at `DialFuture` construction, thus one can not dial the dialer port. This mimics the TCP transport behaviour preventing both dialing and listening on the same TCP port.