Skip to content

Commit bb5886f

Browse files
committed
fix(onion_clinent): search requests should contain zero pind_id
1 parent 75ddfdf commit bb5886f

File tree

1 file changed

+10
-2
lines changed
  • src/toxcore/onion/client

1 file changed

+10
-2
lines changed

src/toxcore/onion/client/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,14 @@ impl OnionClient {
658658
friend_pk,
659659
});
660660

661-
let inner_announce_request = announce_packet_data.request(&node.pk, node.ping_id, request_id);
661+
// the request is a search request if pind_id is 0 and an
662+
// announce request otherwise
663+
let ping_id = if friend_pk.is_some() {
664+
None
665+
} else {
666+
node.ping_id
667+
};
668+
let inner_announce_request = announce_packet_data.request(&node.pk, ping_id, request_id);
662669
let onion_request = path.create_onion_request(node.saddr, InnerOnionRequest::InnerOnionAnnounceRequest(inner_announce_request));
663670

664671
packets.push((Packet::OnionRequest0(onion_request), path.nodes[0].saddr));
@@ -2006,7 +2013,8 @@ mod tests {
20062013
pk: node_pk,
20072014
saddr,
20082015
path_id: path.id(),
2009-
ping_id: None,
2016+
// regardless of this ping_id search requests should contain 0
2017+
ping_id: Some(sha256::hash(&[1, 2, 3])),
20102018
data_pk: None,
20112019
unsuccessful_pings: 0,
20122020
added_time: now,

0 commit comments

Comments
 (0)