* core/src/translation: Add unit tests
* core/src/translation: Support dns4 and dns6
Add dns4 and dns6 as valid protocol replacements for the origin address
to construct external addresses of a given node.
* core/nodes/network: %s/nat_translation/address_translation/
When receiving an observed address on a tcp connection that we initiated, the
observed address contains our tcp dial port, not our tcp listen port. We know
which port we are listening on, thereby we can replace the port within the
observed address.
When receiving an observed address on a tcp connection that we did **not**
initiated, the observed address should contain our listening port. In case it
differs from our listening port there might be a NAT along the path.
With the above in mind, the function name `nat_translation` is misleading.
* Rename RawSwarm* to Network*.
To complete the cut performed in [1].
The only remaining mention of a "swarm" in libp2p-core is in some tests
which actually depend on libp2p-swarm.
[1]: https://github.com/libp2p/rust-libp2p/pull/1188
* Post-merge corrections.
* Replace unbounded channels with bounded ones.
To remove the unbounded channels used for communicating with node tasks
an API similar to `futures::Sink` is used, i.e. sending is split into a
start and complete phase. The start phase returns `StartSend` and first
attempts to complete any pending send operations. Completing the send
means polling until `Poll::Ready(())` is returned.
In addition this PR has split the `handled_node_tasks` module into
several smaller ones (cf. `nodes::tasks`) and renamed some types:
- `nodes::handled_node_tasks::NodeTask` -> `nodes::tasks::task::Task`
- `nodes::handled_node_tasks::NodeTaskInner` -> `nodes::tasks::task::State`
- `nodes::handled_node_tasks::NodeTasks` -> `nodes::tasks::Manager`
- `nodes::handled_node_tasks::TaskClosedEvent` -> `nodes::tasks::Error`
- `nodes::handled_node_tasks::HandledNodesEvent` -> `nodes::tasks::Event`
- `nodes::handled_node_tasks::Task` -> `nodes::tasks::TaskEntry`
- `nodes::handled_node_tasks::ExtToInMessage` -> `nodes::tasks::task::ToTaskMessage`
- `nodes::handled_node_tasks::InToExtMessage` -> `nodes::tasks::task::FromTaskMessage`
* `take_over_to_complete` can be an `Option`.
Since it is always holding just a single pending message.
* `send_event_to_complete` can be an `Option`.
* Update core/src/nodes/tasks/manager.rs
Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>
* Update core/src/nodes/tasks/manager.rs
Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>
* Add comments to explain the need to flush sends ...
of take-over and event messages delivered over Sinks.
* Rename Transport::RawConn to Output
* Remove AsyncRead + AsyncWrite bound on Transport::Output
* UpgradedNode now always implements Transport
* Add and tweak modifiers for Transport and ConnectionUpgrade
* Secio upgrade now returns the pubkey in its output
* Add upgrade::apply
* Add Transport::and_then
* Rework the swarm
* Rustfmt
* Fix concerns
Currently, connection substreams are added to
`connection_reuse::Shared::active_connections`, but never removed. This
is not least because the `StreamMuxer` trait defines its inbound and
outbound substream futures to always yield a substream and contains no
provision to signal that no more substreams can be created, which would
allow client code (e.g. `ConnectionReuse`) to detect this and purge its
caches.
This PR defines the `StreamMuxer` trait to optionally yield
inbound/outbound substreams and changes `libp2p-mplex` to handle
stream EOFs by marking the underlying resource as closed.
`ConnectionReuse` will remove stream muxers from its active connections
cache if a `None` substream is returned.