Commit Graph

1009 Commits

Author SHA1 Message Date
79c7307b0f Update to yamux 0.2.0 (#1069) 2019-04-18 15:04:30 +02:00
5a465b7f50 Fix multiaddr::util::BytesWriter. (#1068)
The current implementation does not properly reserve enough space for
`Write::write_all` to succeed. The property test has been improved to
trigger that issue.
2019-04-18 14:28:47 +02:00
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
a4173705db Add some TryFrom implementations (#1060) 2019-04-17 14:16:50 +02:00
3ec9c37e17 Update examples to print a listen address. (#1064)
This was no longer the case since https://github.com/libp2p/rust-libp2p/pull/1032.
2019-04-16 19:57:16 +02:00
a953b613cf Add NetworkBehaviour::inject_new_external_addr (#1063) 2019-04-16 17:00:20 +02:00
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
9b6336672b Add NetworkBehaviour methods for listened addresses (#1061) 2019-04-16 15:36:08 +02:00
889f003a3f Update README.md (#1059) 2019-04-16 15:13:44 +02:00
4848058776 Fix the WASM build (#1062) 2019-04-16 14:58:14 +02:00
05a74aed43 Expand wildcard IP addresses in TCP transport. (#1044)
Wildcard IP addresses (e.g. 0.0.0.0) are used to listen on all host
interfaces. To report those addresses such that clients know about them
and can actually make use of them we use the `get_if_addrs` crate and
maintain a collection of addresses. We report the whole expansion at the
very beginning of the listener stream with `ListenerEvent::NewAddress`
events and add new addresses should they come to our attention.

What remains to be done is to potentially allow users to filter IP
addresses, for example the local loopback one, and to detect expired
addresses not only if a new address is discovered.
2019-04-11 22:51:07 +02:00
6e0a38bb4a Rewrite the WebCrypto ECDH using wasm-bindgen (#980)
* Rewrite the WebCrypto ECDH

* Add comment about the unsafe
2019-04-10 18:52:31 -03:00
a266b1e724 Patch reading/writing frame lengths in libp2p-noise. (#1050)
* Patch reading/writing frame lengths in libp2p-noise.

Extracted from https://github.com/libp2p/rust-libp2p/pull/1027 since its
fate it still undetermined.

* Fix formatting.
2019-04-10 17:54:24 +02:00
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
98b2517403 Change Multiaddr representation to Bytes. (#1041)
* Change `Multiaddr` representation to `Bytes`.

* Mark several `Multiaddr` methods as deprecated.
2019-04-08 10:57:09 +02:00
480cf380d7 Add ExpandedSwarm (#1046) 2019-04-07 18:34:14 -03:00
b176032a07 Generalize TPeerId into TConnInfo (#1045)
* Generalize TPeerId into TConnInfo

* Final fixes
2019-04-05 13:37:12 -03:00
935825089d Add getters to RawSwarm (#1037) 2019-04-04 16:49:00 -03:00
1dcb3e5b1c Allow oneshot handler's inactivity_timeout to be configurable (#1039) 2019-04-04 16:28:18 -03:00
fac1ba12ec Remove ProtocolsHandlerUpgrErr::MuxerDeniedSubstream. (#1043)
Closes #1042.
2019-04-04 19:11:59 +02:00
1d4324ab70 Split the Swarm from the NetworkBehaviour (#1035) 2019-04-04 12:25:42 -03:00
8f77e9c45e Add missing zeroize() call for secp256k1::SecretKey::from_bytes. (#1040)
* Add missing zeroize() call for secp256k1.

* Add a test.
2019-04-03 10:31:09 +02:00
dfc425ea54 Also publish multistream-select 0.4 (#1034) v0.6.0 2019-03-29 14:05:40 -03:00
235ad98863 Publish v0.6.0 (#1031) 2019-03-29 11:41:42 -03:00
be4f8ca908 Add a Toggle NetworkBehaviour (#1024) 2019-03-29 10:17:11 -03:00
7549948945 Use bounded channels in transport (#987)
* Implement DialFuture

* Update with recommended changes to buffer size, `expect()` and `close()`
2019-03-28 22:34:53 +00:00
03ce6a6ed5 Add method to query external addresses (#1022) 2019-03-28 15:58:02 -03:00
ebbe197d9c Remove remnants of shutdown process (#1020) 2019-03-28 15:36:26 -03:00
d618b7b045 Add lighthouse to list of projects (#1026) 2019-03-28 17:40:29 +01:00
603c7be7c2 [Kademlia] Rehash PeerId before inserting in a KBucketsTable (#1025)
Add KadHash as the type to be used as key within KBuckets and replace PeerId.
2019-03-26 16:17:34 +01:00
538c3dffdf Improve Debug and Display for PeerId (#1019)
* Improve Debug and Display for PeerId

* Update core/src/peer_id.rs

Co-Authored-By: tomaka <pierre.krieger1708@gmail.com>
2019-03-23 10:08:07 +01:00
34db72a080 Split address reach error and node reach error (#1013)
* Split address reach error and node reach error

* Small comments about order of operatoins

* Minor doc change
2019-03-20 20:28:55 +01:00
3f05de6d7c Replace sha1 and tiny-keccak with RustCrypto crates (#1014)
* replace sha1 and tiny-keccak with RustCrypto crates

* Update misc/multihash/src/lib.rs

Co-Authored-By: newpavlov <newpavlov@gmail.com>
2019-03-20 19:19:50 +01:00
761c46ef19 Revert accidental change in Kademlia (#1018) 2019-03-20 18:55:09 +01:00
1e8a976af6 Add kbuckets_entries (#1016) 2019-03-20 18:36:01 +01:00
8de3cddfe8 Bugfix in Kademlia disconnected (#1017) 2019-03-20 17:52:35 +01:00
7b2980133d Simplify the Addresses (#1012)
* Simplify the Addresses

* Remove println
2019-03-20 17:30:00 +01:00
7be97b4f93 Rewrite the Kademlia k-buckets to be more explicit (#996)
* Some k-buckets improvements

* Apply suggestions from code review

Co-Authored-By: tomaka <pierre.krieger1708@gmail.com>

* Use NonZeroUsize for the distance

* Update TODO comment
2019-03-20 17:09:48 +01:00
96e559b503 Wrap multistream-select streams under a Negotiated (#1001) 2019-03-19 17:27:30 +01:00
63e9e39538 swarm: return references from external_addresses (#1008) 2019-03-19 15:23:58 +01:00
9575fa6c08 Documentation updates (#1005)
* Documentation updates:

  * libp2p: Update the top-level module documentation, already including
    intra-rustdoc links, removing outdated documentation, updating examples and
    polishing the text.

  * libp2p-core: Update the transport documentation to clarify that a `Transport`
    is really an abstraction only for connection-oriented transports.

* More links

* Fix typo.

* Address review comments.

* More doc tweaks.

  * Mention the necessity of creating an identity keypair.
  * Remove another mention of the removed Topology trait.
2019-03-19 12:45:57 +01:00
463e1a5837 examples: fix deprecated add_address (#1009) 2019-03-19 10:14:18 +01:00
fc535f532b Some Kademlia improvements (#994)
* Move QueryTarget to the behaviour

* Rework query system

* Add a few tests

* Add some Kademlia tests

* More tests

* Don't return self entry

* Fix tests
2019-03-18 18:20:57 +01:00
f4e7fed742 Remove unused test keys. (#1006) 2019-03-18 15:47:50 +01:00
bbe0bd3377 Fix warning in mplex (#1000) 2019-03-16 12:18:12 +01:00
1820bcb5ef Version 0.5.0 (#999) v0.5.0 2019-03-13 10:14:55 +01:00
1eb7dd8582 Add half-closed mplex substream support (#984) 2019-03-12 15:59:37 +01:00
8059a693a3 Cleaner shutdown process (#992)
* Cleaner shutdown process

* Finish

* Fix Yamux panic

* Remove irrelevant tests

* Update core/src/nodes/handled_node_tasks.rs

Co-Authored-By: tomaka <pierre.krieger1708@gmail.com>

* Fix yamux error handling

* Update yamux
2019-03-11 17:19:50 +01:00
cb93c822f1 Turn yamux's error! into debug! (#995) 2019-03-11 14:44:40 +01:00
2c66f82b11 Consolidate keypairs in core. (#972)
* Consolidate keypairs in core.

Introduce the concept of a node's identity keypair in libp2p-core,
instead of only the public key:

  * New module: libp2p_core::identity with submodules for the currently
    supported key types. An identity::Keypair and identity::PublicKey
    support the creation and verification of signatures. The public key
    supports encoding/decoding according to the libp2p specs.

  * The secio protocol is simplified as a result of moving code to libp2p-core.

  * The noise protocol is slightly simplified by consolidating ed25519
    keypairs in libp2p-core and using x25519-dalek for DH. Furthermore,
    Ed25519 to X25519 keypair conversion is now complete and tested.

Generalise over the DH keys in the noise protocol.

Generalise over the DH keys and thus DH parameter in handshake patterns
of the Noise protocol, such that it is easy to support other DH schemes
in the future, e.g. X448.

* Address new review comments.
2019-03-11 13:42:53 +01:00