Skip to content

Commit

Permalink
fix: Rename /webrtc to /webrtc-direct
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Mar 17, 2023
1 parent 3d247d7 commit 4cd7ee5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.18.0 - unreleased

- Rename `/webrtc` to `/webrt-direct`. See [multiformats/multiaddr discussion] for context. **Note that this is a breaking change.**

[multiformats/multiaddr discussion]: https://github.com/multiformats/multiaddr/pull/150#issuecomment-1468791586

# 0.17.0

- Update to multihash `v0.17`. See [PR 63].
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["multiaddr", "ipfs"]
license = "MIT"
name = "multiaddr"
readme = "README.md"
version = "0.17.0"
version = "0.18.0"

[features]
default = ["url"]
Expand Down
14 changes: 7 additions & 7 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const IP4: u32 = 4;
const IP6: u32 = 41;
const P2P_WEBRTC_DIRECT: u32 = 276;
const P2P_WEBRTC_STAR: u32 = 275;
const WEBRTC: u32 = 280;
const WEBRTC_DIRECT: u32 = 280;
const CERTHASH: u32 = 466;
const P2P_WEBSOCKET_STAR: u32 = 479;
const MEMORY: u32 = 777;
Expand Down Expand Up @@ -83,7 +83,7 @@ pub enum Protocol<'a> {
Ip6(Ipv6Addr),
P2pWebRtcDirect,
P2pWebRtcStar,
WebRTC,
WebRTCDirect,
Certhash(Multihash),
P2pWebSocketStar,
/// Contains the "port" to contact. Similar to TCP or UDP, 0 means "assign me a port".
Expand Down Expand Up @@ -199,7 +199,7 @@ impl<'a> Protocol<'a> {
}
"p2p-websocket-star" => Ok(Protocol::P2pWebSocketStar),
"p2p-webrtc-star" => Ok(Protocol::P2pWebRtcStar),
"webrtc" => Ok(Protocol::WebRTC),
"webrtc-direct" => Ok(Protocol::WebRTCDirect),
"certhash" => {
let s = iter.next().ok_or(Error::InvalidProtocolString)?;
let (_base, decoded) = multibase::decode(s)?;
Expand Down Expand Up @@ -281,7 +281,7 @@ impl<'a> Protocol<'a> {
}
P2P_WEBRTC_DIRECT => Ok((Protocol::P2pWebRtcDirect, input)),
P2P_WEBRTC_STAR => Ok((Protocol::P2pWebRtcStar, input)),
WEBRTC => Ok((Protocol::WebRTC, input)),
WEBRTC_DIRECT => Ok((Protocol::WebRTCDirect, input)),
CERTHASH => {
let (n, input) = decode::usize(input)?;
let (data, rest) = split_at(n, input)?;
Expand Down Expand Up @@ -462,7 +462,7 @@ impl<'a> Protocol<'a> {
}
Protocol::P2pWebSocketStar => w.write_all(encode::u32(P2P_WEBSOCKET_STAR, &mut buf))?,
Protocol::P2pWebRtcStar => w.write_all(encode::u32(P2P_WEBRTC_STAR, &mut buf))?,
Protocol::WebRTC => w.write_all(encode::u32(WEBRTC, &mut buf))?,
Protocol::WebRTCDirect => w.write_all(encode::u32(WEBRTC_DIRECT, &mut buf))?,
Protocol::Certhash(hash) => {
w.write_all(encode::u32(CERTHASH, &mut buf))?;
let bytes = hash.to_bytes();
Expand Down Expand Up @@ -494,7 +494,7 @@ impl<'a> Protocol<'a> {
Ip6(a) => Ip6(a),
P2pWebRtcDirect => P2pWebRtcDirect,
P2pWebRtcStar => P2pWebRtcStar,
WebRTC => WebRTC,
WebRTCDirect => WebRTCDirect,
Certhash(hash) => Certhash(hash),
P2pWebSocketStar => P2pWebSocketStar,
Memory(a) => Memory(a),
Expand Down Expand Up @@ -531,7 +531,7 @@ impl<'a> Protocol<'a> {
Ip6(_) => "ip6",
P2pWebRtcDirect => "p2p-webrtc-direct",
P2pWebRtcStar => "p2p-webrtc-star",
WebRTC => "webrtc",
WebRTCDirect => "webrtc-direct",
Certhash(_) => "certhash",
P2pWebSocketStar => "p2p-websocket-star",
Memory(_) => "memory",
Expand Down
16 changes: 8 additions & 8 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,20 +342,20 @@ fn construct_success() {
);

ma_valid(
"/ip4/127.0.0.1/udp/1234/webrtc",
"/ip4/127.0.0.1/udp/1234/webrtc-direct",
"047F000001910204D29802",
vec![Ip4(local), Udp(1234), WebRTC],
vec![Ip4(local), Udp(1234), WebRTCDirect],
);

let (_base, decoded) =
multibase::decode("uEiDDq4_xNyDorZBH3TlGazyJdOWSwvo4PUo5YHFMrvDE8g").unwrap();
ma_valid(
"/ip4/127.0.0.1/udp/1234/webrtc/certhash/uEiDDq4_xNyDorZBH3TlGazyJdOWSwvo4PUo5YHFMrvDE8g",
"/ip4/127.0.0.1/udp/1234/webrtc-direct/certhash/uEiDDq4_xNyDorZBH3TlGazyJdOWSwvo4PUo5YHFMrvDE8g",
"047F000001910204D29802D203221220C3AB8FF13720E8AD9047DD39466B3C8974E592C2FA383D4A3960714CAEF0C4F2",
vec![
Ip4(local),
Udp(1234),
WebRTC,
WebRTCDirect,
Certhash(Multihash::from_bytes(&decoded).unwrap()),
],
);
Expand Down Expand Up @@ -395,8 +395,8 @@ fn construct_fail() {
"/ip4/127.0.0.1/p2p",
"/ip4/127.0.0.1/p2p/tcp",
"/p2p-circuit/50",
"/ip4/127.0.0.1/udp/1234/webrtc/certhash",
"/ip4/127.0.0.1/udp/1234/webrtc/certhash/b2uaraocy6yrdblb4sfptaddgimjmmp", // 1 character missing from certhash
"/ip4/127.0.0.1/udp/1234/webrtc-direct/certhash",
"/ip4/127.0.0.1/udp/1234/webrtc-direct/certhash/b2uaraocy6yrdblb4sfptaddgimjmmp", // 1 character missing from certhash
];

for address in &addresses {
Expand Down Expand Up @@ -568,7 +568,7 @@ fn protocol_stack() {
"/ip4/127.0.0.1/tcp/127/tls",
"/ip4/127.0.0.1/tcp/127/tls/ws",
"/ip4/127.0.0.1/tcp/127/noise",
"/ip4/127.0.0.1/udp/1234/webrtc",
"/ip4/127.0.0.1/udp/1234/webrtc-direct",
];
let argless = std::collections::HashSet::from([
"http",
Expand All @@ -583,7 +583,7 @@ fn protocol_stack() {
"tls",
"udt",
"utp",
"webrtc",
"webrtc-direct",
"ws",
"wss",
]);
Expand Down

0 comments on commit 4cd7ee5

Please sign in to comment.