Skip to content

Commit

Permalink
Rename /webrtc to /webrtc-direct (#326)
Browse files Browse the repository at this point in the history
* Rename /webrtc to /webrtc-direct

* CHANGELOG link
  • Loading branch information
tomaka authored Mar 21, 2023
1 parent c1a7e2e commit 89ee0a0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/src/libp2p/multiaddr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 <https://github.com/multiformats/multibase#multibase-table>
Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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("/");
Expand All @@ -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");
}
Expand Down
1 change: 1 addition & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion wasm-node/javascript/src/index-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 89ee0a0

Please sign in to comment.