28 Commits

Author SHA1 Message Date
Roman Borschel
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
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
Fedor Sakharov
463e1a5837 examples: fix deprecated add_address (#1009) 2019-03-19 10:14:18 +01:00
Roman Borschel
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
Roman Borschel
eeed66707b Address edition-2018 idioms. (#929) 2019-02-11 14:58:15 +01:00
Pierre Krieger
df923526ca
Embed the topology in the NetworkBehaviour (#889)
* Embed the topology in the NetworkBehaviour

* Put topologies inside of Floodsub and Kad

* Fix core tests

* Fix chat example

* More work

* Some cleanup

* Restore external addresses system
2019-01-26 23:57:53 +01:00
Pierre Krieger
b1f2ddd4b5
Floodsub now produces FloodsubEvent (#823) 2019-01-07 13:42:47 +01:00
Pierre Krieger
d10cafa804
Make deriving the NetworkBehaviour more ergonomic (#782) 2018-12-20 15:21:13 +01:00
Pierre Krieger
123cfcda02
Add helpers for easier Transports creation (#777)
* Add helpers for easier Transports creation

* Fix doctests
2018-12-14 10:41:54 +01:00
Pierre Krieger
40a503fd63
Store information about the local node in the topology (#772)
* Store information about the local node in the topology

* Fix build

* Store the external addresses in the topology
2018-12-13 19:06:13 +01:00
Pierre Krieger
d06eb67353
Add a mDNS network behaviour (#736)
* Move the MdnsService to a service module

* Add a Mdns behaviour

* Add a Mdns network behaviour

* Add minor documentation

* Add minor todo

* Use nat_traversal on the observed address

* Don't add self to topology

* Automatically connect to nodes we discover

* Add Debug implementations

* Fix example
2018-12-10 16:00:16 +01:00
Pierre Krieger
9102266d70
Rename all the network behaviours to more basic names (#726)
* Rename FloodsubBehaviour to Floodsub

* Rename Ping behaviours

* Rename identify
2018-12-05 17:04:25 +01:00
Pierre Krieger
10d76d64d0
Add a few more methods to Swarm and PollParameters (#721) 2018-12-04 13:54:04 +01:00
James Ray
3c614c23ac Add &message.source in println! as per … (#705)
* Add &message.source in println! as per https://github.com/libp2p/rust-libp2p/issues/702#issuecomment-442726078.

Co-authored-by: David <dvdplm@gmail.com>

* Update examples/chat.rs

Co-Authored-By: jamesray1 <16969914+jamesray1@users.noreply.github.com>
2018-11-30 09:55:59 +01:00
James Ray
fceaf2293b Chore/grammar (#701)
* Add a space.

* qed -> QED and ' ; qed' -> '; QED'

* ' ; QED' -> '; QED'
2018-11-29 16:38:52 +01:00
Pierre Krieger
3aa1fcbdc6
Add a KademliaHandler (#580)
* Rework Kademlia for the new design

* Minor work on protocol.rs

* More work

* Remove QueryTarget::FindValue

* Finish work on query

* Query timeout test

* Work on topology

* More work

* Update protocols/kad/src/topology.rs

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

* Fix trailing whitespaces

* Use if let
2018-11-29 12:11:35 +01:00
Pierre Krieger
1b05132d6a
Add libp2p-mdns (#590)
* Add libp2p-mdns

* Fix win32

* Make compatible with Rust 1.29

* Remove mDNS on esmcripten

* Fix concerns

* More concern

* Use append_u16

* Make decode_character_string return a Cow

* Add TODO

* Don't send queries from 5353

* Fix flags

* More flags fix

* More concerns

* Fix flags

* Fix removed env_logger
2018-11-24 13:55:18 +01:00
Toralf Wittner
826a290bf1
examples: Use logger in chat example. (#678) 2018-11-23 14:18:30 +01:00
David
080a75451f Floodsub chat example (#641)
* Add a floodsub example with the new Swarm

* WIP fixes for Floodsub chat-example code

* cleanup

* Address grumbles

* Update docs

* Update to newest master
2018-11-20 10:35:22 +01:00
Pierre Krieger
724d0f5d82
Remove the old API (#565)
* Remove the old API

* Fix integration test
2018-10-15 16:17:55 +01:00
Pierre Krieger
c032afbde5
Implement GET_PROVIDERS/ADD_PROVIDER Kademlia messages (#530)
* Implement GET_PROVIDERS/ADD_PROVIDER Kademlia messages

* Use multihash and peer id in protocol.rs

* Fix Kademlia example
2018-10-01 18:40:35 +02:00
Toralf Wittner
84b089cacc
Refactor multiaddr crate. (#498)
Refactor multiaddr crate.

- Remove `AddrComponent`. Instead `Protocol` directly contains its
associated data.

- Various smaller changes around conversions to Multiaddr from other
types, e.g. socket addresses.

- Expand tests to include property tests which test encoding/decoding
identity.
2018-09-20 19:51:00 +02:00
Pierre Krieger
1969bde4fe
Rework the Ping protocol (#497)
* Rework the Ping upgrade

* Fix concerns
2018-09-20 16:55:57 +02:00
Toralf Wittner
6a5681aed7
secio: Add NULL cipher and allow more configuration. (#468)
* Introduce NULL cipher and allow more configuration.

* Back to using the hash-code for handshake.

Using `Endpoint` would be incompatible with the existing protocol.

* Add comments.
2018-09-12 09:10:05 +02:00
Pierre Krieger
304e9c72c8
Report the entire peers after a result (#467) 2018-09-07 16:46:34 +02:00
Pierre Krieger
75ceba7809
The SwarmFuture is now a Stream (#442)
* The SwarmFuture is now a Stream

* Return the produced future in the message

* Remove IncomingConnection event

* Pass error when failing to dial

* Fix loop break mistake

* Fix concern

* Rename SwarmFuture to SwarmEvents

* Increase type length limit

* Remove todo
2018-09-04 14:53:27 +02:00
Pierre Krieger
f787c80a42 Merge the changes from polkadot-2 into master (#446) 2018-09-03 16:46:15 +02:00
Benjamin Kampmann
2ea49718f3
Clean up directory structure (#426)
* Remove unused circular-buffer crate
* Move transports into subdirectory
* Move misc into subdirectory
* Move stores into subdirectory
* Move multiplexers
* Move protocols
* Move libp2p top layer
* Fix Test: skip doctest if secio isn't enabled
2018-08-29 11:24:44 +02:00