From 89ee0a0b74f197a9f6231a30cdd1f3c5bb0cda45 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 21 Mar 2023 11:38:04 +0100 Subject: [PATCH] Rename /webrtc to /webrtc-direct (#326) * Rename /webrtc to /webrtc-direct * CHANGELOG link --- lib/src/libp2p/multiaddr.rs | 14 +++++++------- wasm-node/CHANGELOG.md | 1 + wasm-node/javascript/src/index-browser.ts | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/src/libp2p/multiaddr.rs b/lib/src/libp2p/multiaddr.rs index 19914aef48..a48c8c4472 100644 --- a/lib/src/libp2p/multiaddr.rs +++ b/lib/src/libp2p/multiaddr.rs @@ -210,7 +210,7 @@ pub enum ProtocolRef<'a> { Wss, // TODO: unclear what the payload is; see https://github.com/multiformats/multiaddr/issues/127 Memory(u64), - WebRTC, + WebRtcDirect, /// Contains the multihash of the TLS certificate. Certhash(Cow<'a, [u8]>), // TODO: a bit hacky because there's no "owned" equivalent to MultihashRef } @@ -280,7 +280,7 @@ impl<'a> ProtocolRef<'a> { .map_err(|_| ParseError::InvalidMemoryPayload)?, )) } - "webrtc" => Ok(ProtocolRef::WebRTC), + "webrtc-direct" => Ok(ProtocolRef::WebRtcDirect), "certhash" => { let s = iter.next().ok_or(ParseError::UnexpectedEof)?; // See @@ -321,7 +321,7 @@ impl<'a> ProtocolRef<'a> { ProtocolRef::Ws => 477, ProtocolRef::Wss => 478, ProtocolRef::Memory(_) => 777, - ProtocolRef::WebRTC => 280, + ProtocolRef::WebRtcDirect => 280, ProtocolRef::Certhash(_) => 466, }; @@ -386,7 +386,7 @@ impl<'a> fmt::Display for ProtocolRef<'a> { ProtocolRef::Ws => write!(f, "/ws"), ProtocolRef::Wss => write!(f, "/wss"), ProtocolRef::Memory(payload) => write!(f, "/memory/{}", payload), - ProtocolRef::WebRTC => write!(f, "/webrtc"), + ProtocolRef::WebRtcDirect => write!(f, "/webrtc-direct"), ProtocolRef::Certhash(multihash) => { write!( f, @@ -529,7 +529,7 @@ fn protocol<'a, E: nom::error::ParseError<&'a [u8]>>( 478 => Ok((bytes, ProtocolRef::Wss)), // TODO: unclear what the /memory payload is, see https://github.com/multiformats/multiaddr/issues/127 777 => nom::combinator::map(nom::number::complete::be_u64, ProtocolRef::Memory)(bytes), - 280 => Ok((bytes, ProtocolRef::WebRTC)), + 280 => Ok((bytes, ProtocolRef::WebRtcDirect)), 466 => nom::combinator::map( nom::combinator::verify( nom::multi::length_data(crate::util::leb128::nom_leb128_usize), @@ -580,7 +580,7 @@ mod tests { check_valid("/dns6//tcp/55"); check_valid("/dnsaddr/./tcp/55"); check_valid("/memory/1234567890"); - check_valid("/webrtc"); + check_valid("/webrtc-direct"); // TODO: example valid /certhash check_invalid("/"); @@ -591,7 +591,7 @@ mod tests { check_invalid("/ws/1.2.3.4"); check_invalid("/tcp/65536"); check_invalid("/p2p/blablabla"); - check_invalid("/webrtc/2"); + check_invalid("/webrtc-direct/2"); check_invalid("/certhash"); check_invalid("/certhash/12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN"); } diff --git a/wasm-node/CHANGELOG.md b/wasm-node/CHANGELOG.md index dcabe4a022..a47bc79896 100644 --- a/wasm-node/CHANGELOG.md +++ b/wasm-node/CHANGELOG.md @@ -6,6 +6,7 @@ - No longer panic when a libp2p networking request emitted by smoldot exceeds the maximum size allowed by the protocol. Instead, either a warning is printed (similar to consensus-related issues) or a JSON-RPC error is returned. ([#318](https://github.com/smol-dot/smoldot/pull/318)) - Add an arbitrary limit to the size of unprocessed networking packets, in order to avoid DoS attacks. This limit is necessary in order to bypass limitations in the networking APIs exposed by browsers. ([#312](https://github.com/smol-dot/smoldot/pull/312)) +- Rename `/webrtc` to `/webrtc-direct` in multiaddresses, in accordance with the rest of the libp2p ecosystem. ([#326](https://github.com/smol-dot/smoldot/pull/326)) ## 1.0.0 - 2022-03-12 diff --git a/wasm-node/javascript/src/index-browser.ts b/wasm-node/javascript/src/index-browser.ts index 87df7efaec..a26ca622bd 100644 --- a/wasm-node/javascript/src/index-browser.ts +++ b/wasm-node/javascript/src/index-browser.ts @@ -87,7 +87,7 @@ export function start(options?: ClientOptions): Client { // TODO: remove support for `/wss` in a long time (https://github.com/paritytech/smoldot/issues/1940) const wsParsed = config.address.match(/^\/(ip4|ip6|dns4|dns6|dns)\/(.*?)\/tcp\/(.*?)\/(ws|wss|tls\/ws)$/); - const webRTCParsed = config.address.match(/^\/(ip4|ip6)\/(.*?)\/udp\/(.*?)\/webrtc\/certhash\/(.*?)$/); + const webRTCParsed = config.address.match(/^\/(ip4|ip6)\/(.*?)\/udp\/(.*?)\/webrtc-direct\/certhash\/(.*?)$/); if (wsParsed != null) { let connection: WebSocket;