Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add WebTransport protocol #4874

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1c2c377
attempt to extend QUIC transport impl
dgarus Nov 16, 2023
8bf8d0c
example
dgarus Nov 16, 2023
cabc7de
example
dgarus Nov 16, 2023
83058d5
Merge branch 'master' into web-transport-quic
dgarus Nov 17, 2023
fdcd176
Merge branch 'master' into web-transport-quic
dgarus Nov 21, 2023
8325840
Merge branch 'master' into web-transport-quic
dgarus Nov 22, 2023
7a54fd3
Merge branch 'master' into web-transport-quic
dgarus Nov 23, 2023
dc80864
Merge branch 'master' into web-transport-quic
dgarus Dec 12, 2023
13cc3df
added CertManager
dgarus Dec 22, 2023
5ceccfd
Merge branch 'master' into web-transport-quic
dgarus Dec 22, 2023
cd9d646
Merge branch 'master' into web-transport-quic
dgarus Dec 25, 2023
10d97fe
noise
dgarus Dec 25, 2023
d418dc1
single endpoint for quic and wt
dgarus Dec 25, 2023
cefaebe
Merge remote-tracking branch 'origin/web-transport-quic' into web-tra…
dgarus Dec 25, 2023
94fd970
Merge branch 'master' into web-transport-quic
dgarus Dec 25, 2023
c1dca8c
Merge branch 'master' into web-transport-quic
dgarus Dec 29, 2023
d01f149
Merge branch 'master' into web-transport-quic
dgarus Jan 9, 2024
1f2297c
Merge branch 'master' into web-transport-quic
dgarus Jan 18, 2024
dc08909
msg
dgarus Jan 25, 2024
a3e3a5e
Merge remote-tracking branch 'origin/web-transport-quic' into web-tra…
dgarus Jan 25, 2024
2b06072
Merge branch 'master' into web-transport-quic
dgarus Jan 25, 2024
c3a8e7d
Merge branch 'master' into web-transport-quic
dgarus Feb 12, 2024
f024ded
Merge branch 'master' into web-transport-quic
dgarus Apr 16, 2024
1cdecf1
Merge branch 'master' into web-transport-quic
dgarus May 2, 2024
9b8b27e
Merge branch 'master' into web-transport-quic
dgarus May 7, 2024
c5ff302
Merge branch 'refs/heads/master' into web-transport-quic
dgarus Jul 9, 2024
098b58b
Merge branch 'master' into web-transport-quic
dgarus Jul 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 80 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions transports/quic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ tokio = { version = "1.33.0", default-features = false, features = ["net", "rt",
tracing = "0.1.37"
socket2 = "0.5.5"
ring = "0.16.20"
sha2 = "0.10.7"
hex = "0.4"

# WebTransport
http = "0.2.11"
h3 = { git = "https://github.com/hyperium/h3" }
h3-quinn = { git = "https://github.com/hyperium/h3" }
h3-webtransport = { git = "https://github.com/hyperium/h3" }
Comment on lines +36 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there no released versions of these libraries yet? We won't be able to merge this without released versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With git versions, everything is ok:

image

But when I define h3 = "0.0.4" I got two versions 0.0.3 and 0.0.4:

image

And, accordingly, I got a lot of errors.
I stuck with this problem for the first time, do you know how to fix it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is because there hasn't yet been a release of h3-webtransport with h3 0.0.4. See https://crates.io/crates/h3-webtransport/0.1.0/dependencies. I'd suggest nudging the maintainers for a new release!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG
Thanks, I'll do it a bit later

rcgen = "0.11.3"
time = "0.3"

[features]
tokio = ["dep:tokio", "if-watch/tokio", "quinn/runtime-tokio"]
Expand All @@ -48,6 +58,7 @@ libp2p-yamux = { workspace = true }
quickcheck = "1"
tokio = { version = "1.33.0", features = ["macros", "rt-multi-thread", "time"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
hex-literal = "0.4"

[[test]]
name = "stream_compliance"
Expand Down
32 changes: 31 additions & 1 deletion transports/quic/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER

Check failure on line 18 in transports/quic/src/config.rs

View workflow job for this annotation

GitHub Actions / rustfmt

Diff in /home/runner/work/rust-libp2p/rust-libp2p/transports/quic/src/config.rs
// DEALINGS IN THE SOFTWARE.

use quinn::VarInt;
use std::{sync::Arc, time::Duration};
use libp2p_core::multihash::Multihash;
use crate::webtransport::fingerprint::Fingerprint;

/// Config for the transport.
#[derive(Clone)]
Expand Down Expand Up @@ -55,12 +57,23 @@
/// If support for draft-29 is enabled servers support draft-29 and version 1 on all
/// QUIC listening addresses.
/// As client the version is chosen based on the remote's address.
pub support_draft_29: bool,

Check failure on line 60 in transports/quic/src/config.rs

View workflow job for this annotation

GitHub Actions / rustfmt

Diff in /home/runner/work/rust-libp2p/rust-libp2p/transports/quic/src/config.rs

// pub web_transport_config: WebTransportConfig,

/// TLS client config for the inner [`quinn::ClientConfig`].
client_tls_config: Arc<rustls::ClientConfig>,
//todo At first boot of the node, it creates one self-signed certificate with a validity of 14 days,
// starting immediately, and another certificate with the 14 day validity period starting on
// the expiry date of the first certificate.
// The node advertises a multiaddress containing the certificate hashes of these two certificates.
// Once the first certificate has expired, the node starts using the already generated next certificate.
// At the same time, it again generates a new certificate for the following period and updates
// the multiaddress it advertises.
/// TLS server config for the inner [`quinn::ServerConfig`].
server_tls_config: Arc<rustls::ServerConfig>,
pub(crate) cert_hash: Multihash<64>,

/// Libp2p identity of the node.
keypair: libp2p_identity::Keypair,
}
Expand All @@ -69,10 +82,26 @@
/// Creates a new configuration object with default values.
pub fn new(keypair: &libp2p_identity::Keypair) -> Self {
let client_tls_config = Arc::new(libp2p_tls::make_client_config(keypair, None).unwrap());
let server_tls_config = Arc::new(libp2p_tls::make_server_config(keypair).unwrap());

//todo set up cert's dates
let (cert, private_key) = libp2p_tls::certificate::generate(keypair).unwrap();

let server_tls_config = Arc::new(
libp2p_tls::make_server_config_with_cert(
cert.clone(), private_key, vec![

Check failure on line 91 in transports/quic/src/config.rs

View workflow job for this annotation

GitHub Actions / rustfmt

Diff in /home/runner/work/rust-libp2p/rust-libp2p/transports/quic/src/config.rs
b"libp2p".to_vec(),
b"h3".to_vec(),
b"h3-32".to_vec(),
b"h3-31".to_vec(),
b"h3-30".to_vec(),
b"h3-29".to_vec(),
]

Check failure on line 98 in transports/quic/src/config.rs

View workflow job for this annotation

GitHub Actions / rustfmt

Diff in /home/runner/work/rust-libp2p/rust-libp2p/transports/quic/src/config.rs
).unwrap()
);
Self {
client_tls_config,
server_tls_config,
cert_hash: Fingerprint::from_certificate(cert.as_ref()).to_multihash(),
support_draft_29: false,
handshake_timeout: Duration::from_secs(5),
max_idle_timeout: 30 * 1000,
Expand Down Expand Up @@ -100,6 +129,7 @@
let Config {
client_tls_config,
server_tls_config,
cert_hash: _,
max_idle_timeout,
max_concurrent_stream_limit,
keep_alive_interval,
Expand Down
5 changes: 3 additions & 2 deletions transports/quic/src/connection/connecting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@

use futures::{
future::{select, Either, FutureExt, Select},
prelude::*,

Check failure on line 27 in transports/quic/src/connection/connecting.rs

View workflow job for this annotation

GitHub Actions / rustfmt

Diff in /home/runner/work/rust-libp2p/rust-libp2p/transports/quic/src/connection/connecting.rs
};
use futures_timer::Delay;
use libp2p_identity::PeerId;
use std::{
pin::Pin,
task::{Context, Poll},

Check failure on line 33 in transports/quic/src/connection/connecting.rs

View workflow job for this annotation

GitHub Actions / rustfmt

Diff in /home/runner/work/rust-libp2p/rust-libp2p/transports/quic/src/connection/connecting.rs
time::Duration,
};
use libp2p_core::muxing::StreamMuxerBox;

/// A QUIC connection currently being negotiated.
#[derive(Debug)]
Expand Down Expand Up @@ -67,7 +68,7 @@
}

impl Future for Connecting {
type Output = Result<(PeerId, Connection), Error>;
type Output = Result<(PeerId, StreamMuxerBox), Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let connection = match futures::ready!(self.connecting.poll_unpin(cx)) {
Expand All @@ -77,6 +78,6 @@

let peer_id = Self::remote_peer_id(&connection);
let muxer = Connection::new(connection);
Poll::Ready(Ok((peer_id, muxer)))
Poll::Ready(Ok((peer_id, StreamMuxerBox::new(muxer))))
}
}
4 changes: 4 additions & 0 deletions transports/quic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ mod connection;
mod hole_punching;
mod provider;
mod transport;
mod webtransport;

use std::net::SocketAddr;

Expand Down Expand Up @@ -101,6 +102,9 @@ pub enum Error {
/// Error when holepunching for a remote is already in progress
#[error("Already punching hole for {0}).")]
HolePunchInProgress(SocketAddr),

#[error("WebTransport error.")]
WebTransportError,
}

/// Dialing a remote peer failed.
Expand Down
Loading
Loading