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

Quic attempt 4 #2801

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c2a4468
Init impl with quinn
kpp Aug 4, 2022
c1a3137
Copy tls code
kpp Aug 4, 2022
853e7fd
Use tls-quic crypto
kpp Aug 4, 2022
709b199
Handle Listeners
elenaf9 Aug 4, 2022
df5c1cc
Copy IfAddr code
kpp Aug 5, 2022
16441e6
Call poll_if_addr
elenaf9 Aug 5, 2022
2f69771
Get peer id in QuicUpgrade
kpp Aug 4, 2022
14b4151
Add tests
kpp Aug 4, 2022
39585f9
Make QuicSubstream::poll_close fuse'able
kpp Aug 4, 2022
e7c71f5
Add quic to libp2p
kpp Aug 5, 2022
2e73f06
Fix tracing dep version
kpp Aug 5, 2022
3fce558
Add to/from udp addr tests
kpp Aug 5, 2022
e51072b
Add test close_listener
elenaf9 Aug 5, 2022
0a3fca1
Fix warnings in tests
kpp Aug 5, 2022
629b158
Dial with an appropriate local addr
elenaf9 Aug 5, 2022
45018da
cargo clippy
kpp Aug 5, 2022
2dea096
cargo fmt
kpp Aug 5, 2022
945fd1f
Merge branch 'master' into quic-attempt-4
kpp Aug 25, 2022
d8ef5c1
Fix poll_address_change
kpp Aug 25, 2022
645b0ba
Move to async_std with a custom quinn
kpp Aug 25, 2022
526e065
Merge branch 'master' into quic-attempt-4
kpp Sep 12, 2022
03ad457
Upgrade if-watch to 2.0.0
kpp Sep 12, 2022
0a6915b
Merge branch 'master' into quic-attempt-4
kpp Sep 21, 2022
0e86fb2
Use cipher suite order from rustls
kpp Sep 22, 2022
7569b16
Merge branch 'master' into quic-attempt-4
kpp Oct 28, 2022
197b270
Move crypto to libp2p-tls crate
kpp Oct 28, 2022
e9dcec3
Remove usused tls mod
kpp Oct 28, 2022
eca5328
Update quinn crate
kpp Oct 28, 2022
46902ab
Ignore test endpoint_reuse for now
kpp Nov 1, 2022
568ede9
Remove unused deps
kpp Nov 1, 2022
150297e
Use ops::Try whenever possible
kpp Nov 1, 2022
11ef3a5
Use quinn from crates.io
kpp Nov 3, 2022
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
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ ping = ["dep:libp2p-ping", "libp2p-metrics?/ping"]
plaintext = ["dep:libp2p-plaintext"]
pnet = ["dep:libp2p-pnet"]
relay = ["dep:libp2p-relay", "libp2p-metrics?/relay"]
quic = ["dep:libp2p-quic"]
request-response = ["dep:libp2p-request-response"]
rendezvous = ["dep:libp2p-rendezvous"]
tcp-async-io = ["dep:libp2p-tcp", "libp2p-tcp?/async-io"]
Expand Down Expand Up @@ -89,6 +90,7 @@ libp2p-noise = { version = "0.38.0", path = "transports/noise", optional = true
libp2p-ping = { version = "0.38.0", path = "protocols/ping", optional = true }
libp2p-plaintext = { version = "0.35.0", path = "transports/plaintext", optional = true }
libp2p-pnet = { version = "0.22.0", path = "transports/pnet", optional = true }
libp2p-quic = { version = "0.8.0", path = "transports/quic", optional = true }
libp2p-relay = { version = "0.11.0", path = "protocols/relay", optional = true }
libp2p-rendezvous = { version = "0.8.0", path = "protocols/rendezvous", optional = true }
libp2p-request-response = { version = "0.20.0", path = "protocols/request-response", optional = true }
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ pub use libp2p_plaintext as plaintext;
#[cfg_attr(docsrs, doc(cfg(feature = "pnet")))]
#[doc(inline)]
pub use libp2p_pnet as pnet;
#[cfg(feature = "quic")]
#[cfg_attr(docsrs, doc(cfg(feature = "quic")))]
#[doc(inline)]
pub use libp2p_quic as quic;
#[cfg(feature = "relay")]
#[cfg_attr(docsrs, doc(cfg(feature = "relay")))]
#[doc(inline)]
Expand Down
33 changes: 33 additions & 0 deletions transports/quic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "libp2p-quic"
version = "0.8.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
description = "TLS based QUIC transport implementation for libp2p"
repository = "https://github.com/libp2p/rust-libp2p"
license = "MIT"

[dependencies]
if-watch = "1.1.1"
kpp marked this conversation as resolved.
Show resolved Hide resolved
libp2p-core = { version = "0.35.0", path = "../../core" }
quinn = { version = "0.8.0", git = "https://github.com/kpp/quinn.git", branch = "parity_master", features = ["tls-rustls", "futures-io", "futures-core", "runtime-async-std"] }
futures = "0.3.21"
thiserror = "1.0.26"
tracing = "0.1"
rand = "0.8.5"

oid-registry = "0.6.0"
webpki = "0.22.0"
rcgen = "0.9.2"
ring = "0.16.20"
kpp marked this conversation as resolved.
Show resolved Hide resolved
rustls = { version = "0.20.2", default-features = false, features = ["dangerous_configuration"] }
x509-parser = "0.14.0"
yasna = "0.5.0"

[dev-dependencies]
anyhow = "1.0.41"
async-std = { version = "1.12.0", features = ["attributes"] }
async-trait = "0.1.50"
libp2p = { version = "0.47.0", default-features = false, features = ["request-response"], path = "../.." }
#libp2p = { version = "0.47.0", path = "../.." }
tracing-subscriber = {version = "0.3.8", features = ["env-filter"] }
100 changes: 100 additions & 0 deletions transports/quic/src/in_addr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
use if_watch::{IfEvent, IfWatcher};

use futures::{
future::{BoxFuture, FutureExt},
stream::Stream,
};

use std::{
io::Result,
net::IpAddr,
ops::DerefMut,
pin::Pin,
task::{Context, Poll},
};

/// Watches for interface changes.
#[derive(Debug)]
pub enum InAddr {
/// The socket accepts connections on a single interface.
One { ip: Option<IpAddr> },
/// The socket accepts connections on all interfaces.
Any { if_watch: Box<IfWatch> },
}

impl InAddr {
/// If ip is specified then only one `IfEvent::Up` with IpNet(ip)/32 will be generated.
/// If ip is unspecified then `IfEvent::Up/Down` events will be generated for all interfaces.
pub fn new(ip: IpAddr) -> Self {
if ip.is_unspecified() {
let watcher = IfWatch::Pending(IfWatcher::new().boxed());
InAddr::Any {
if_watch: Box::new(watcher),
}
} else {
InAddr::One { ip: Some(ip) }
}
}
}

pub enum IfWatch {
Pending(BoxFuture<'static, std::io::Result<IfWatcher>>),
Ready(Box<IfWatcher>),
}

impl std::fmt::Debug for IfWatch {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match *self {
IfWatch::Pending(_) => write!(f, "Pending"),
IfWatch::Ready(_) => write!(f, "Ready"),
}
}
}
impl Stream for InAddr {
type Item = Result<IfEvent>;

fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
let me = Pin::into_inner(self);
loop {
match me {
// If the listener is bound to a single interface, make sure the
// address is reported once.
InAddr::One { ip } => {
if let Some(ip) = ip.take() {
return Poll::Ready(Some(Ok(IfEvent::Up(ip.into()))));
}
}
InAddr::Any { if_watch } => {
match if_watch.deref_mut() {
// If we listen on all interfaces, wait for `if-watch` to be ready.
IfWatch::Pending(f) => match futures::ready!(f.poll_unpin(cx)) {
Ok(watcher) => {
*if_watch = Box::new(IfWatch::Ready(Box::new(watcher)));
continue;
}
Err(err) => {
*if_watch = Box::new(IfWatch::Pending(IfWatcher::new().boxed()));
return Poll::Ready(Some(Err(err)));
}
},
// Consume all events for up/down interface changes.
IfWatch::Ready(watcher) => {
if let Poll::Ready(ev) = watcher.poll_unpin(cx) {
match ev {
Ok(event) => {
return Poll::Ready(Some(Ok(event)));
}
Err(err) => {
return Poll::Ready(Some(Err(err)));
}
}
}
}
}
}
}
break;
}
Poll::Pending
}
}
Loading