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.
The `QueryId` type should be exported as it is used in the
`NetworkBehaviour::ProtocolsHandler` type of `Kademlia`.
`Kademlia::protocol_name` is added for convenience.
* 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
* 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.
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.
* 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>
Also implement `Deref` and `DerefMut` on `Config` to allow transparent
configuration of `yamux::Config`.
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
* 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>
* 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
* 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>
* 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
* 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
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>
* 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>
* 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
* 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>