Skip to content

Commit fd8790f

Browse files
committed
update strom dependency which fixes disable remote fingerprint verification, modify multistream protocol message, modify opening based on str0m api changes
1 parent 8a02398 commit fd8790f

File tree

4 files changed

+41
-28
lines changed

4 files changed

+41
-28
lines changed

Cargo.lock

Lines changed: 15 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ rcgen = { version = "0.14.5", optional = true }
6464
# End of Quic related dependencies.
6565

6666
# WebRTC related dependencies. WebRTC is an experimental feature flag. The dependencies must be updated.
67-
str0m = { version = "0.9.0", optional = true }
67+
str0m = { git = "https://github.com/algesten/str0m", rev = "8058d4d66bc1ac465962f95ac30df3235e671612", optional = true }
6868
# End of WebRTC related dependencies.
6969

7070
# Fuzzing related dependencies.

src/multistream_select/protocol.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ impl Message {
220220

221221
// Skip ahead to the next protocol.
222222
remaining = &tail[len..];
223+
if remaining.len() == 0 {
224+
// During negotiation the remote may not append a trailing newline.
225+
break;
226+
}
223227
}
224228

225229
Ok(Message::Protocols(protocols))
@@ -230,7 +234,7 @@ impl Message {
230234
///
231235
/// # Note
232236
///
233-
/// This is implementation is not compliant with the multistream-select protocol spec.
237+
/// This implementation may not be compliant with the multistream-select protocol spec.
234238
/// The only purpose of this was to get the `multistream-select` protocol working with smoldot.
235239
pub fn webrtc_encode_multistream_message(
236240
messages: impl IntoIterator<Item = Message>,
@@ -249,9 +253,6 @@ pub fn webrtc_encode_multistream_message(
249253
header.append(&mut proto_bytes);
250254
}
251255

252-
// For the `Message::Protocols` to be interpreted correctly, it must be followed by a newline.
253-
header.push(b'\n');
254-
255256
Ok(BytesMut::from(&header[..]))
256257
}
257258

@@ -542,4 +543,21 @@ mod tests {
542543
ProtocolError::InvalidMessage
543544
);
544545
}
546+
547+
#[test]
548+
fn test_decode_multiple_protocols_no_trailing_newline() {
549+
let raw: [u8; 38] = [
550+
19, 47, 109, 117, 108, 116, 105, 115, 116, 114, 101, 97, 109, 47, 49, 46, 48, 46, 48, 10,
551+
17, 47, 105, 112, 102, 115, 47, 112, 105, 110, 103, 47, 49, 46, 48, 46, 48, 10,
552+
];
553+
let bytes = Bytes::copy_from_slice(&raw);
554+
555+
assert_eq!(
556+
Message::decode(bytes).unwrap(),
557+
Message::Protocols(vec![
558+
Protocol::try_from(Bytes::from_static(b"/multistream/1.0.0")).unwrap(),
559+
Protocol::try_from(Bytes::from_static(b"/ipfs/ping/1.0.0")).unwrap(),
560+
])
561+
);
562+
}
545563
}

src/transport/webrtc/opening.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ impl OpeningWebRtcConnection {
176176
.rtc
177177
.direct_api()
178178
.remote_dtls_fingerprint()
179-
.clone()
180-
.expect("fingerprint to exist");
179+
.expect("fingerprint to exist")
180+
.clone();
181181
Self::fingerprint_to_bytes(&fingerprint)
182182
}
183183

@@ -268,8 +268,8 @@ impl OpeningWebRtcConnection {
268268
.rtc
269269
.direct_api()
270270
.remote_dtls_fingerprint()
271-
.clone()
272271
.expect("fingerprint to exist")
272+
.clone()
273273
.bytes;
274274

275275
const MULTIHASH_SHA256_CODE: u64 = 0x12;

0 commit comments

Comments
 (0)