diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 21863d0ed39..5cbfc20d69d 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -6,7 +6,6 @@ on: - 'master' tags: - 'libp2p-server-**' - pull_request: jobs: server: @@ -34,11 +33,6 @@ jobs: with: context: . file: ./misc/server/Dockerfile - push: ${{ ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} # Only push image if we have the required permissions, i.e. not running from a fork - cache-from: ${{ ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' && type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=rust-libp2p-server }} - cache-to: ${{ ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' && type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=rust-libp2p-server }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - env: - AWS_ACCESS_KEY_ID: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }} diff --git a/.github/workflows/interop-test.yml b/.github/workflows/interop-test.yml index f3950897089..558adcda66c 100644 --- a/.github/workflows/interop-test.yml +++ b/.github/workflows/interop-test.yml @@ -1,6 +1,5 @@ name: Interoperability Testing on: - pull_request: push: branches: - "master" @@ -24,8 +23,9 @@ jobs: - name: Build ${{ matrix.flavour }} image run: ./scripts/build-interop-image.sh env: - AWS_ACCESS_KEY_ID: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }} + AWS_BUCKET_NAME: ${{ vars.S3_LIBP2P_BUILD_CACHE_BUCKET_NAME }} + AWS_ACCESS_KEY_ID: ${{ vars.S3_LIBP2P_BUILD_CACHE_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_LIBP2P_BUILD_CACHE_AWS_SECRET_ACCESS_KEY }} FLAVOUR: ${{ matrix.flavour }} - name: Run ${{ matrix.flavour }} tests @@ -33,9 +33,9 @@ jobs: with: test-filter: ${{ matrix.flavour }}-rust-libp2p-head extra-versions: ${{ github.workspace }}/interop-tests/${{ matrix.flavour }}-ping-version.json - s3-cache-bucket: libp2p-by-tf-aws-bootstrap - s3-access-key-id: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }} - s3-secret-access-key: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }} + s3-cache-bucket: ${{ vars.S3_LIBP2P_BUILD_CACHE_BUCKET_NAME }} + s3-access-key-id: ${{ vars.S3_LIBP2P_BUILD_CACHE_AWS_ACCESS_KEY_ID }} + s3-secret-access-key: ${{ secrets.S3_LIBP2P_BUILD_CACHE_AWS_SECRET_ACCESS_KEY }} worker-count: 16 run-holepunching-interop: name: Run hole-punch interoperability tests @@ -50,7 +50,7 @@ jobs: with: test-filter: rust-libp2p-head extra-versions: ${{ github.workspace }}/hole-punching-tests/version.json - s3-cache-bucket: libp2p-by-tf-aws-bootstrap - s3-access-key-id: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }} - s3-secret-access-key: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }} + s3-cache-bucket: ${{ vars.S3_LIBP2P_BUILD_CACHE_BUCKET_NAME }} + s3-access-key-id: ${{ vars.S3_LIBP2P_BUILD_CACHE_AWS_ACCESS_KEY_ID }} + s3-secret-access-key: ${{ secrets.S3_LIBP2P_BUILD_CACHE_AWS_SECRET_ACCESS_KEY }} worker-count: 16 diff --git a/Cargo.lock b/Cargo.lock index 31ac59efa4a..e7d9086acf8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -833,9 +833,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" dependencies = [ "serde", ] @@ -2687,7 +2687,7 @@ dependencies = [ [[package]] name = "libp2p-autonat" -version = "0.13.0" +version = "0.13.1" dependencies = [ "async-std", "async-trait", @@ -2874,7 +2874,7 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.45.0" +version = "0.45.1" dependencies = [ "async-std", "asynchronous-codec", @@ -4584,30 +4584,6 @@ dependencies = [ "elliptic-curve", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.85" @@ -4724,7 +4700,7 @@ dependencies = [ "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash", + "rustc-hash 1.1.0", "rustls 0.23.11", "thiserror", "tokio", @@ -4733,14 +4709,14 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.2" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e974563a4b1c2206bbc61191ca4da9c22e4308b4c455e8906751cc7828393f08" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" dependencies = [ "bytes", "rand 0.8.5", "ring 0.17.8", - "rustc-hash", + "rustc-hash 2.0.0", "rustls 0.23.11", "slab", "thiserror", @@ -5206,6 +5182,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc_version" version = "0.4.0" @@ -5471,18 +5453,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.203" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -5513,9 +5495,9 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", @@ -6002,30 +5984,29 @@ dependencies = [ [[package]] name = "thirtyfour-macros" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cae91d1c7c61ec65817f1064954640ee350a50ae6548ff9a1bdd2489d6ffbb0" +checksum = "b72d056365e368fc57a56d0cec9e41b02fb4a3474a61c8735262b1cfebe67425" dependencies = [ - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", @@ -6576,9 +6557,9 @@ dependencies = [ [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna 0.5.0", diff --git a/Cargo.toml b/Cargo.toml index 853e5c62b4b..cf55527c1ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,14 +77,14 @@ futures-bounded = { version = "0.2.4" } futures-rustls = { version = "0.26.0", default-features = false } libp2p = { version = "0.54.1", path = "libp2p" } libp2p-allow-block-list = { version = "0.4.1", path = "misc/allow-block-list" } -libp2p-autonat = { version = "0.13.0", path = "protocols/autonat" } +libp2p-autonat = { version = "0.13.1", path = "protocols/autonat" } libp2p-connection-limits = { version = "0.4.0", path = "misc/connection-limits" } libp2p-core = { version = "0.42.0", path = "core" } libp2p-dcutr = { version = "0.12.1", path = "protocols/dcutr" } libp2p-dns = { version = "0.42.0", path = "transports/dns" } libp2p-floodsub = { version = "0.45.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.47.1", path = "protocols/gossipsub" } -libp2p-identify = { version = "0.45.0", path = "protocols/identify" } +libp2p-identify = { version = "0.45.1", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } libp2p-kad = { version = "0.47.0", path = "protocols/kad" } libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" } diff --git a/examples/autonatv2/Dockerfile b/examples/autonatv2/Dockerfile index 5a523649d80..6bc92e4d11b 100644 --- a/examples/autonatv2/Dockerfile +++ b/examples/autonatv2/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.75-alpine as builder +FROM rust:1.81-alpine as builder RUN apk add musl-dev diff --git a/hole-punching-tests/Dockerfile b/hole-punching-tests/Dockerfile index af00ef2272f..403cc301fc6 100644 --- a/hole-punching-tests/Dockerfile +++ b/hole-punching-tests/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.75.0 as builder +FROM rust:1.81.0 as builder # Run with access to the target cache to speed up builds WORKDIR /workspace diff --git a/interop-tests/Dockerfile.chromium b/interop-tests/Dockerfile.chromium index a6b0fc89e82..86edbc5b9d2 100644 --- a/interop-tests/Dockerfile.chromium +++ b/interop-tests/Dockerfile.chromium @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.75.0 as chef +FROM rust:1.81 as chef RUN rustup target add wasm32-unknown-unknown RUN wget -q -O- https://github.com/rustwasm/wasm-pack/releases/download/v0.12.1/wasm-pack-v0.12.1-x86_64-unknown-linux-musl.tar.gz | tar -zx -C /usr/local/bin --strip-components 1 --wildcards "wasm-pack-*/wasm-pack" RUN wget -q -O- https://github.com/WebAssembly/binaryen/releases/download/version_115/binaryen-version_115-x86_64-linux.tar.gz | tar -zx -C /usr/local/bin --strip-components 2 --wildcards "binaryen-version_*/bin/wasm-opt" diff --git a/interop-tests/Dockerfile.native b/interop-tests/Dockerfile.native index b122ac72991..499c73437fc 100644 --- a/interop-tests/Dockerfile.native +++ b/interop-tests/Dockerfile.native @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM lukemathwalker/cargo-chef:0.1.62-rust-1.75.0 as chef +FROM lukemathwalker/cargo-chef:0.1.67-rust-bullseye as chef WORKDIR /app FROM chef AS planner diff --git a/misc/allow-block-list/src/lib.rs b/misc/allow-block-list/src/lib.rs index 7646638a651..56de29d1985 100644 --- a/misc/allow-block-list/src/lib.rs +++ b/misc/allow-block-list/src/lib.rs @@ -271,6 +271,8 @@ where _: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } diff --git a/misc/connection-limits/src/lib.rs b/misc/connection-limits/src/lib.rs index b02e52f25a1..05a9b639f26 100644 --- a/misc/connection-limits/src/lib.rs +++ b/misc/connection-limits/src/lib.rs @@ -355,6 +355,8 @@ impl NetworkBehaviour for Behaviour { _: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } @@ -586,6 +588,8 @@ mod tests { _connection_id: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } diff --git a/misc/memory-connection-limits/src/lib.rs b/misc/memory-connection-limits/src/lib.rs index 7b5803a61aa..757ff770487 100644 --- a/misc/memory-connection-limits/src/lib.rs +++ b/misc/memory-connection-limits/src/lib.rs @@ -190,6 +190,8 @@ impl NetworkBehaviour for Behaviour { _: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } diff --git a/misc/memory-connection-limits/tests/util/mod.rs b/misc/memory-connection-limits/tests/util/mod.rs index d18aa78fd22..01e8cd9f655 100644 --- a/misc/memory-connection-limits/tests/util/mod.rs +++ b/misc/memory-connection-limits/tests/util/mod.rs @@ -116,6 +116,8 @@ impl NetworkBehaviour _: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } diff --git a/misc/quick-protobuf-codec/src/lib.rs b/misc/quick-protobuf-codec/src/lib.rs index 166ee82ff08..32cee8eccac 100644 --- a/misc/quick-protobuf-codec/src/lib.rs +++ b/misc/quick-protobuf-codec/src/lib.rs @@ -12,6 +12,7 @@ mod generated; pub use generated::test as proto; /// [`Codec`] implements [`Encoder`] and [`Decoder`], uses [`unsigned_varint`] +/// /// to prefix messages with their length and uses [`quick_protobuf`] and a provided /// `struct` implementing [`MessageRead`] and [`MessageWrite`] to do the encoding. pub struct Codec { diff --git a/misc/server/Dockerfile b/misc/server/Dockerfile index 1583fba6bef..24ae2b9fd99 100644 --- a/misc/server/Dockerfile +++ b/misc/server/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.75.0 as chef +FROM rust:1.81.0 as chef RUN wget -q -O- https://github.com/LukeMathWalker/cargo-chef/releases/download/v0.1.62/cargo-chef-x86_64-unknown-linux-gnu.tar.gz | tar -zx -C /usr/local/bin RUN cargo install --locked --root /usr/local libp2p-lookup --version 0.6.4 WORKDIR /app diff --git a/protocols/autonat/CHANGELOG.md b/protocols/autonat/CHANGELOG.md index e171412aa58..f1aeda6ac18 100644 --- a/protocols/autonat/CHANGELOG.md +++ b/protocols/autonat/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.13.1 +- Verify that an incoming AutoNAT dial comes from a connected peer. See [PR 5597](https://github.com/libp2p/rust-libp2p/pull/5597). + ## 0.13.0 - Due to the refactor of `Transport` it's no longer required to create a seperate transport for diff --git a/protocols/autonat/Cargo.toml b/protocols/autonat/Cargo.toml index 2c01d18dceb..0c0e757641d 100644 --- a/protocols/autonat/Cargo.toml +++ b/protocols/autonat/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-autonat" edition = "2021" rust-version = { workspace = true } description = "NAT and firewall detection for libp2p" -version = "0.13.0" +version = "0.13.1" authors = ["David Craven ", "Elena Frank ", "Hannes Furmans "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/autonat/src/v1/behaviour/as_server.rs b/protocols/autonat/src/v1/behaviour/as_server.rs index 3ecdd3ac26e..1289bd53d24 100644 --- a/protocols/autonat/src/v1/behaviour/as_server.rs +++ b/protocols/autonat/src/v1/behaviour/as_server.rs @@ -107,6 +107,21 @@ impl<'a> HandleInnerEvent for AsServer<'a> { }, } => { let probe_id = self.probe_id.next(); + if !self.connected.contains_key(&peer) { + tracing::debug!( + %peer, + "Reject inbound dial request from peer since it is not connected" + ); + + return VecDeque::from([ToSwarm::GenerateEvent(Event::InboundProbe( + InboundProbeEvent::Error { + probe_id, + peer, + error: InboundProbeError::Response(ResponseError::DialRefused), + }, + ))]); + } + match self.resolve_inbound_request(peer, request) { Ok(addrs) => { tracing::debug!( diff --git a/protocols/autonat/src/v2/client/handler/dial_back.rs b/protocols/autonat/src/v2/client/handler/dial_back.rs index b94580e69ba..98a41a82504 100644 --- a/protocols/autonat/src/v2/client/handler/dial_back.rs +++ b/protocols/autonat/src/v2/client/handler/dial_back.rs @@ -83,6 +83,8 @@ impl ConnectionHandler for Handler { tracing::warn!("Dial back request dropped, too many requests in flight"); } } + // TODO: remove when Rust 1.82 is MSRVprotocols/autonat/src/v2/client/handler/dial_back.rs + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(ListenUpgradeError { error, .. }) => { void::unreachable(error); } diff --git a/protocols/autonat/src/v2/client/handler/dial_request.rs b/protocols/autonat/src/v2/client/handler/dial_request.rs index 9d2df8ee6b4..85ad176ec30 100644 --- a/protocols/autonat/src/v2/client/handler/dial_request.rs +++ b/protocols/autonat/src/v2/client/handler/dial_request.rs @@ -216,6 +216,8 @@ async fn start_stream_handle( .map_err(|e| match e { StreamUpgradeError::NegotiationFailed => Error::UnsupportedProtocol, StreamUpgradeError::Timeout => Error::Io(io::ErrorKind::TimedOut.into()), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(v) => void::unreachable(v), StreamUpgradeError::Io(e) => Error::Io(e), })?; diff --git a/protocols/autonat/src/v2/server/behaviour.rs b/protocols/autonat/src/v2/server/behaviour.rs index 5f7b21d165b..9264c728fe4 100644 --- a/protocols/autonat/src/v2/server/behaviour.rs +++ b/protocols/autonat/src/v2/server/behaviour.rs @@ -112,6 +112,8 @@ where Either::Left(Either::Left(Err(e))) => { tracing::debug!("dial back error: {e:?}"); } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Left(Either::Right(v)) => void::unreachable(v), Either::Right(Either::Left(cmd)) => { let addr = cmd.addr.clone(); diff --git a/protocols/autonat/src/v2/server/handler/dial_request.rs b/protocols/autonat/src/v2/server/handler/dial_request.rs index 9a3729d4ccf..14ddb153416 100644 --- a/protocols/autonat/src/v2/server/handler/dial_request.rs +++ b/protocols/autonat/src/v2/server/handler/dial_request.rs @@ -143,6 +143,8 @@ where ); } } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(ListenUpgradeError { error, .. }) => { tracing::debug!("inbound request failed: {:?}", error); } diff --git a/protocols/dcutr/src/behaviour.rs b/protocols/dcutr/src/behaviour.rs index 49f479196f7..7c39f70bec0 100644 --- a/protocols/dcutr/src/behaviour.rs +++ b/protocols/dcutr/src/behaviour.rs @@ -315,6 +315,8 @@ impl NetworkBehaviour for Behaviour { .or_default() += 1; self.queued_events.push_back(ToSwarm::Dial { opts }); } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right(never) => void::unreachable(never), }; } diff --git a/protocols/dcutr/src/handler/relayed.rs b/protocols/dcutr/src/handler/relayed.rs index 30b769b0bd4..620c066c7ee 100644 --- a/protocols/dcutr/src/handler/relayed.rs +++ b/protocols/dcutr/src/handler/relayed.rs @@ -152,6 +152,8 @@ impl Handler { match output { future::Either::Left(stream) => self.set_stream(StreamType::Inbound, stream), // A connection listener denies all incoming substreams, thus none can ever be fully negotiated. + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] future::Either::Right(output) => void::unreachable(output), } } @@ -179,6 +181,8 @@ impl Handler { ::InboundProtocol, >, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(error.into_inner()); } @@ -190,6 +194,8 @@ impl Handler { >, ) { let error = match error { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(v) => void::unreachable(v), StreamUpgradeError::NegotiationFailed => outbound::Error::Unsupported, StreamUpgradeError::Io(e) => outbound::Error::Io(e), @@ -338,6 +344,8 @@ impl ConnectionHandler for Handler { ConnectionEvent::FullyNegotiatedOutbound(fully_negotiated_outbound) => { self.on_fully_negotiated_outbound(fully_negotiated_outbound) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(listen_upgrade_error) => { self.on_listen_upgrade_error(listen_upgrade_error) } diff --git a/protocols/gossipsub/src/handler.rs b/protocols/gossipsub/src/handler.rs index 88def13a521..8e3b3a8b022 100644 --- a/protocols/gossipsub/src/handler.rs +++ b/protocols/gossipsub/src/handler.rs @@ -493,6 +493,8 @@ impl ConnectionHandler for Handler { .. }) => match protocol { Either::Left(protocol) => handler.on_fully_negotiated_inbound(protocol), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right(v) => void::unreachable(v), }, ConnectionEvent::FullyNegotiatedOutbound(fully_negotiated_outbound) => { @@ -504,6 +506,8 @@ impl ConnectionHandler for Handler { }) => { tracing::debug!("Dial upgrade error: Protocol negotiation timeout"); } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::DialUpgradeError(DialUpgradeError { error: StreamUpgradeError::Apply(e), .. diff --git a/protocols/gossipsub/src/transform.rs b/protocols/gossipsub/src/transform.rs index 6f57d9fc46b..4831f9781b0 100644 --- a/protocols/gossipsub/src/transform.rs +++ b/protocols/gossipsub/src/transform.rs @@ -28,6 +28,7 @@ use crate::{Message, RawMessage, TopicHash}; /// A general trait of transforming a [`RawMessage`] into a [`Message`]. The +/// /// [`RawMessage`] is obtained from the wire and the [`Message`] is used to /// calculate the [`crate::MessageId`] of the message and is what is sent to the application. /// diff --git a/protocols/identify/CHANGELOG.md b/protocols/identify/CHANGELOG.md index 275f7114b28..c5778ff92ee 100644 --- a/protocols/identify/CHANGELOG.md +++ b/protocols/identify/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.45.1 + +- Add `hide_listen_addrs` option to prevent leaking (local) listen addresses. + See [PR 5507](https://github.com/libp2p/rust-libp2p/pull/5507). + ## 0.45.0 - Address translation is moved here from `libp2p-core`. diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index cdc5ce587de..c3fb585c99c 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-identify" edition = "2021" rust-version = { workspace = true } description = "Nodes identification protocol for libp2p" -version = "0.45.0" +version = "0.45.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/identify/src/behaviour.rs b/protocols/identify/src/behaviour.rs index 6590ccd6588..c8672674c1a 100644 --- a/protocols/identify/src/behaviour.rs +++ b/protocols/identify/src/behaviour.rs @@ -147,6 +147,12 @@ pub struct Config { /// /// Disabled by default. pub cache_size: usize, + + /// Whether to include our listen addresses in our responses. If enabled, + /// we will effectively only share our external addresses. + /// + /// Disabled by default. + pub hide_listen_addrs: bool, } impl Config { @@ -160,6 +166,7 @@ impl Config { interval: Duration::from_secs(5 * 60), push_listen_addr_updates: false, cache_size: 100, + hide_listen_addrs: false, } } @@ -189,6 +196,12 @@ impl Config { self.cache_size = cache_size; self } + + /// Configures whether we prevent sending out our listen addresses. + pub fn with_hide_listen_addrs(mut self, b: bool) -> Self { + self.hide_listen_addrs = b; + self + } } impl Behaviour { @@ -258,11 +271,11 @@ impl Behaviour { } fn all_addresses(&self) -> HashSet { - self.listen_addresses - .iter() - .chain(self.external_addresses.iter()) - .cloned() - .collect() + let mut addrs = HashSet::from_iter(self.external_addresses.iter().cloned()); + if !self.config.hide_listen_addrs { + addrs.extend(self.listen_addresses.iter().cloned()); + }; + addrs } fn emit_new_external_addr_candidate_event( diff --git a/protocols/identify/tests/smoke.rs b/protocols/identify/tests/smoke.rs index 49ae9f0726f..d624005408e 100644 --- a/protocols/identify/tests/smoke.rs +++ b/protocols/identify/tests/smoke.rs @@ -222,6 +222,77 @@ async fn emits_unique_listen_addresses() { assert!(reported_addrs.contains(&(swarm2_peer_id, swarm2_tcp_listen_addr))); } +#[async_std::test] +async fn hides_listen_addresses() { + let _ = tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .try_init(); + + let mut swarm1 = Swarm::new_ephemeral(|identity| { + identify::Behaviour::new( + identify::Config::new("a".to_string(), identity.public()) + .with_agent_version("b".to_string()) + .with_interval(Duration::from_secs(1)) + .with_cache_size(10), + ) + }); + let mut swarm2 = Swarm::new_ephemeral(|identity| { + identify::Behaviour::new( + identify::Config::new("c".to_string(), identity.public()) + .with_agent_version("d".to_string()) + .with_hide_listen_addrs(true), + ) + }); + + let (_swarm2_mem_listen_addr, swarm2_tcp_listen_addr) = + swarm2.listen().with_tcp_addr_external().await; + let swarm2_peer_id = *swarm2.local_peer_id(); + swarm1.connect(&mut swarm2).await; + + async_std::task::spawn(swarm2.loop_on_next()); + + let swarm_events = futures::stream::poll_fn(|cx| swarm1.poll_next_unpin(cx)) + .take(8) + .collect::>() + .await; + + let infos = swarm_events + .iter() + .filter_map(|e| match e { + SwarmEvent::Behaviour(identify::Event::Received { info, .. }) => Some(info.clone()), + _ => None, + }) + .collect::>(); + + assert!( + infos.len() > 1, + "should exchange identify payload more than once" + ); + + let listen_addrs = infos + .iter() + .map(|i| i.listen_addrs.clone()) + .collect::>(); + + for addrs in listen_addrs { + assert_eq!(addrs.len(), 1); + assert!(addrs.contains(&swarm2_tcp_listen_addr)); + } + + let reported_addrs = swarm_events + .iter() + .filter_map(|e| match e { + SwarmEvent::NewExternalAddrOfPeer { peer_id, address } => { + Some((*peer_id, address.clone())) + } + _ => None, + }) + .collect::>(); + + assert_eq!(reported_addrs.len(), 1, "To have one TCP address of remote"); + assert!(reported_addrs.contains(&(swarm2_peer_id, swarm2_tcp_listen_addr))); +} + #[async_std::test] async fn identify_push() { let _ = tracing_subscriber::fmt() diff --git a/protocols/kad/src/handler.rs b/protocols/kad/src/handler.rs index 5e7c2e21b8b..17c483da709 100644 --- a/protocols/kad/src/handler.rs +++ b/protocols/kad/src/handler.rs @@ -501,6 +501,8 @@ impl Handler { // is a `Void`. let protocol = match protocol { future::Either::Left(p) => p, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] future::Either::Right(p) => void::unreachable(p), }; diff --git a/protocols/perf/Dockerfile b/protocols/perf/Dockerfile index 1bd846cc228..f68ea6ef211 100644 --- a/protocols/perf/Dockerfile +++ b/protocols/perf/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.75.0 as builder +FROM rust:1.81.0 as builder # Run with access to the target cache to speed up builds WORKDIR /workspace diff --git a/protocols/perf/src/client/handler.rs b/protocols/perf/src/client/handler.rs index 2a2c5499fc2..55fafad7fcc 100644 --- a/protocols/perf/src/client/handler.rs +++ b/protocols/perf/src/client/handler.rs @@ -112,6 +112,8 @@ impl ConnectionHandler for Handler { >, ) { match event { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { protocol, .. }) => void::unreachable(protocol), @@ -144,6 +146,8 @@ impl ConnectionHandler for Handler { result: Err(error.into()), })); } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(ListenUpgradeError { info: (), error }) => { void::unreachable(error) } diff --git a/protocols/perf/src/server/handler.rs b/protocols/perf/src/server/handler.rs index ddfe8f881e5..4cb535a452c 100644 --- a/protocols/perf/src/server/handler.rs +++ b/protocols/perf/src/server/handler.rs @@ -73,6 +73,8 @@ impl ConnectionHandler for Handler { } fn on_behaviour_event(&mut self, v: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(v) } @@ -98,16 +100,22 @@ impl ConnectionHandler for Handler { tracing::warn!("Dropping inbound stream because we are at capacity"); } } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { info, .. }) => { void::unreachable(info) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::DialUpgradeError(DialUpgradeError { info, .. }) => { void::unreachable(info) } ConnectionEvent::AddressChange(_) | ConnectionEvent::LocalProtocolsChange(_) | ConnectionEvent::RemoteProtocolsChange(_) => {} + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(ListenUpgradeError { info: (), error }) => { void::unreachable(error) } diff --git a/protocols/ping/src/handler.rs b/protocols/ping/src/handler.rs index 2816cdc4048..7b36b2d4b3d 100644 --- a/protocols/ping/src/handler.rs +++ b/protocols/ping/src/handler.rs @@ -210,6 +210,8 @@ impl Handler { "ping protocol negotiation timed out", )), }, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(e) => void::unreachable(e), StreamUpgradeError::Io(e) => Failure::Other { error: Box::new(e) }, }; diff --git a/protocols/relay/src/behaviour.rs b/protocols/relay/src/behaviour.rs index 463febf9f2f..46419ae64e3 100644 --- a/protocols/relay/src/behaviour.rs +++ b/protocols/relay/src/behaviour.rs @@ -366,6 +366,8 @@ impl NetworkBehaviour for Behaviour { ) { let event = match event { Either::Left(e) => e, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right(v) => void::unreachable(v), }; diff --git a/protocols/relay/src/behaviour/handler.rs b/protocols/relay/src/behaviour/handler.rs index 92557287099..23e90f4b3f8 100644 --- a/protocols/relay/src/behaviour/handler.rs +++ b/protocols/relay/src/behaviour/handler.rs @@ -449,6 +449,8 @@ impl Handler { StreamUpgradeError::Timeout => outbound_stop::Error::Io(io::ErrorKind::TimedOut.into()), StreamUpgradeError::NegotiationFailed => outbound_stop::Error::Unsupported, StreamUpgradeError::Io(e) => outbound_stop::Error::Io(e), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(v) => void::unreachable(v), }; diff --git a/protocols/relay/src/priv_client.rs b/protocols/relay/src/priv_client.rs index f8d1d9c9eb2..8bbc813ec4c 100644 --- a/protocols/relay/src/priv_client.rs +++ b/protocols/relay/src/priv_client.rs @@ -236,6 +236,8 @@ impl NetworkBehaviour for Behaviour { ) { let handler_event = match handler_event { Either::Left(e) => e, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right(v) => void::unreachable(v), }; diff --git a/protocols/relay/src/priv_client/handler.rs b/protocols/relay/src/priv_client/handler.rs index 662d63cc742..05fdd5673ae 100644 --- a/protocols/relay/src/priv_client/handler.rs +++ b/protocols/relay/src/priv_client/handler.rs @@ -445,6 +445,8 @@ impl ConnectionHandler for Handler { let _ = next.send(Ok(ev.protocol)); } } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(ev) => void::unreachable(ev.error), ConnectionEvent::DialUpgradeError(ev) => { if let Some(next) = self.pending_streams.pop_front() { @@ -583,6 +585,8 @@ fn into_reserve_error(e: StreamUpgradeError) -> outbound_hop::ReserveError StreamUpgradeError::Timeout => { outbound_hop::ReserveError::Io(io::ErrorKind::TimedOut.into()) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(never) => void::unreachable(never), StreamUpgradeError::NegotiationFailed => outbound_hop::ReserveError::Unsupported, StreamUpgradeError::Io(e) => outbound_hop::ReserveError::Io(e), @@ -594,6 +598,8 @@ fn into_connect_error(e: StreamUpgradeError) -> outbound_hop::ConnectError StreamUpgradeError::Timeout => { outbound_hop::ConnectError::Io(io::ErrorKind::TimedOut.into()) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(never) => void::unreachable(never), StreamUpgradeError::NegotiationFailed => outbound_hop::ConnectError::Unsupported, StreamUpgradeError::Io(e) => outbound_hop::ConnectError::Io(e), diff --git a/protocols/request-response/src/cbor.rs b/protocols/request-response/src/cbor.rs index 44d82be2630..a27d069e758 100644 --- a/protocols/request-response/src/cbor.rs +++ b/protocols/request-response/src/cbor.rs @@ -143,6 +143,8 @@ mod codec { fn decode_into_io_error(err: cbor4ii::serde::DecodeError) -> io::Error { match err { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] cbor4ii::serde::DecodeError::Core(DecodeError::Read(e)) => { io::Error::new(io::ErrorKind::Other, e) } diff --git a/protocols/request-response/src/handler.rs b/protocols/request-response/src/handler.rs index f0467593f85..0591b37dc30 100644 --- a/protocols/request-response/src/handler.rs +++ b/protocols/request-response/src/handler.rs @@ -240,6 +240,8 @@ where self.pending_events .push_back(Event::OutboundUnsupportedProtocols(message.request_id)); } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(e) => void::unreachable(e), StreamUpgradeError::Io(e) => { self.pending_events.push_back(Event::OutboundStreamFailed { @@ -256,6 +258,8 @@ where ::InboundProtocol, >, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(error) } } @@ -484,6 +488,8 @@ where ConnectionEvent::DialUpgradeError(dial_upgrade_error) => { self.on_dial_upgrade_error(dial_upgrade_error) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(listen_upgrade_error) => { self.on_listen_upgrade_error(listen_upgrade_error) } diff --git a/protocols/stream/src/handler.rs b/protocols/stream/src/handler.rs index f63b93c1761..bf80e30c3c6 100644 --- a/protocols/stream/src/handler.rs +++ b/protocols/stream/src/handler.rs @@ -96,6 +96,8 @@ impl ConnectionHandler for Handler { } fn on_behaviour_event(&mut self, event: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } @@ -143,6 +145,8 @@ impl ConnectionHandler for Handler { swarm::StreamUpgradeError::Timeout => { OpenStreamError::Io(io::Error::from(io::ErrorKind::TimedOut)) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] swarm::StreamUpgradeError::Apply(v) => void::unreachable(v), swarm::StreamUpgradeError::NegotiationFailed => { OpenStreamError::UnsupportedProtocol(p) diff --git a/scripts/build-interop-image.sh b/scripts/build-interop-image.sh index 28a8db9188d..ad6ef78b153 100755 --- a/scripts/build-interop-image.sh +++ b/scripts/build-interop-image.sh @@ -6,13 +6,13 @@ CACHE_TO="" # If we have credentials, write to cache if [[ -n "${AWS_SECRET_ACCESS_KEY}" ]]; then - CACHE_TO="--cache-to type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=${FLAVOUR}-rust-libp2p-head" + CACHE_TO="--cache-to type=s3,mode=max,bucket=${AWS_BUCKET_NAME},region=us-east-1,prefix=buildCache,name=${FLAVOUR}-rust-libp2p-head" fi docker buildx build \ --load \ $CACHE_TO \ - --cache-from type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=${FLAVOUR}-rust-libp2p-head \ + --cache-from type=s3,mode=max,bucket=${AWS_BUCKET_NAME},region=us-east-1,prefix=buildCache,name=${FLAVOUR}-rust-libp2p-head \ -t ${FLAVOUR}-rust-libp2p-head \ . \ -f interop-tests/Dockerfile.${FLAVOUR} diff --git a/swarm/src/behaviour/toggle.rs b/swarm/src/behaviour/toggle.rs index 398c919ae86..5d72534c91e 100644 --- a/swarm/src/behaviour/toggle.rs +++ b/swarm/src/behaviour/toggle.rs @@ -210,6 +210,8 @@ where ) { let out = match out { future::Either::Left(out) => out, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] future::Either::Right(v) => void::unreachable(v), }; @@ -251,6 +253,8 @@ where let err = match err { Either::Left(e) => e, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right(v) => void::unreachable(v), }; diff --git a/swarm/src/connection.rs b/swarm/src/connection.rs index 603a5b0d7c4..2f9afc38418 100644 --- a/swarm/src/connection.rs +++ b/swarm/src/connection.rs @@ -1189,10 +1189,14 @@ mod tests { >, ) { match event { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { protocol, .. }) => void::unreachable(protocol), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { protocol, .. @@ -1200,6 +1204,8 @@ mod tests { ConnectionEvent::DialUpgradeError(DialUpgradeError { error, .. }) => { self.error = Some(error) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::AddressChange(_) | ConnectionEvent::ListenUpgradeError(_) | ConnectionEvent::LocalProtocolsChange(_) @@ -1208,6 +1214,8 @@ mod tests { } fn on_behaviour_event(&mut self, event: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } @@ -1283,6 +1291,8 @@ mod tests { } fn on_behaviour_event(&mut self, event: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } diff --git a/swarm/src/connection/pool/task.rs b/swarm/src/connection/pool/task.rs index 08674fd2ee5..13977a17b85 100644 --- a/swarm/src/connection/pool/task.rs +++ b/swarm/src/connection/pool/task.rs @@ -105,6 +105,8 @@ pub(crate) async fn new_for_pending_outgoing_connection( }) .await; } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Left((Ok(v), _)) => void::unreachable(v), Either::Right((Ok((address, output, errors)), _)) => { let _ = events @@ -143,6 +145,8 @@ pub(crate) async fn new_for_pending_incoming_connection( }) .await; } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Left((Ok(v), _)) => void::unreachable(v), Either::Right((Ok(output), _)) => { let _ = events diff --git a/swarm/src/dummy.rs b/swarm/src/dummy.rs index 6e1b4d56eb9..0bd8c06862d 100644 --- a/swarm/src/dummy.rs +++ b/swarm/src/dummy.rs @@ -49,6 +49,8 @@ impl NetworkBehaviour for Behaviour { _: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } @@ -76,6 +78,8 @@ impl crate::handler::ConnectionHandler for ConnectionHandler { } fn on_behaviour_event(&mut self, event: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } @@ -98,19 +102,29 @@ impl crate::handler::ConnectionHandler for ConnectionHandler { >, ) { match event { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { protocol, .. }) => void::unreachable(protocol), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { protocol, .. }) => void::unreachable(protocol), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::DialUpgradeError(DialUpgradeError { info: _, error }) => match error { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Timeout => unreachable!(), StreamUpgradeError::Apply(e) => void::unreachable(e), StreamUpgradeError::NegotiationFailed | StreamUpgradeError::Io(_) => { unreachable!("Denied upgrade does not support any protocols") } }, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::AddressChange(_) | ConnectionEvent::ListenUpgradeError(_) | ConnectionEvent::LocalProtocolsChange(_) diff --git a/swarm/src/handler/pending.rs b/swarm/src/handler/pending.rs index 23b9adcfd90..9601f5cf78b 100644 --- a/swarm/src/handler/pending.rs +++ b/swarm/src/handler/pending.rs @@ -52,6 +52,8 @@ impl ConnectionHandler for PendingConnectionHandler { } fn on_behaviour_event(&mut self, v: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(v) } @@ -74,9 +76,13 @@ impl ConnectionHandler for PendingConnectionHandler { >, ) { match event { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { protocol, .. }) => void::unreachable(protocol), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { protocol, info: _info, @@ -87,6 +93,8 @@ impl ConnectionHandler for PendingConnectionHandler { void::unreachable(_info); } } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::AddressChange(_) | ConnectionEvent::DialUpgradeError(_) | ConnectionEvent::ListenUpgradeError(_) diff --git a/swarm/src/upgrade.rs b/swarm/src/upgrade.rs index 53b627458c9..f6c6648a373 100644 --- a/swarm/src/upgrade.rs +++ b/swarm/src/upgrade.rs @@ -121,6 +121,7 @@ where } /// Wraps around a type that implements [`OutboundUpgradeSend`], [`InboundUpgradeSend`], or +/// /// both, and implements [`OutboundUpgrade`](upgrade::OutboundUpgrade) and/or /// [`InboundUpgrade`](upgrade::InboundUpgrade). /// diff --git a/swarm/tests/swarm_derive.rs b/swarm/tests/swarm_derive.rs index 919ed0cab7f..667f68408cf 100644 --- a/swarm/tests/swarm_derive.rs +++ b/swarm/tests/swarm_derive.rs @@ -577,6 +577,8 @@ fn custom_out_event_no_type_parameters() { _connection: ConnectionId, message: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(message); } diff --git a/transports/quic/src/hole_punching.rs b/transports/quic/src/hole_punching.rs index 605799af5e1..a38d123a6a4 100644 --- a/transports/quic/src/hole_punching.rs +++ b/transports/quic/src/hole_punching.rs @@ -20,6 +20,8 @@ pub(crate) async fn hole_puncher( match futures::future::select(P::sleep(timeout_duration), punch_holes_future).await { Either::Left(_) => Error::HandshakeTimedOut, Either::Right((Err(hole_punch_err), _)) => hole_punch_err, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right((Ok(never), _)) => match never {}, } }