1080 Commits

Author SHA1 Message Date
Volker Mische
b00197a0fd Use upstream version of multihash instead of a fork
The changes from the libp2p fork have been backported to upstream, hence
upstream can now be used instead.
2020-03-02 17:40:40 +01:00
Pierre Krieger
7cbb3cf8f3
Add Mdns::discovered_nodes (#1480) 2020-03-02 17:11:28 +01:00
Toralf Wittner
d8bb9990c0
Require latest yamux version. (#1479) 2020-02-28 13:30:59 +01:00
Pierre Krieger
2c40f2880e
Publish 0.16.2 (#1476) v0.16.2 2020-02-28 10:54:52 +01:00
Toralf Wittner
96cc7912a3
Keep polling connection when closing. (#1474)
The API contract of Yamux is that the connection has to be polled
until `None` or some `Err(_)` is returned. Therefore while closing
we need to keep polling the connection. Only polling the control
channel will not have an effect but `close` will always return
`Poll::Pending` as the connection does not make progress.
2020-02-27 16:04:03 +01:00
Demi Obenour
62ea7c165b
Upgrade crypto libs (#1470) 2020-02-26 13:23:52 +01:00
Toralf Wittner
2ea459dcdc
kad: Export QueryId and add Kademlia::protocol_name. (#1469)
The `QueryId` type should be exported as it is used in the
`NetworkBehaviour::ProtocolsHandler` type of `Kademlia`.

`Kademlia::protocol_name` is added for convenience.
2020-02-25 11:59:38 +01:00
vms
688aa5bc79
Move mdns (#1458)
* move mdns

* alphabetic ordering in Cargo.toml

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-24 19:36:55 +01:00
Mazdak Farrokhzad
4496337f93
Onion3Addr::acquire: fix bug due to differing lifetimes (#1468)
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-24 18:42:43 +01:00
Guillaume GONI
4472840acf
NetworkBehaviour derive fix IntoProtocolsHandler/ProtocolsHandler::select ambiguity (#1466)
* NetworkBehaviour derive fix IntoProtocolsHandler/ProtocolsHandler::select ambiguity

* Missing space misc/core-derive/src/lib.rs

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

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-24 16:56:36 +01:00
Ashley
e84cbf278a
Add a js implementation of wasm-ext. (#1454)
* Squashed commit of the following:

commit 8d11f27165aecb6275c6a435e36d4fc38193b601
Author: Ashley Ruglys <ashley.ruglys@gmail.com>
Date:   Thu Feb 13 16:27:26 2020 +0100

    Fix implementation

commit 8f60187bcc3b57069eb8bd7ac530d9da3da4176e
Author: Ashley Ruglys <ashley.ruglys@gmail.com>
Date:   Thu Feb 13 12:38:35 2020 +0100

    Add implementation

commit 445fadea709c930b83b4f7905c030bb29c776eed
Author: Ashley Ruglys <ashley.ruglys@gmail.com>
Date:   Wed Feb 12 16:45:31 2020 +0100

    Use different features on different targets

commit e5d47c19fc06b96bad16f433a1526ecf4d9ce99b
Author: Ashley Ruglys <ashley.ruglys@gmail.com>
Date:   Mon Feb 10 13:23:50 2020 +0100

    Use ring on native

commit 8def133f8230885535765f8e244162cdb8901a34
Author: Ashley Ruglys <ashley.ruglys@gmail.com>
Date:   Fri Feb 7 14:46:52 2020 +0100

    Use the sha2 crate for sha512 hashing

commit 268880d2ed6510a0339d70184d7ad88f3efb39c4
Author: Ashley <ashley.ruglys@gmail.com>
Date:   Fri Feb 7 01:25:29 2020 +0100

    Fix documentation

commit 9769bc5242972c2c74e9b5e36960ca2513ddbb33
Author: Ashley <ashley.ruglys@gmail.com>
Date:   Fri Feb 7 01:17:20 2020 +0100

    Switch snow resolver to default

commit ac22537385ff81b274aec14a8c6f47a0b59606ce
Author: Ashley <ashley.ruglys@gmail.com>
Date:   Thu Feb 6 20:34:50 2020 +0100

    hmm...

* Feature gate

* Rename -> websocket_transport

* Update transports/wasm-ext/Cargo.toml

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

* Update transports/wasm-ext/src/lib.rs

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

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-19 15:10:07 +01:00
Pierre Krieger
bfc1934dc0
Remove change that didn't make it (#1461) 2020-02-18 18:46:13 +01:00
Pierre Krieger
fa4cd50476
Publish 0.16.1 (#1459) v0.16.1 2020-02-18 14:05:22 +01:00
Rüdiger Klaehn
145200fa4f
Implement FusedStream for Swarm (#1433)
* Implement FusedStream for Swarm

The stream for swarm will never terminate, and therefore does not have to
keep track of termination.

* Get rid of the wall of complex type constraints

...as they don't seem to be necessary anymore for latest master
2020-02-18 10:33:01 +01:00
Roman Borschel
b6a93b3c5e
Small libp2p-kad tweaks. (#1457)
* Replace some remaining `AsRef` constraints for DHT keys with `Borrow`.
  * Add a bit of debug/trace logging.
  * Tiny refactoring and a debug assertion for the `bucket` module.
2020-02-17 14:52:11 +01:00
Toralf Wittner
57cab3b7ce
secio: Use UnexpectedEof instead of BrokenPipe. (#1456)
Secio's handshake reports unexpected EOF errors in two places.
Presumably because `std::io::ErrorKind::UnexpectedEof` did not exist
when secio was first implemented, `ErrorKind::BrokenPipe` is used
for this error. Since we nowadays have `UnexpectedEof` at our disposal,
secio should use this more appropriate error kind.
2020-02-14 14:46:13 +01:00
Pierre Krieger
be31f66031
Revert bumping multistream-select and bump multihash (#1455)
* Revert bumping multistream-select

* Also bump multihash
v0.16.0
2020-02-14 13:33:28 +01:00
Pierre Krieger
ace8123cf2
Publish 0.16.0 (#1453)
* Publish 0.16.0

* Apply suggestions from code review

Co-Authored-By: Toralf Wittner <tw@dtex.org>

Co-authored-by: Toralf Wittner <tw@dtex.org>
2020-02-14 11:33:52 +01:00
Toralf Wittner
70d634daff
Grow noise buffers dynamically. (#1436)
* Grow noise buffers dynamically.

Currently we allocate a buffer of 176 KiB for each noise state, i.e.
each connection. For connections which see only small data frames
this is wasteful. At the same time we limit the max. write buffer size
to 16 KiB to keep the total buffer size relatively small, which
results in smaller encrypted messages and also makes it less likely to
ever encounter the max. noise package size of 64 KiB in practice when
communicating with other nodes using the same implementation.

This PR repaces the static buffer allocation with a dynamic one. We
only reserve a small space for the authentication tag plus some extra
reserve and are able to buffer larger data frames before encrypting.

* Grow write buffer from offset.

As suggested by @mxinden, this prevents increasing the write buffer up
to MAX_WRITE_BUF_LEN.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-13 12:38:33 +01:00
Pierre Krieger
bbed28b3ec
Make errors on listener non-fatal (#1427)
* Make errors on listener non-fatal

* Fix bad rename

* Some changes to trait bounds

* Fix noise tests

* Apply suggestions from code review

Co-Authored-By: Toralf Wittner <tw@dtex.org>

* Add reason for closure

* Fix intra-doc link

Co-authored-by: Toralf Wittner <tw@dtex.org>
2020-02-13 12:05:45 +01:00
vms
e2ddab223d
add poll parameters to custom poll function (#1442)
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-13 11:17:55 +01:00
Toralf Wittner
cdb733b479
yamux: Re-export WindowUpdateMode. (#1443)
Also implement `Deref` and `DerefMut` on `Config` to allow transparent
configuration of `yamux::Config`.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-13 10:57:29 +01:00
Roman Borschel
b872bd9030
Temporary canonical multihash in peer ID. (#1449)
* Temporary canonical multihash in peer ID.

* Reduce code duplication.

* Remove unnecessary impls.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-13 10:36:14 +01:00
Ashley
8238fd2100
Switch noise from the RingResolver to the DefaultResolver (#1439)
* hmm...

* Switch snow resolver to default

* Fix documentation

* Use the sha2 crate for sha512 hashing

* Use ring on native

* Use different features on different targets

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-12 21:44:50 +01:00
Toralf Wittner
afb1c877a3
multiaddr: Fix generation of arbitrary onion addr. (#1451)
Exclude port 0 which is not a valid port number for onion addresses.
2020-02-12 20:27:17 +01:00
Pierre Krieger
e855cd5915
Use SHA256 again for from_public_key (#1444) 2020-02-12 15:28:40 +01:00
Pierre Krieger
955352bfd2
Extract rw-stream-sink to its own repo (#1448) 2020-02-12 13:23:08 +01:00
Pierre Krieger
627e93ba17
Propagate rustdoc links check to GH actions (#1446)
* Propagate rustdoc links check to GH actions

* Fix WASM test

* Try fix WASM test again

* Try run tests on a real machine
2020-02-11 16:28:29 +01:00
Pierre Krieger
cbb3315822
Try to use GitHub actions (#1430) 2020-02-11 15:09:45 +01:00
Rüdiger Klaehn
d55871623c
Ipfs private swarms interop example (#1420)
* Add gossipsub and ping

* Implement swarm key parsing from environment

* WIP remove stuff

* WIP remove more stuff

* Use gossipsub instead of floodsub

* Make ipfs example work with or without swarm key

* Add support for /ipfs/Qm1234 multiaddrs

* Add documentation for ipfs example

* Rename example to ipfs-private

* Fix comments

* Move EitherTransport into either.rs

And prettify imports of ipfs-private example

* Sanitize multiaddr before parsing

...and remove the "ipfs" protocol from multiaddr

* Remove TSubstream type parameter

...so that it works with current master

* PR feedback

use source instead of cause
2020-02-10 18:35:51 +01:00
Pierre Krieger
fc4dec581e
Check documentation intra-link (#1432)
* Fix broken links in rustdoc

This fixes all of the rustdoc warnings on nightly.

* Check documentation intra-link

* Fix config

* Fix bad indent

* Make nightly explicit

* More links fixes

* Fix link broken after master merge

Co-authored-by: Demi Obenour <48690212+DemiMarie-parity@users.noreply.github.com>
2020-02-10 15:17:07 +01:00
Pierre Krieger
1eff4b9823
Simplify trait bounds on NetworkBehaviour (#1405)
* Simplify trait bounds requirements

* More work

* Moar

* Finish

* Fix final tests

* More simplification

* Use separate traits for Inbound/Outbound

* Update gossipsub and remove warnings

* Add documentation to swarm

* Remove BoxSubstream

* Fix tests not compiling

* Fix stack overflow

* Address concerns

* For some reason my IDE ignored libp2p-kad
2020-02-07 16:29:30 +01:00
Akihito Nakano
69852a580b
Add dnsaddr (#1356)
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-06 13:54:50 +01:00
Shotaro Yamada
b200728443
Fix copy-paste error in doc string (#1428)
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-06 11:17:05 +01:00
Rüdiger Klaehn
39794b333f
Provides a debug instance for an RSA public key... (#1421)
* Provides a debug instance for an RSA public key...

that is a bit easier on the eyes than the raw Vec<u8>

* Move to_hex into the fmt method

PR feedback

* Remove to_hex altogether
2020-02-05 19:50:13 +01:00
Shotaro Yamada
f2d7091376
Remove unused dependencies (#1429)
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-05 17:04:04 +01:00
Max Inden
2b7c015aa5
protocols/gossipsub: Do not close connection when inbound fails (#1424)
Instead of closing the connection on an error on the inbound substream
(both on `poll_next` as well as `poll_close`), one can set it to None
and depend on the remote to open an new one in case they have more data
to send.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-05 15:31:50 +01:00
Ashley
c73a175963
Switch to futures-timer 3.0 (#1426) 2020-02-05 12:12:18 +01:00
Pierre Krieger
7c04f7e468
Bump multihash to 0.2.2 (#1425) 2020-02-04 15:18:20 +01:00
Stan Bondi
955b60796a
Added Onion3 support to multiaddr (#1354) 2020-02-04 13:40:57 +01:00
Piotr Gołąb
57fd677686
Update gossipsub-chat example docstring (#1419)
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-04 11:45:06 +01:00
Qinxuan Chen
013b72791a
Add Blake2b256 and Blake2s128 (#1386)
Signed-off-by: koushiro <koushiro.cqx@gmail.com>

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-04 11:17:09 +01:00
Rüdiger Klaehn
dd0c5c37f6
Allow multiple pings over one connection (#1416)
* Allow multiple pings over one connection

This is so that pinging a rust-libp2p node from ipfs works even without passing -n 1

* Remove timeout
2020-02-04 10:28:00 +01:00
Toralf Wittner
44b5e3e176
Bump yamux version 0.4.1 (#1415) 2020-01-31 10:27:20 +01:00
Pierre Krieger
b964cacfa4
Finish PeerId inlining change (#1413)
* Add peer id inlining for small public keys

* Apply @twittner suggestions

* Make PeerId compare equal accross hashes

* Fix mDNS

* Remove useless functions

* Add property test

Co-authored-by: Age Manning <Age@AgeManning.com>
2020-01-29 11:33:19 +01:00
Rüdiger Klaehn
f5e7461cec Implement private networks (#1385)
* Add pnet protocol

copied from plaintext protocol, since that seems to be the closest match

* Minimalize the pnet protocol

* WIP private swarms with fixed key

* Different nonces for write and read

* Use per stream write buffer to avoid allocations

* Add parsing and formating of PSKs

* Directly call handshake

Also remove unneeded InboundUpgrade and OutboundUpgrade

* Add HandshakeError

* Add dedicated pnet example

* Add tests for PSK parsing and formatting

* Some more tests for the parsing, fail case

* Add fingerprint

To be able to check if a go-ipfs and rust-libp2p use the same key without
having to dump the actual key. Not sure if there is a spec for this anywhere,
but it is basically just copied from go-ipfs.

* Minimize dependencies and remove dead code

* Rename PSK to PreSharedKey and use pin_project

* Add crypt_writer

Basically a stripped down and modified version of async_std BufWriter that
also encrypts using the given cipher.

* cargo fmt

* Actually get rid of the Unpin requirement

* Rewrite flushing and remove written count from state

* Add docs for pnet/lib.rs

* Increase library version

* Remove pnet example

There will be a more elaborate and useful example in a different PR

* Return pending on pending...

also make doc text less ambiguous

* Add debug assertions to check invariants of poll_flush_buf

Also, clarify the invariants in the comments of that method
2020-01-28 13:22:09 +01:00
Pierre Krieger
4bf42d188f
Remove all mod.rs files (#1400) 2020-01-28 08:51:06 +01:00
Rüdiger Klaehn
3b50cbd1b8 Addressing #473 ... if I understood the ticket right, we want to pass… (#1395)
* Addressing #473 ... if I understood the ticket right, we want to pass through whatever the application provides as a topic identifier, leaving hashing (or not hashing) up to the application.

* Remove TopicDescriptor and use Topic newtype everywhere

* PR feedback

Use From<Topic> instead of Into<String>
Use impl Into<Topic> instead of Topic in public API

Co-authored-by: Peat Bakke <peat@peat.org>
2020-01-27 15:23:01 +01:00
Pierre Krieger
2ef7c40cda
Add metadata to gossipsub (#1409) v0.15.0 2020-01-24 17:57:54 +01:00
Pierre Krieger
f1f40956d6
Publish 0.15.0 (#1408)
* Publish 0.15.0

* Oops, script too efficient
2020-01-24 17:14:56 +01:00