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(websocket): don't dial /dnsaddr addresses #5613

Merged
merged 9 commits into from
Nov 5, 2024
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.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ libp2p-upnp = { version = "0.3.0", path = "protocols/upnp" }
libp2p-webrtc = { version = "0.8.0-alpha", path = "transports/webrtc" }
libp2p-webrtc-utils = { version = "0.3.0", path = "misc/webrtc-utils" }
libp2p-webrtc-websys = { version = "0.4.0-alpha.2", path = "transports/webrtc-websys" }
libp2p-websocket = { version = "0.44.0", path = "transports/websocket" }
libp2p-websocket = { version = "0.44.1", path = "transports/websocket" }
libp2p-websocket-websys = { version = "0.4.0", path = "transports/websocket-websys" }
libp2p-webtransport-websys = { version = "0.4.0", path = "transports/webtransport-websys" }
libp2p-yamux = { version = "0.46.0", path = "muxers/yamux" }
Expand Down Expand Up @@ -151,4 +151,8 @@ clippy.manual_let_else = "warn"
clippy.dbg_macro = "warn"

[workspace.metadata.release]
pre-release-hook = ["/bin/sh", '-c', '/bin/sh $WORKSPACE_ROOT/scripts/add-changelog-header.sh'] # Nested use of shell to expand variables.
pre-release-hook = [
"/bin/sh",
'-c',
'/bin/sh $WORKSPACE_ROOT/scripts/add-changelog-header.sh',
] # Nested use of shell to expand variables.
zetsuboii marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions transports/websocket/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.44.1

- fix: Return `Error::InvalidMultiaddr` when dialed to a `/dnsaddr` address
See [PR 5613](https://github.com/libp2p/rust-libp2p/pull/5613)

## 0.44.0

- Implement refactored `Transport`.
Expand Down
2 changes: 1 addition & 1 deletion transports/websocket/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-websocket"
edition = "2021"
rust-version = { workspace = true }
description = "WebSocket transport for libp2p"
version = "0.44.0"
version = "0.44.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
9 changes: 7 additions & 2 deletions transports/websocket/src/framed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,7 @@ fn parse_ws_dial_addr<T>(addr: Multiaddr) -> Result<WsAddress, Error<T>> {
}
(Some(Protocol::Dns(h)), Some(Protocol::Tcp(port)))
| (Some(Protocol::Dns4(h)), Some(Protocol::Tcp(port)))
| (Some(Protocol::Dns6(h)), Some(Protocol::Tcp(port)))
| (Some(Protocol::Dnsaddr(h)), Some(Protocol::Tcp(port))) => {
| (Some(Protocol::Dns6(h)), Some(Protocol::Tcp(port))) => {
break (format!("{h}:{port}"), tls::dns_name_ref(&h)?)
}
(Some(_), Some(p)) => {
Expand Down Expand Up @@ -993,6 +992,12 @@ mod tests {
assert_eq!(info.server_name, "::1".try_into().unwrap());
assert_eq!(info.tcp_addr, "/ip6/::1/tcp/2222".parse().unwrap());

// Check `/dnsaddr`
let addr = "/dnsaddr/example.com/tcp/2222/ws"
.parse::<Multiaddr>()
.unwrap();
parse_ws_dial_addr::<io::Error>(addr).unwrap_err();

// Check non-ws address
let addr = "/ip4/127.0.0.1/tcp/2222".parse::<Multiaddr>().unwrap();
parse_ws_dial_addr::<io::Error>(addr).unwrap_err();
Expand Down
Loading