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

fix(autonat): reject inbound dial request from peer if its not connected #5597

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ 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.0", path = "protocols/dcutr" }
Expand Down
3 changes: 3 additions & 0 deletions protocols/autonat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.13.1
Eligioo marked this conversation as resolved.
Show resolved Hide resolved
- 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
Expand Down
2 changes: 1 addition & 1 deletion protocols/autonat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>", "Elena Frank <[email protected]>", "Hannes Furmans <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
15 changes: 15 additions & 0 deletions protocols/autonat/src/v1/behaviour/as_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
Loading