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 all 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 @@ -62,6 +62,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 = ["dep:libp2p-tcp"]
Expand Down Expand Up @@ -98,6 +99,7 @@ libp2p-noise = { version = "0.40.0", path = "transports/noise", optional = true
libp2p-ping = { version = "0.40.1", path = "protocols/ping", optional = true }
libp2p-plaintext = { version = "0.37.0", path = "transports/plaintext", optional = true }
libp2p-pnet = { version = "0.22.1", path = "transports/pnet", optional = true }
libp2p-quic = { version = "0.8.0", path = "transports/quic", optional = true }
libp2p-relay = { version = "0.13.0", path = "protocols/relay", optional = true }
libp2p-rendezvous = { version = "0.10.0", path = "protocols/rendezvous", optional = true }
libp2p-request-response = { version = "0.22.1", 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 @@ -93,6 +93,10 @@ pub use libp2p_plaintext as plaintext;
#[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")]
#[doc(inline)]
pub use libp2p_relay as relay;
Expand Down
26 changes: 26 additions & 0 deletions transports/quic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[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 = "2.0.0"
libp2p-core = { version = "0.37.0", path = "../../core" }
libp2p-tls = { version = "0.1.0-alpha", path = "../../transports/tls" }
quinn = { version = "0.9.0", features = ["tls-rustls", "futures-io", "runtime-async-std"] }
futures = "0.3.21"
thiserror = "1.0.26"
tracing = "0.1"
rand = "0.8.5"
rustls = "0.20.2"

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

use futures::stream::Stream;

use std::{
io::Result,
net::IpAddr,
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<IfWatcher> },
}

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) -> Result<Self> {
let result = if ip.is_unspecified() {
let watcher = IfWatcher::new()?;
InAddr::Any {
if_watch: Box::new(watcher),
}
} else {
InAddr::One { ip: Some(ip) }
};
Ok(result)
}
}

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);
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 } => {
// Consume all events for up/down interface changes.
if let Poll::Ready(ev) = if_watch.poll_if_event(cx) {
match ev {
Ok(event) => {
return Poll::Ready(Some(Ok(event)));
}
Err(err) => {
return Poll::Ready(Some(Err(err)));
}
}
}
}
}
Poll::Pending
}
}
Loading