From 5a095fec81069c13c5efdea7dd56b5e1215c9f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Duarte?= Date: Wed, 25 Jun 2025 15:48:38 +0100 Subject: [PATCH 1/3] Mark Protocol::Wss as deprecated --- src/protocol.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/protocol.rs b/src/protocol.rs index f0fa1d4..8d7eff1 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -121,6 +121,7 @@ pub enum Protocol<'a> { Utp, WebTransport, Ws(Cow<'a, str>), + #[deprecated] Wss(Cow<'a, str>), Ip6zone(Cow<'a, str>), Ipcidr(u8), From 6a31479017a72b2974617556b18122aa813f8518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Duarte?= Date: Wed, 25 Jun 2025 16:00:25 +0100 Subject: [PATCH 2/3] Add allow(deprecated) --- src/from_url.rs | 7 ++++++- src/protocol.rs | 28 ++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/from_url.rs b/src/from_url.rs index ce5ae6d..8900546 100644 --- a/src/from_url.rs +++ b/src/from_url.rs @@ -68,7 +68,12 @@ fn from_url_inner_http_ws( ) -> std::result::Result { let (protocol, lost_path, default_port) = match url.scheme() { "ws" => (Protocol::Ws(url.path().to_owned().into()), false, 80), - "wss" => (Protocol::Wss(url.path().to_owned().into()), false, 443), + "wss" => ( + #[allow(deprecated)] + Protocol::Wss(url.path().to_owned().into()), + false, + 443, + ), "http" => (Protocol::Http, true, 80), "https" => (Protocol::Https, true, 443), _ => unreachable!("We only call this function for one of the given schemes; qed"), diff --git a/src/protocol.rs b/src/protocol.rs index 8d7eff1..e491356 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -216,7 +216,10 @@ impl<'a> Protocol<'a> { "quic-v1" => Ok(Protocol::QuicV1), "webtransport" => Ok(Protocol::WebTransport), "ws" => Ok(Protocol::Ws(Cow::Borrowed("/"))), - "wss" => Ok(Protocol::Wss(Cow::Borrowed("/"))), + "wss" => Ok( + #[allow(deprecated)] + Protocol::Wss(Cow::Borrowed("/")), + ), "x-parity-ws" => { let s = iter.next().ok_or(Error::InvalidProtocolString)?; let decoded = percent_encoding::percent_decode(s.as_bytes()).decode_utf8()?; @@ -225,7 +228,10 @@ impl<'a> Protocol<'a> { "x-parity-wss" => { let s = iter.next().ok_or(Error::InvalidProtocolString)?; let decoded = percent_encoding::percent_decode(s.as_bytes()).decode_utf8()?; - Ok(Protocol::Wss(decoded)) + Ok( + #[allow(deprecated)] + Protocol::Wss(decoded), + ) } "p2p-websocket-star" => Ok(Protocol::P2pWebSocketStar), "p2p-webrtc-star" => Ok(Protocol::P2pWebRtcStar), @@ -430,11 +436,19 @@ impl<'a> Protocol<'a> { let (data, rest) = split_at(n, input)?; Ok((Protocol::Ws(Cow::Borrowed(str::from_utf8(data)?)), rest)) } - WSS => Ok((Protocol::Wss(Cow::Borrowed("/")), input)), + WSS => Ok(( + #[allow(deprecated)] + Protocol::Wss(Cow::Borrowed("/")), + input, + )), WSS_WITH_PATH => { let (n, input) = decode::usize(input)?; let (data, rest) = split_at(n, input)?; - Ok((Protocol::Wss(Cow::Borrowed(str::from_utf8(data)?)), rest)) + Ok(( + #[allow(deprecated)] + Protocol::Wss(Cow::Borrowed(str::from_utf8(data)?)), + rest, + )) } IP6ZONE => { let (n, input) = decode::usize(input)?; @@ -570,7 +584,9 @@ impl<'a> Protocol<'a> { w.write_all(encode::usize(bytes.len(), &mut encode::usize_buffer()))?; w.write_all(bytes)? } + #[allow(deprecated)] Protocol::Wss(ref s) if s == "/" => w.write_all(encode::u32(WSS, &mut buf))?, + #[allow(deprecated)] Protocol::Wss(s) => { w.write_all(encode::u32(WSS_WITH_PATH, &mut buf))?; let bytes = s.as_bytes(); @@ -665,6 +681,7 @@ impl<'a> Protocol<'a> { Utp => Utp, WebTransport => WebTransport, Ws(cow) => Ws(Cow::Owned(cow.into_owned())), + #[allow(deprecated)] Wss(cow) => Wss(Cow::Owned(cow.into_owned())), Ip6zone(cow) => Ip6zone(Cow::Owned(cow.into_owned())), Ipcidr(mask) => Ipcidr(mask), @@ -712,7 +729,9 @@ impl<'a> Protocol<'a> { WebTransport => "webtransport", Ws(ref s) if s == "/" => "ws", Ws(_) => "x-parity-ws", + #[allow(deprecated)] Wss(ref s) if s == "/" => "wss", + #[allow(deprecated)] Wss(_) => "x-parity-wss", Ip6zone(_) => "ip6zone", Ipcidr(_) => "ipcidr", @@ -762,6 +781,7 @@ impl fmt::Display for Protocol<'_> { percent_encoding::percent_encode(s.as_bytes(), PATH_SEGMENT_ENCODE_SET); write!(f, "/{encoded}") } + #[allow(deprecated)] Wss(s) if s != "/" => { let encoded = percent_encoding::percent_encode(s.as_bytes(), PATH_SEGMENT_ENCODE_SET); From 665443960423c7312dd86d6dfe66d59f24a8e143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Duarte?= Date: Thu, 26 Jun 2025 09:21:49 +0100 Subject: [PATCH 3/3] #[allow(deprecate)] on tests --- tests/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/lib.rs b/tests/lib.rs index 936809e..cabf633 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -148,7 +148,10 @@ impl Arbitrary for Proto { 28 => Proto(Utp), 29 => Proto(WebTransport), 30 => Proto(Ws("/".into())), - 31 => Proto(Wss("/".into())), + 31 => Proto( + #[allow(deprecated)] + Wss("/".into()), + ), 32 => Proto(Ip6zone(Cow::Owned(SubString::arbitrary(g).0))), 33 => Proto(Ipcidr(Arbitrary::arbitrary(g))), 34 => { @@ -367,7 +370,7 @@ fn construct_success() { ]); ma_valid("/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/tcp/8000/wss/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC", "29200108A07AC542013AC986FFFE317095061F40DE03A503221220D52EBB89D85B02A284948203A62FF28389C57C9F42BEEC4EC20DB76A68911C0B", - vec![Ip6(addr6), Tcp(8000), Wss("/".into()), P2p(peer_id("QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC"))]); + vec![Ip6(addr6), Tcp(8000), #[allow(deprecated)] Wss("/".into()), P2p(peer_id("QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC"))]); ma_valid("/ip4/127.0.0.1/tcp/9090/p2p-circuit/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC", "047F000001062382A202A503221220D52EBB89D85B02A284948203A62FF28389C57C9F42BEEC4EC20DB76A68911C0B", vec![Ip4(local), Tcp(9090), P2pCircuit, P2p(peer_id("QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC"))]);