* 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.
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
* 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
* 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
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.
* 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)