diff --git a/Cargo.lock b/Cargo.lock index 4554147f4e4..4c739c2f5ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3450,7 +3450,7 @@ dependencies = [ [[package]] name = "libp2p-websocket-websys" -version = "0.3.1" +version = "0.3.2" dependencies = [ "bytes", "futures", diff --git a/Cargo.toml b/Cargo.toml index b6508a3d3f2..ce33cec2ba0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,7 +112,7 @@ libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.2.0", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" } libp2p-websocket = { version = "0.43.0", path = "transports/websocket" } -libp2p-websocket-websys = { version = "0.3.1", path = "transports/websocket-websys" } +libp2p-websocket-websys = { version = "0.3.2", path = "transports/websocket-websys" } libp2p-webtransport-websys = { version = "0.2.0", path = "transports/webtransport-websys" } libp2p-yamux = { version = "0.45.1", path = "muxers/yamux" } multiaddr = "0.18.1" diff --git a/transports/websocket-websys/CHANGELOG.md b/transports/websocket-websys/CHANGELOG.md index 3cfb1b2fbf9..f92b76ebeaa 100644 --- a/transports/websocket-websys/CHANGELOG.md +++ b/transports/websocket-websys/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.3.2 + +- Change close code in drop implementation to `1000` given that in browsers only + the code `1000` and codes between `3000` and `4999` are allowed to be set by + userland code. + See [PR 5229](https://github.com/libp2p/rust-libp2p/pull/5229). + ## 0.3.1 - Add support for different WASM environments by introducing a `WebContext` that diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 5855b582c80..c73c753e7b4 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.3.1" +version = "0.3.2" 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 02b6bc837eb..ca56d5727a5 100644 --- a/transports/websocket-websys/src/lib.rs +++ b/transports/websocket-websys/src/lib.rs @@ -434,13 +434,14 @@ impl AsyncWrite for Connection { impl Drop for Connection { fn drop(&mut self) { - const GO_AWAY_STATUS_CODE: u16 = 1001; // See https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1. + // In browsers, userland code is not allowed to use any other status code than 1000: https://websockets.spec.whatwg.org/#dom-websocket-close + const REGULAR_CLOSE: u16 = 1000; // See https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1. if let ReadyState::Connecting | ReadyState::Open = self.inner.ready_state() { let _ = self .inner .socket - .close_with_code_and_reason(GO_AWAY_STATUS_CODE, "connection dropped"); + .close_with_code_and_reason(REGULAR_CLOSE, "connection dropped"); } WebContext::new()