1345 Commits

Author SHA1 Message Date
Pierre Krieger
26ec67b0a9
Make the kademlia test ignore failures 2019-12-09 16:50:08 +01:00
Toralf Wittner
481849e4f1
secio: Back to 4-byte BE length prefix. (#1337)
The secio spec states that each frame must be prefix with a 32-bit big
endian length prefix so we can not use an unsigned varint here.
2019-12-09 16:34:13 +01:00
Roman S. Borschel
3de85ba4e2 Fix possible incorrect return value from LengthDelimitedReader::write().
Due to not taking into account buf.len() when computing `written`,
it may be incorrectly less than buf.len().
2019-12-09 15:50:35 +01:00
Pierre Krieger
b6d5d97261
Merge pull request #1336 from tomaka/fix-stable-fut-tests
Fix the regular tests for stable-futures
2019-12-09 12:06:15 +01:00
Pierre Krieger
73e745ec2b
Fix the regular tests for stable-futures 2019-12-09 11:41:31 +01:00
Pierre Krieger
ea58aed37e
Merge pull request #1335 from twittner/tests
Fix remaining tests.
2019-12-09 11:37:37 +01:00
Toralf Wittner
173fc04b30 Fix tests. 2019-12-07 15:11:46 +01:00
Toralf Wittner
9cefb52b1f
Update to current soketto develop. (#1332) 2019-12-06 15:54:15 +01:00
Pierre Krieger
fb997f24da
Merge pull request #1327 from tomaka/merge-master-for-real
Merge master for real
2019-11-29 17:54:21 +01:00
Pierre Krieger
a6bef386bf
Merge remote-tracking branch 'upstream/master' into HEAD 2019-11-29 13:46:48 +01:00
Pierre Krieger
aa4c2898cb
Fix identify not compiling for wasm (#1326) 2019-11-29 13:42:46 +01:00
Pierre Krieger
98dac8d509
Merge master into stable-futures (#1325)
* Update parking_lot to v0.9 (#1300)

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Publish 0.13.1 (#1304)

* Publish 0.13.1

* Update CHANGELOG.md

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

* Update some deps of core-derive (#1299)

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2019-11-28 18:03:59 +01:00
Max Inden
26f58d20a8
protocols/kad: Fix tests + minor fix in mdns and noise (#1320)
* misc/mdns: Fix missleading error message

* protocols/noise: Remove unneeded tokio-io import

* protocols/kad: Update tests to use stable futures
2019-11-28 16:12:02 +01:00
Toralf Wittner
8d22e98abc
Add support for PINGs and PONGs to websockets. (#1319)
* Add support for PINGs and PONGs to websockets.

`Connection` (formerly `BytesConnection`) now supports more structured
`IncomingData` and `OutgoingData` which mirror the data types in
soketto (which are not exposed). This allows adding `Connection::ping`
and `Connection::pong` methods.

The non-framed websocket transport defines `BytesConnection` as a
wrapper around `Connection` and handles only binary data.
2019-11-26 17:37:45 +01:00
Pierre Krieger
8be45f5318 Fix the identify tests (#1324)
* Fix identify tests

* Some clean-up
2019-11-26 14:47:49 +01:00
Pierre Krieger
e5b087d01f
Fix the WASM build with stable futures (#1322)
* Fix the WASM build with stable futures

* Fix duplicate dependencies error
2019-11-26 11:48:47 +01:00
Pierre Krieger
e083e82212 Fix tests of libp2p-ping (#1321) 2019-11-25 17:33:59 +01:00
Toralf Wittner
b7644722ee
Fix examples and update core-derive. (#1317) 2019-11-25 10:45:04 +01:00
Toralf Wittner
df71d4a861
Update root crate to use futures-0.3. (#1315)
Mostly mechanical. Creating a `CommonTransport` yields an
`io::Result<_>` now since creating the `DnsConfig` may fail with an
`io::Error` when creating the `ThreadPool`.

The `DnsConfig` `Transport` impl had to be changed slightly:

(a) PR [[1311]] requires some `Send` bounds.
(b) The async block had to be changed to work around lifetime inference
issues which resulted in an "one type is more general than the other"
error.

[1311]: https://github.com/libp2p/rust-libp2p/pull/1311
2019-11-22 14:30:21 +01:00
Toralf Wittner
1597b026cb
Use soketto's reader-writer-split branch. (#1311) 2019-11-22 14:29:52 +01:00
Pierre Krieger
7cd44ae3de
Fix mplex tests (#1314) 2019-11-21 16:14:27 +01:00
Toralf Wittner
812889102c
Update mdns dependencies to use futures-0.3 (#1313) 2019-11-20 18:26:21 +01:00
Max Inden
a26620bf39 misc/mdns: Update to futures-preview (#1247)
* misc/mdns/service: Use async std with stack pinned futures

* misc/mdns: Define mdns broadcast address as lazy static

* misc/mdns: Drop future before borrowing their arguments again

* misc/mdns: Send queries on query socket, not socket

* misc/mdns: Use poll_next_unpin on query interval stream

* misc/mdns: Ensure underlying task is woken up on next interval tick

* misc/mdns: Wrap match expression in scope to drop future early

* misc/mdns: Adjust 'discovery_ourselves' test

* misc/mdns: Make query interval fire instantly on first tick

This is an optimization only important for short lived use cases, e.g.
unit tests. Instead of waiting for 20 seconds at first, the query
interval fires right away and thereby the service makes progress
instantly.

* misc/mdns: Adjust MdnsService documentation tests

* misc/mdns: Do not drop UDP socket send and reicv futures

Libp2p-mdns uses the async-std crate for network io. This crate only
offers async send and receive functions. In order to use this in non
async/await functions one needs to keep the future returned by the crate
functions around across `poll` invocations.

The future returned by the crate functions references the io resource.
Thus one has to keep both the io resource as well as the future
referencing it. This results in a self-referencing struct which is not
possible to create with safe Rust.

Instead, by having `MdnsService::next` (former `MdnsService::poll`) take
ownership of `self`, the Rust async magic takes care of the above (See
code comments for more details).

As a (negative) side effect, given that `MdnsService::next` takes
ownership of `self`, there is nothing to bind the lifetime of the
returned `MdnsPacket` to. With no better solution in mind, this patch
makes `MdnsPacket` static, not referencing the `MdnsService` receive
buffer.

* misc/mdns: Fix code comments and remove *if Free* TODO

* misc/mdns: Minor refactorings

* misc/mdns: Build responses in behaviour.rs directly

* misc/mdns: Move response ttl duration to constant

* misc/mdns: Remove optimization todo comment

* misc/mdns: Add query interval test

* misc/mdns: Move packet parsing into MdnPacket impl

* misc/mdns: Don't have receiving packets starve the query interval

When we 'await' on receiving a packet on the udp socket without
receiving a single packet we starve the remaining logic of the mdns
service, in this case the logic triggered on the receive interval.

* misc/mdns: Add debug_assert to MaybeBusyMdnsService check

* misc/mdns: Implement Debug for MaybeBusyMdnsService

* misc/mdns: Make ownership note a normal comment, not a doc comment

* misc/mdns: Have discovered_peers return an iterator
2019-11-20 13:25:12 +01:00
Qinxuan Chen
88c2287e44 Update some deps of core-derive (#1299)
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2019-11-19 17:25:58 +01:00
Toralf Wittner
02c5f34fc0
Update more crates to futures-0.3 (#1312) 2019-11-19 11:18:16 +01:00
Max Inden
be73b90345 protocols/plaintext: Move to stable futures and use unsigned varints (#1306)
* protocols/plaintext: Move to stable futures and use unsigned varints

The plaintext 2.0 specification requires to use unsigned varints for
frame length delimiting instead of fixed 4 byte integer frame length
delimiting. This commit aligns the implementation with the
specification.

* protocols/secio: Fix doc comment BytesMut -> Vec<u8>

* protocols/plaintext: Add quick check smoke test

* protocols/plaintext: Rework imports and log levels

* protocols/plaintext: Use BytesMut instead of Vec<u8>

* protocols/plaintext: Use BoxFuture
2019-11-19 11:15:35 +01:00
Pierre Krieger
3dd07fcc3a
Update libp2p-uds to futures 0.3 (#1308)
* Update libp2p-uds to futures 0.3

* Some clean-up
2019-11-18 12:06:26 +01:00
Toralf Wittner
3e89c36d16
yamux: Use futures-0.3. (#1307) 2019-11-15 16:58:45 +01:00
Toralf Wittner
2015053756
Update yamux to development version. (#1297)
Update yamux to development version.

For the boxed `futures::stream::Stream` we have to decide if we require
a `Send` bound or not. Since some upgrades may produce outputs which are
`!Send` we offer both upgrade versions.
2019-11-15 12:49:52 +01:00
Toralf Wittner
f85241dd36 Update core, tcp, secio and mplex to futures-0.3. (#1302)
* Update `rw-stream-sink` to futures-0.3.

* Update core, tcp, secio and mplex to futures-0.3.

On top of https://github.com/libp2p/rust-libp2p/pull/1301
2019-11-14 13:42:14 +01:00
Pierre Krieger
9e36ef41ac
Publish 0.13.1 (#1304)
* Publish 0.13.1

* Update CHANGELOG.md

Co-Authored-By: Toralf Wittner <tw@dtex.org>
v0.13.1
2019-11-13 14:48:15 +01:00
Qinxuan Chen
fa7c5c4d47 Update parking_lot to v0.9 (#1300)
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2019-11-12 13:28:44 +01:00
Toralf Wittner
cb74580e35
websocket: Replace futures-rustls with async-tls. (#1298) 2019-11-08 10:46:34 +01:00
Pierre Krieger
c1226b203a
Cherry-pick commits from master to stable-futures (#1296)
* Implement Debug for (ed25519|secp256k1)::(Keypair|SecretKey) (#1285)

* Fix possible arithmetic overflow in libp2p-kad. (#1291)

When the number of active queries exceeds the (internal)
JOBS_MAX_QUERIES limit, which is only supposed to bound
the number of concurrent queries relating to background
jobs, an arithmetic overflow occurs. This is fixed by
using saturating subtraction.

* protocols/plaintext: Add example on how to upgrade with PlainTextConfig1 (#1286)

* [mdns] - Support for long mDNS names (Bug #1232) (#1287)

* Dead code -- commenting out with a note referencing future implementation

* Adding "std" feature so that cargo can build in other directories (notably `misc/mdns`, so that I could run these tests)

* Permitting `PeerID` to be built from an `Identity` multihash

* The length limit for DNS labels is 63 characters, as per RFC1035

* Allocates the vector with capacity for the service name plus additional QNAME encoding bytes

* Added support for encoding/decoding peer IDs with an encoded length greater than 63 characters

* Removing "std" from ring features

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

* Retaining MAX_INLINE_KEY_LENGTH with comment about future usage

* `segment_peer_id` consumes `peer_id` ... plus an early return for IDs that don't need to be segmented

* Fixing logic

* Bump most dependencies (#1268)

* Bump most dependencies

This actually builds 😊.

* Bump all dependencies

Includes the excellent work of @rschulman in #1265.

* Remove use of ed25519-dalek fork

* Monomorphize more dependencies

* Add compatibility hack for rand

Cargo allows a crate to depend on multiple versions of another, but
`cargo-web` panics in that situation.  Use a wrapper crate to work
around the panic.

* Use @tomaka’s idea for using a newer `rand`

instead of my own ugly hack.

* Switch to Parity master

as its dependency-bumping PR has been merged.

* Update some depenendencies again

* Remove unwraps and `#[allow(deprecated)]`.

* Remove spurious changes to dependencies

Bumping minor or patch versions is not needed, and increases likelyhood
of merge conflicts.

* Remove some redundant Cargo.toml changes

* Replace a retry loop with an expect

`ed25519::SecretKey::from_bytes` will never fail for 32-byte inputs.

* Revert changes that don’t belong in this PR

* Remove using void to bypass ICE (#1295)

* Publish 0.13.0 (#1294)
2019-11-06 16:09:15 +01:00
Pierre Krieger
b3b9081f85
Publish 0.13.0 (#1294) v0.13.0 2019-11-06 09:37:22 +01:00
Pierre Krieger
96699a472a
Remove using void to bypass ICE (#1295) 2019-11-06 09:19:49 +01:00
Toralf Wittner
7eb4165d44 Use unsigned-varint and futures_codec from crates.io. (#1293) 2019-11-05 09:08:08 +01:00
Max Inden
5f17b11f8e protocols/noise: Adapt to breaking changes in noise 0.16 (#1292) 2019-11-01 17:34:50 +01:00
Max Inden
8944899fe0 *: Remove usage of custom buffer initialization usage (#1263)
* *: Remove usage of custom buffer initialization usage

With version `0.3.0-alpha.19` the futures-preview crate makes the
`AsyncRead::initializer` API unstable.

In order to improve interoperability with e.g. both a library depending
on alpha.18 as well as a library depending on alpha.19 and in order for
rust-libp2p to become stable again, this commit removes all usages of
the unstable `initializer` API.

* protocols/noise: Remove NoiseOutput Asyncread initializer

* transports/tcp: Remove TcpTransStream AsyncRead initializer

* *: Remove version pinning of futures-preview to 0.3.0-alpha.18

With version 0.3.0-alpha.19 the futures-preview crate makes the
AsyncRead::initializer API unstable. Given that the previous commits
removed usage of the initializer API, the version pinning is not needed
any longer.
2019-11-01 16:53:11 +01:00
Demi Obenour
979c82040e Bump most dependencies (#1268)
* Bump most dependencies

This actually builds 😊.

* Bump all dependencies

Includes the excellent work of @rschulman in #1265.

* Remove use of ed25519-dalek fork

* Monomorphize more dependencies

* Add compatibility hack for rand

Cargo allows a crate to depend on multiple versions of another, but
`cargo-web` panics in that situation.  Use a wrapper crate to work
around the panic.

* Use @tomaka’s idea for using a newer `rand`

instead of my own ugly hack.

* Switch to Parity master

as its dependency-bumping PR has been merged.

* Update some depenendencies again

* Remove unwraps and `#[allow(deprecated)]`.

* Remove spurious changes to dependencies

Bumping minor or patch versions is not needed, and increases likelyhood
of merge conflicts.

* Remove some redundant Cargo.toml changes

* Replace a retry loop with an expect

`ed25519::SecretKey::from_bytes` will never fail for 32-byte inputs.

* Revert changes that don’t belong in this PR
2019-10-31 18:30:17 +01:00
Peat Bakke
eb7b7bd919 [mdns] - Support for long mDNS names (Bug #1232) (#1287)
* Dead code -- commenting out with a note referencing future implementation

* Adding "std" feature so that cargo can build in other directories (notably `misc/mdns`, so that I could run these tests)

* Permitting `PeerID` to be built from an `Identity` multihash

* The length limit for DNS labels is 63 characters, as per RFC1035

* Allocates the vector with capacity for the service name plus additional QNAME encoding bytes

* Added support for encoding/decoding peer IDs with an encoded length greater than 63 characters

* Removing "std" from ring features

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

* Retaining MAX_INLINE_KEY_LENGTH with comment about future usage

* `segment_peer_id` consumes `peer_id` ... plus an early return for IDs that don't need to be segmented

* Fixing logic
2019-10-31 10:54:41 +01:00
Max Inden
c29ec854b4 protocols/plaintext: Add example on how to upgrade with PlainTextConfig1 (#1286) 2019-10-28 18:32:29 +01:00
Roman Borschel
3f2dd0110b
Fix possible arithmetic overflow in libp2p-kad. (#1291)
When the number of active queries exceeds the (internal)
JOBS_MAX_QUERIES limit, which is only supposed to bound
the number of concurrent queries relating to background
jobs, an arithmetic overflow occurs. This is fixed by
using saturating subtraction.
2019-10-28 18:05:03 +01:00
Pierre Krieger
0eeddac86f
Update the stable-futures branch to master (#1288)
* Configurable multistream-select protocol. Add V1Lazy variant. (#1245)

Make the multistream-select protocol (version) configurable
on transport upgrades as well as for individual substreams.

Add a "lazy" variant of multistream-select 1.0 that delays
sending of negotiation protocol frames as much as possible
but is only safe to use under additional assumptions that
go beyond what is required by the multistream-select v1
specification.

* Improve the code readability of the chat example (#1253)

* Add bridged chats (#1252)

* Try fix CI (#1261)

* Print Rust version on CI

* Don't print where not appropriate

* Change caching strategy

* Remove win32 build

* Remove win32 from list

* Update libsecp256k1 dep to 0.3.0 (#1258)

* Update libsecp256k1 dep to 0.3.0

* Sign now cannot fail

* Upgrade url and percent-encoding deps to 2.1.0 (#1267)

* Upgrade percent-encoding dep to 2.1.0

* Upgrade url dep to 2.1.0

* Revert CIPHERS set to null (#1273)

* Update dependency versions (#1265)

* Update versions of many dependencies

* Bump version of rand

* Updates for changed APIs in rand, ring, and webpki

* Replace references to `snow::Session`

`Session` no longer exists in `snow` but the replacement is two structs `HandshakeState` and `TransportState`
Something will have to be done to harmonize `NoiseOutput.session`

* Add precise type for UnparsedPublicKey

* Update data structures/functions to match new snow's API

* Delete diff.diff

Remove accidentally committed diff file

* Remove commented lines in identity/rsa.rs

* Bump libsecp256k1 to 0.3.1

* Implement /plaintext/2.0.0 (#1236)

* WIP

* plaintext/2.0.0

* Refactor protobuf related issues to compatible with the spec

* Rename: new PlainTextConfig -> PlainText2Config

* Keep plaintext/1.0.0 as PlainText1Config

* Config contains pubkey

* Rename: proposition -> exchange

* Add PeerId to Exchange

* Check the validity of the remote's `Exchange`

* Tweak

* Delete unused import

* Add debug log

* Delete unused field: public_key_encoded

* Delete unused field: local

* Delete unused field: exchange_bytes

* The inner instance should not be public

* identity::Publickey::Rsa is not available on wasm

* Delete PeerId from Config as it should be generated from the pubkey

* Catch up for #1240

* Tweak

* Update protocols/plaintext/src/error.rs

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

* Update protocols/plaintext/src/handshake.rs

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

* Update protocols/plaintext/src/error.rs

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

* Update protocols/plaintext/src/error.rs

Co-Authored-By: Roman Borschel <romanb@users.noreply.github.com>

* Update protocols/plaintext/src/error.rs

Co-Authored-By: Roman Borschel <romanb@users.noreply.github.com>

* Rename: pubkey -> local_public_key

* Delete unused error

* Rename: PeerIdValidationFailed -> InvalidPeerId

* Fix: HandShake -> Handshake

* Use bytes insteadof Publickey to avoid code duplication

* Replace with ProtobufError

* Merge HandshakeContext<()> into HandshakeContext<Local>

* Improve the peer ID validation to simplify the handshake

* Propagate Remote to allow extracting the PeerId from the Remote

* Collapse the same kind of errors into the variant

* [noise]: `sodiumoxide 0.2.5` (#1276)

Fixes https://github.com/RustSec/advisory-db/pull/192

* examples/ipfs-kad.rs: Remove outdated reference to `without_init` (#1280)

* CircleCI Test Fix (#1282)

* Disabling "Docker Layer Caching" because it breaks one of the circleci checks

* Bump to trigger CircleCI build

* unbump

* zeroize: Upgrade to v1.0 (#1284)

v1.0 final release is out. Release notes:

https://github.com/iqlusioninc/crates/pull/279

* *: Consolidate protobuf scripts and update to rust-protobuf 2.8.1 (#1275)

* *: Consolidate protobuf generation scripts

* *: Update to rust-protobuf 2.8.1

* *: Mark protobuf generated modules with '_proto'

* examples: Add distributed key value store (#1281)

* examples: Add distributed key value store

This commit adds a basic distributed key value store supporting GET and
PUT commands using Kademlia and mDNS.

* examples/distributed-key-value-store: Fix typo

* Simple Warning Cleanup (#1278)

* Cleaning up warnings - removing unused `use`

* Cleaning up warnings - unused tuple value

* Cleaning up warnings - removing dead code

* Cleaning up warnings - fixing deprecated name

* Cleaning up warnings - removing dead code

* Revert "Cleaning up warnings - removing dead code"

This reverts commit f18a765e4bf240b0ed9294ec3ae5dab5c186b801.

* Enable the std feature of ring (#1289)
2019-10-28 18:04:01 +01:00
Caio
54ee836409 Implement Debug for (ed25519|secp256k1)::(Keypair|SecretKey) (#1285) 2019-10-28 13:46:08 +01:00
Pierre Krieger
9e314a123b
Enable the std feature of ring (#1289) 2019-10-28 13:10:01 +01:00
Peat Bakke
732becd419 Simple Warning Cleanup (#1278)
* Cleaning up warnings - removing unused `use`

* Cleaning up warnings - unused tuple value

* Cleaning up warnings - removing dead code

* Cleaning up warnings - fixing deprecated name

* Cleaning up warnings - removing dead code

* Revert "Cleaning up warnings - removing dead code"

This reverts commit f18a765e4bf240b0ed9294ec3ae5dab5c186b801.
2019-10-24 11:21:29 +02:00
Max Inden
e65bfbd846 examples: Add distributed key value store (#1281)
* examples: Add distributed key value store

This commit adds a basic distributed key value store supporting GET and
PUT commands using Kademlia and mDNS.

* examples/distributed-key-value-store: Fix typo
2019-10-24 10:58:42 +02:00
Max Inden
206e4e7553 *: Consolidate protobuf scripts and update to rust-protobuf 2.8.1 (#1275)
* *: Consolidate protobuf generation scripts

* *: Update to rust-protobuf 2.8.1

* *: Mark protobuf generated modules with '_proto'
2019-10-22 13:39:07 +02:00
Tony Arcieri
b90aa37b95 zeroize: Upgrade to v1.0 (#1284)
v1.0 final release is out. Release notes:

https://github.com/iqlusioninc/crates/pull/279
2019-10-22 10:10:45 +00:00