diff --git a/Cargo.lock b/Cargo.lock index c0ada652504..8a6278717f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3432,7 +3432,7 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.44.0" +version = "0.44.1" dependencies = [ "async-std", "either", @@ -3455,7 +3455,7 @@ dependencies = [ [[package]] name = "libp2p-websocket-websys" -version = "0.4.0" +version = "0.4.1" dependencies = [ "bytes", "futures", diff --git a/Cargo.toml b/Cargo.toml index 8869505921d..780d26240db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,8 +112,8 @@ libp2p-upnp = { version = "0.3.1", 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-websys = { version = "0.4.0", path = "transports/websocket-websys" } +libp2p-websocket = { version = "0.44.1", path = "transports/websocket" } +libp2p-websocket-websys = { version = "0.4.1", path = "transports/websocket-websys" } libp2p-webtransport-websys = { version = "0.4.0", path = "transports/webtransport-websys" } libp2p-yamux = { version = "0.46.0", path = "muxers/yamux" } multiaddr = "0.18.1" diff --git a/transports/websocket-websys/CHANGELOG.md b/transports/websocket-websys/CHANGELOG.md index d0aeb509823..9d0cb7d7726 100644 --- a/transports/websocket-websys/CHANGELOG.md +++ b/transports/websocket-websys/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.1 + +- fix: Return `None` when extracting a `/dnsaddr` address + See [PR 5613](https://github.com/libp2p/rust-libp2p/pull/5613) + ## 0.4.0 - Implement refactored `Transport`. diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 32483f28c57..1687d3c0fb5 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-websocket-websys" edition = "2021" rust-version = "1.60.0" description = "WebSocket for libp2p under WASM environment" -version = "0.4.0" +version = "0.4.1" authors = ["Vince Vasta "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/websocket-websys/src/lib.rs b/transports/websocket-websys/src/lib.rs index 3467e802bc5..17b07c71c0a 100644 --- a/transports/websocket-websys/src/lib.rs +++ b/transports/websocket-websys/src/lib.rs @@ -130,8 +130,7 @@ fn extract_websocket_url(addr: &Multiaddr) -> Option { } (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))) => { format!("{}:{}", &h, port) } _ => return None, @@ -549,6 +548,12 @@ mod tests { .unwrap(); assert!(extract_websocket_url(&addr).is_none()); + // Check `/dnsaddr` + let addr = "/dnsaddr/example.com/tcp/2222/ws" + .parse::() + .unwrap(); + assert!(extract_websocket_url(&addr).is_none()); + // Check non-ws address let addr = "/ip4/127.0.0.1/tcp/2222".parse::().unwrap(); assert!(extract_websocket_url(&addr).is_none()); diff --git a/transports/websocket/CHANGELOG.md b/transports/websocket/CHANGELOG.md index cd079cfdd5a..1a8e9569c06 100644 --- a/transports/websocket/CHANGELOG.md +++ b/transports/websocket/CHANGELOG.md @@ -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`. diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index e08346da5ca..07f84901eda 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -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 "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/websocket/src/framed.rs b/transports/websocket/src/framed.rs index 198443508d9..259be6a68f8 100644 --- a/transports/websocket/src/framed.rs +++ b/transports/websocket/src/framed.rs @@ -510,8 +510,7 @@ fn parse_ws_dial_addr(addr: Multiaddr) -> Result> { } (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)) => { @@ -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::() + .unwrap(); + parse_ws_dial_addr::(addr).unwrap_err(); + // Check non-ws address let addr = "/ip4/127.0.0.1/tcp/2222".parse::().unwrap(); parse_ws_dial_addr::(addr).unwrap_err();