Skip to content

Commit

Permalink
Send MulticastPacket instead of Request to the multicast address
Browse files Browse the repository at this point in the history
  • Loading branch information
seamlik committed Mar 10, 2024
1 parent 0635192 commit 078e76d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions main/src/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ async fn send_requests(
discovery_port: u16,
) -> Result<(), ScanError> {
let multicast_address = SocketAddrV6::new(crate::get_discovery_ip(), discovery_port, 0, 0);
let packet: MulticastPacket = request.into();
log::debug!(
"Sending {:?} to multicast address {}",
request,
packet,
multicast_address
);
let packet: Arc<[u8]> = request.encode_to_vec().into();
let packet_bytes: Arc<[u8]> = packet.encode_to_vec().into();
multicast_sender
.send(multicast_address, packet.clone())
.send(multicast_address, packet_bytes.clone())
.await?;
Ok(())
}
Expand Down Expand Up @@ -155,7 +156,8 @@ mod test {
let request = Request {
response_collector_port: 100,
};
let request_packet: Arc<[u8]> = request.encode_to_vec().into();
let packet: MulticastPacket = request.clone().into();
let packet_bytes: Arc<[u8]> = packet.encode_to_vec().into();

let mut response_collector = MockResponseCollector::new();
response_collector
Expand All @@ -170,7 +172,7 @@ mod test {
let mut multicast_sender = MockMulticastSender::default();
multicast_sender
.expect_send()
.with(eq(multicast_address), eq(request_packet.clone()))
.with(eq(multicast_address), eq(packet_bytes.clone()))
.return_once(|_, _| async { Ok(()) }.boxed());

let mut multicast_receiver = MockMulticastPacketReceiver::default();
Expand Down

0 comments on commit 078e76d

Please sign in to comment.