15 Commits

Author SHA1 Message Date
Pierre Krieger
b6378ac526
PollParameters is now a trait (#1177)
* PollParameters is now a trait

* Fix unused variable
2019-06-18 10:23:26 +02:00
Pierre Krieger
78d6f44e46
Allow customizing the Swarm with TConnInfo (#1172) 2019-06-12 16:21:39 +02:00
Pierre Krieger
603fd5744f
No longer require fmt::Debug when not necessary (#1158) 2019-06-04 13:08:37 +02:00
Toralf Wittner
fd0e48bf37 Add IntoProtocolsHandler::inbound_protocol. (#1099) 2019-05-08 20:23:28 +02:00
Toralf Wittner
77ce5a52dd
Add ranked address collection. (#1096)
Keep external addresses in a ranked collection and ensure iteration is
performed in order from highest to lowest rank.
2019-05-02 19:46:27 +02:00
Pierre Krieger
5c34f8a0ed
&mut self -> &mut Self (#1073) 2019-04-23 10:54:25 +02:00
Fedor Sakharov
7dc95e78f7 swarm: ban connections based on peerid (#1065)
* swarm: ban connections based on peerid

* Update core/src/swarm/swarm.rs

Co-Authored-By: montekki <fedor.sakharov@gmail.com>

* Update core/src/swarm/swarm.rs

Co-Authored-By: montekki <fedor.sakharov@gmail.com>

* remove the testing code

* close connections on ban ban_peer_id

* adds code to unban a peer

* simplify connection closing code

* remove blank line

* ignore DialPeer actions and inject_dial_failure

* Update core/src/swarm/swarm.rs

Co-Authored-By: montekki <fedor.sakharov@gmail.com>

* Update core/src/swarm/swarm.rs

Co-Authored-By: montekki <fedor.sakharov@gmail.com>

* bring back the .expect()
2019-04-18 18:17:14 +02:00
Toralf Wittner
ca58f8029c
Remove Transport::nat_traversal and refactor multiaddr. (#1052)
The functionality is available through `Multiaddr::replace`.
What we currently call "nat_traversal" is merley a replacement of an IP
address prefix in a `Multiaddr`, hence it can be done directly on
`Multiaddr` values instead of having to go through a `Transport`.

In addition this PR consolidates changes made to `Multiaddr` in
previous commits which resulted in lots of deprecations. It adds some
more (see below for the complete list of API changes) and removes all
deprecated functionality, requiring a minor version bump.

Here are the changes to `multiaddr` compared to the currently published
version:

1.  Removed `into_bytes` (use `to_vec` instead).
2.  Renamed `to_bytes` to `to_vec`.
3.  Removed `from_bytes` (use the `TryFrom` impl instead).
4.  Added `with_capacity`.
5.  Added `len`.
6.  Removed `as_slice` (use `AsRef` impl instead).
7.  Removed `encapsulate` (use `push` or `with` instead).
8.  Removed `decapsulate` (use `pop` instead).
9.  Renamed `append` to `push`.
10. Added `with`.
11. Added `replace`.
12. Removed `ToMultiaddr` trait (use `TryFrom` instead).
2019-04-17 20:12:31 +02:00
Pierre Krieger
a953b613cf
Add NetworkBehaviour::inject_new_external_addr (#1063) 2019-04-16 17:00:20 +02:00
Roman Borschel
bee5c58b27
libp2p-ping improvements. (#1049)
* libp2p-ping improvements.

  * re #950: Removes use of the `OneShotHandler`, but still sending each
    ping over a new substream, as seems to be intentional since #828.

  * re #842: Adds an integration test that exercises the ping behaviour through
    a Swarm, requiring the RTT to be below a threshold. This requires disabling
    Nagle's algorithm as it can interact badly with delayed ACKs (and has been
    observed to do so in the context of the new ping example and integration test).

  * re #864: Control of the inbound and outbound (sub)stream protocol upgrade
    timeouts has been moved from the `NodeHandlerWrapperBuilder` to the
    `ProtocolsHandler`. That may also alleviate the need for a custom timeout
    on an `OutboundSubstreamRequest` as a `ProtocolsHandler` is now free to
    adjust these timeouts over time.

Other changes:

  * A new ping example.
  * Documentation improvements.

* More documentation improvements.

* Add PingPolicy and ensure no event is dropped.

* Remove inbound_timeout/outbound_timeout.

As per review comment, the inbound timeout is now configured
as part of the `listen_protocol` and the outbound timeout as
part of the `OutboundSubstreamRequest`.

* Simplify and generalise.

Generalise `ListenProtocol` to `SubstreamProtocol`, reusing it in
the context of `ProtocolsHandlerEvent::OutboundSubstreamRequest`.

* Doc comments for SubstreamProtocol.

* Adapt to changes in master.

* Relax upper bound for ping integration test rtt.

For "slow" CI build machines?
2019-04-16 15:57:29 +02:00
Pierre Krieger
9b6336672b
Add NetworkBehaviour methods for listened addresses (#1061) 2019-04-16 15:36:08 +02:00
Toralf Wittner
6917b8f543
Have Transport::Listeners produce ListenerEvents. (#1032)
Replace the listener and address pair returned from `Transport::listen_on` with just a listener that produces `ListenerEvent` values which include upgrades as well as address changes.
2019-04-10 10:29:21 +02:00
Pierre Krieger
480cf380d7
Add ExpandedSwarm (#1046) 2019-04-07 18:34:14 -03:00
Pierre Krieger
b176032a07
Generalize TPeerId into TConnInfo (#1045)
* Generalize TPeerId into TConnInfo

* Final fixes
2019-04-05 13:37:12 -03:00
Pierre Krieger
1d4324ab70
Split the Swarm from the NetworkBehaviour (#1035) 2019-04-04 12:25:42 -03:00