Skip to content

Commit

Permalink
misc/multistream-select: Ignore simultaneous open 'iamclient'
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Apr 26, 2021
1 parent 3bd6602 commit 125e3c3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions misc/multistream-select/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const MSG_MULTISTREAM_1_0: &[u8] = b"/multistream/1.0.0\n";
const MSG_PROTOCOL_NA: &[u8] = b"na\n";
/// The encoded form of a multistream-select 'ls' message.
const MSG_LS: &[u8] = b"ls\n";
const MSG_IAMCLIENT: &[u8] = b"iamclient\n";

/// The multistream-select header lines preceeding negotiation.
///
Expand Down Expand Up @@ -171,6 +172,13 @@ impl Message {
return Ok(Message::ListProtocols)
}

// TODO: This is a hack for now.
//
// See https://github.com/libp2p/specs/pull/196#discussion_r615846605 for details.
if msg == MSG_IAMCLIENT {
return Ok(Message::Protocol(Protocol("iamclient".into())))
}

// If it starts with a `/`, ends with a line feed without any
// other line feeds in-between, it must be a protocol name.
if msg.get(0) == Some(&b'/') && msg.last() == Some(&b'\n') &&
Expand Down

0 comments on commit 125e3c3

Please sign in to comment.