Skip to content

Commit

Permalink
Merge branch 'master' of github.com:libp2p/rust-libp2p into rename-re…
Browse files Browse the repository at this point in the history
…quest-response
  • Loading branch information
jxs committed Dec 4, 2022
2 parents 11ca1df + dfc5ec8 commit 637a32d
Show file tree
Hide file tree
Showing 25 changed files with 338 additions and 98 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and host documentation
on:
push:
branches:
- master

jobs:
build:
name: Build documentation
runs-on: ubuntu-latest
steps:
- name: Install Protoc
uses: arduino/setup-protoc@v1
- name: Checkout
uses: actions/checkout@v3
- name: Install nightly toolchain
run: rustup toolchain install nightly
- name: Build Documentation
run: cargo +nightly doc --no-deps --workspace -F full
env:
RUSTDOCFLAGS: "--cfg docsrs"
RUSTFLAGS: "--cfg docsrs"
- name: Add index file
run: |
mkdir host-docs
echo "<meta http-equiv=\"refresh\" content=\"0; url=libp2p\">" > target/doc/index.html
cp -r target/doc/* ./host-docs
- name: Upload documentation
uses: actions/[email protected]
with:
path: "host-docs/"

deploy:
name: Deploy documentation
needs: build
permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ libp2p-gossipsub = { version = "0.43.0", path = "protocols/gossipsub", optional
[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }
async-trait = "0.1"
env_logger = "0.9.0"
env_logger = "0.10.0"
clap = { version = "4.0.13", features = ["derive"] }
tokio = { version = "1.15", features = ["io-util", "io-std", "macros", "rt", "rt-multi-thread"] }

Expand Down
2 changes: 1 addition & 1 deletion misc/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ libp2p-gossipsub = { version = "0.43.0", path = "../../protocols/gossipsub", op

[dev-dependencies]
log = "0.4.0"
env_logger = "0.9.0"
env_logger = "0.10.0"
futures = "0.3.1"
libp2p = { path = "../..", features = ["full"] }
hyper = { version="0.14", features = ["server", "tcp", "http1"] }
Expand Down
2 changes: 1 addition & 1 deletion misc/multistream-select/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ unsigned-varint = "0.7"

[dev-dependencies]
async-std = "1.6.2"
env_logger = "0.9"
env_logger = "0.10"
libp2p = { path = "../..", features = ["full"] }
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
rand = "0.8"
Expand Down
2 changes: 1 addition & 1 deletion muxers/mplex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] }
[dev-dependencies]
async-std = { version = "1.7.0", features = ["attributes"] }
criterion = "0.4"
env_logger = "0.9"
env_logger = "0.10"
futures = "0.3"
libp2p = { path = "../..", features = ["full"] }
libp2p-muxer-test-harness = { path = "../test-harness" }
Expand Down
2 changes: 1 addition & 1 deletion protocols/autonat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ prost = "0.11"

[dev-dependencies]
async-std = { version = "1.10", features = ["attributes"] }
env_logger = "0.9"
env_logger = "0.10"
clap = { version = "4.0.13", features = ["derive"] }
libp2p = { path = "../..", features = ["full"] }

Expand Down
2 changes: 1 addition & 1 deletion protocols/dcutr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void = "1"
prost-build = "0.11"

[dev-dependencies]
env_logger = "0.9.0"
env_logger = "0.10.0"
libp2p = { path = "../..", features = ["full"] }
rand = "0.8"
clap = { version = "4.0.13", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ prometheus-client = "0.18.0"

[dev-dependencies]
async-std = "1.6.3"
env_logger = "0.9.0"
env_logger = "0.10.0"
libp2p = { path = "../..", features = ["full"] }
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
hex = "0.4.2"
Expand Down
2 changes: 1 addition & 1 deletion protocols/identify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void = "1.0"

[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }
env_logger = "0.9"
env_logger = "0.10"
libp2p = { path = "../..", features = ["full"] }

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ serde = { version = "1.0", optional = true, features = ["derive"] }
thiserror = "1"

[dev-dependencies]
env_logger = "0.9.0"
env_logger = "0.10.0"
futures-timer = "3.0"
libp2p = { path = "../..", features = ["full"] }
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
Expand Down
2 changes: 1 addition & 1 deletion protocols/mdns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async-io = ["dep:async-io", "if-watch/smol"]

[dev-dependencies]
async-std = { version = "1.9.0", features = ["attributes"] }
env_logger = "0.9.0"
env_logger = "0.10.0"
libp2p = { path = "../..", features = ["full"] }
tokio = { version = "1.19", default-features = false, features = ["macros", "rt", "rt-multi-thread", "time"] }

Expand Down
2 changes: 1 addition & 1 deletion protocols/relay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void = "1"
prost-build = "0.11"

[dev-dependencies]
env_logger = "0.9.0"
env_logger = "0.10.0"
libp2p = { path = "../..", features = ["full"] }
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
clap = { version = "4.0.13", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion protocols/rendezvous/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void = "1"

[dev-dependencies]
async-trait = "0.1"
env_logger = "0.9.0"
env_logger = "0.10.0"
libp2p = { path = "../..", features = ["full"] }
rand = "0.8"
tokio = { version = "1.15", features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs", "net" ] }
Expand Down
2 changes: 1 addition & 1 deletion protocols/request-response/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ unsigned-varint = { version = "0.7", features = ["std", "futures"] }

[dev-dependencies]
async-std = "1.6.2"
env_logger = "0.9.0"
env_logger = "0.10.0"
libp2p = { path = "../..", features = ["full"] }
rand = "0.8"

Expand Down
2 changes: 1 addition & 1 deletion swarm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ wasm-bindgen = ["dep:wasm-bindgen-futures", "dep:getrandom"]
[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }
either = "1.6.0"
env_logger = "0.9"
env_logger = "0.10"
futures = "0.3.1"
libp2p-identify = { path = "../protocols/identify" }
libp2p-kad = { path = "../protocols/kad" }
Expand Down
2 changes: 1 addition & 1 deletion transports/dns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trust-dns-resolver = { version = "0.22", default-features = false, features = ["
smallvec = "1.6.1"

[dev-dependencies]
env_logger = "0.9"
env_logger = "0.10"
tokio-crate = { package = "tokio", version = "1.0", default-features = false, features = ["rt", "time"] }
async-std-crate = { package = "async-std", version = "1.6" }

Expand Down
2 changes: 1 addition & 1 deletion transports/noise/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ snow = { version = "0.9.0", features = ["default-resolver"], default-features =

[dev-dependencies]
async-io = "1.2.0"
env_logger = "0.9.0"
env_logger = "0.10.0"
libp2p = { path = "../..", features = ["full"] }
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
libsodium-sys-stable = { version = "1.19.22", features = ["fetch-latest"] }
Expand Down
2 changes: 1 addition & 1 deletion transports/plaintext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] }
void = "1.0.2"

[dev-dependencies]
env_logger = "0.9.0"
env_logger = "0.10.0"
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
rand = "0.8"

Expand Down
7 changes: 7 additions & 0 deletions transports/quic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 0.7.0-alpha.2 [unreleased]

- Add opt-in support for the `/quic` codepoint, interpreted as QUIC version draft-29.
See [PR 3151].

[PR 3151]: https://github.com/libp2p/rust-libp2p/pull/3151

# 0.7.0-alpha

- Initial alpha release.
4 changes: 2 additions & 2 deletions transports/quic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libp2p-quic"
version = "0.7.0-alpha"
version = "0.7.0-alpha.2"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
rust-version = "1.62.0"
Expand Down Expand Up @@ -37,7 +37,7 @@ rustc-args = ["--cfg", "docsrs"]

[dev-dependencies]
async-std = { version = "1.12.0", features = ["attributes"] }
env_logger = "0.9.0"
env_logger = "0.10.0"
libp2p = { path = "../..", features = ["tcp", "yamux", "noise", "async-std"] }
libp2p-muxer-test-harness = { path = "../../muxers/test-harness" }
quickcheck = "1"
Expand Down
50 changes: 39 additions & 11 deletions transports/quic/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

use crate::{provider::Provider, transport::SocketFamily, ConnectError, Connection, Error};
use crate::{
provider::Provider,
transport::{ProtocolVersion, SocketFamily},
ConnectError, Connection, Error,
};

use bytes::BytesMut;
use futures::{
Expand Down Expand Up @@ -69,6 +73,16 @@ pub struct Config {
/// of a connection.
pub max_connection_data: u32,

/// Support QUIC version draft-29 for dialing and listening.
///
/// Per default only QUIC Version 1 / [`libp2p_core::multiaddr::Protocol::QuicV1`]
/// is supported.
///
/// 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,

/// TLS client config for the inner [`quinn_proto::ClientConfig`].
client_tls_config: Arc<rustls::ClientConfig>,
/// TLS server config for the inner [`quinn_proto::ServerConfig`].
Expand All @@ -83,6 +97,7 @@ impl Config {
Self {
client_tls_config,
server_tls_config,
support_draft_29: false,
handshake_timeout: Duration::from_secs(5),
max_idle_timeout: 30 * 1000,
max_concurrent_stream_limit: 256,
Expand Down Expand Up @@ -113,6 +128,7 @@ impl From<Config> for QuinnConfig {
keep_alive_interval,
max_connection_data,
max_stream_data,
support_draft_29,
handshake_timeout: _,
} = config;
let mut transport = quinn_proto::TransportConfig::default();
Expand All @@ -138,7 +154,10 @@ impl From<Config> for QuinnConfig {
let mut client_config = quinn_proto::ClientConfig::new(client_tls_config);
client_config.transport_config(transport);

let endpoint_config = quinn_proto::EndpointConfig::default();
let mut endpoint_config = quinn_proto::EndpointConfig::default();
if !support_draft_29 {
endpoint_config.supported_versions(vec![1]);
}

QuinnConfig {
client_config,
Expand Down Expand Up @@ -280,6 +299,8 @@ pub enum ToEndpoint {
Dial {
/// UDP address to connect to.
addr: SocketAddr,
/// Version to dial the remote on.
version: ProtocolVersion,
/// Channel to return the result of the dialing to.
result: oneshot::Sender<Result<Connection, Error>>,
},
Expand Down Expand Up @@ -403,18 +424,25 @@ impl<P: Provider> Driver<P> {
to_endpoint: ToEndpoint,
) -> ControlFlow<(), Option<quinn_proto::Transmit>> {
match to_endpoint {
ToEndpoint::Dial { addr, result } => {
ToEndpoint::Dial {
addr,
result,
version,
} => {
let mut config = self.client_config.clone();
if version == ProtocolVersion::Draft29 {
config.version(0xff00_001d);
}
// This `"l"` seems necessary because an empty string is an invalid domain
// name. While we don't use domain names, the underlying rustls library
// is based upon the assumption that we do.
let (connection_id, connection) =
match self.endpoint.connect(self.client_config.clone(), addr, "l") {
Ok(c) => c,
Err(err) => {
let _ = result.send(Err(ConnectError::from(err).into()));
return ControlFlow::Continue(None);
}
};
let (connection_id, connection) = match self.endpoint.connect(config, addr, "l") {
Ok(c) => c,
Err(err) => {
let _ = result.send(Err(ConnectError::from(err).into()));
return ControlFlow::Continue(None);
}
};

debug_assert_eq!(connection.side(), quinn_proto::Side::Client);
let (tx, rx) = mpsc::channel(CHANNEL_CAPACITY);
Expand Down
Loading

0 comments on commit 637a32d

Please sign in to comment.