qp2p

Crates.ioqp2p
lib.rsqp2p
version0.36.4
sourcesrc
created_at2020-09-08 13:57:51.375203
updated_at2023-03-14 09:41:57.906138
descriptionPeer-to-peer networking library using QUIC
homepagehttps://maidsafe.net
repositoryhttps://github.com/maidsafe/qp2p
max_upload_size
id286146
size226,661
MaidSafe-QA (MaidSafe-QA)

documentation

https://docs.rs/qp2p

README

qp2p

Crate Documentation
Documentation
MaidSafe website SAFE Dev Forum SAFE Network Forum

Overview

This library provides an API to simplify common tasks when creating P2P networks, including:

  • Establishing encrypted, uni- and bidirectional connections (using QUIC with TLS 1.3).
  • Connection pooling, for reusing already opened connections.
  • Fault-tolerance, including retries and racing connections against sets of peers.
  • Sending discrete messages (using QUIC streams as 'framing').

Features

QUIC

There are several informative posts describing both QUIC and TLS 1.3:

These are highly recommended to be able to better understand this library, in particular the Cloudflare blog posts (10 minute read).

Encryption of connections

QUIC provides connection security via the use of TLS 1.3. Currently, self-signed certificates are used to encrypt connections, but this provides no authentication.

In the future, we would like to support authentication via certificate authorities and pre-agreed certificates. This should satisfy the requirements of many P2P networks, whether they trust any clearnet certificate authority (which may be a centralised attack source) or whether they pass the identity management up to a different layer to validate identities and simply use qp2p as a secured network in terms of encrypted connections.

Connection pooling

Although QUIC connections are relatively cheap to establish (e.g. compared to TCP connections), there is still some overhead. To minimise this overhead, all opened connections are pooled and reused based on their target socket address.

Fault tolerance

APIs are available to connect to any peer from a list of peers. Connections are established concurrently, and the first to succeed is kept, while the rest are discarded. This allows connecting to any of a set of equivalent peers, finding a still-reachable peer in a set of previously known peers, etc.

Messaging

QUIC is a streaming protocol, without an explicit model for discrete messages. However, QUIC connections can multiplex an arbitrary number of streams, which are cheap to construct and dispose of. This library uses streams as a message framing mechanism, sending or receiving a single message per stream.

QUIC supports both unidirectional and bidirectional streams, and both are exposed through this library.

  • Unidirectional streams should typically be preferred for peer-to-peer communication. This requires peers to have external connectivity, which is generally better for fault tolerance (e.g. contact sharing, reconnection).

  • Bidirectional streams should be preferred for client-server communication. This does not require external connectivity, so clients can still communicate from behind firewalls/gateways (such as household routers).

License

This SAFE Network library is dual-licensed under the Modified BSD (LICENSE-BSD https://opensource.org/licenses/BSD-3-Clause) or the MIT license (LICENSE-MIT http://opensource.org/licenses/MIT) at your option.

Contributing

Want to contribute? Great 🎉

There are many ways to give back to the project, whether it be writing new code, fixing bugs, or just reporting errors. All forms of contributions are encouraged!

For instructions on how to contribute, see our Guide to contributing.

Commit count: 776

cargo fmt