Skip to content

Commit 7fb83bc

Browse files
committed
mitm: fix todo! panics returning proper Errors
1 parent 948d31e commit 7fb83bc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/mitm.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,19 +403,19 @@ pub async fn proxy<A: Endpoint<A> + 'static>(
403403
// for both HU and MD
404404
if proxy_type == ProxyType::HeadUnit {
405405
// waiting for initial version frame (HU is starting transmission)
406-
let Some(pkt) = rxr.recv().await else { todo!() };
406+
let pkt = rxr.recv().await.ok_or("reader channel hung up")?;
407407
let _ = pkt_debug(&pkt.payload).await;
408408
// sending to the MD
409409
tx.send(pkt).await?;
410410
// waiting for MD reply
411-
let Some(pkt) = rx.recv().await else { todo!() };
411+
let pkt = rx.recv().await.ok_or("rx channel hung up")?;
412412
// sending reply back to the HU
413413
pkt.transmit(&mut device).await?;
414414

415415
// doing SSL handshake
416416
const STEPS: u8 = 2;
417417
for i in 1..=STEPS {
418-
let Some(pkt) = rxr.recv().await else { todo!() };
418+
let pkt = rxr.recv().await.ok_or("reader channel hung up")?;
419419
pkt.ssl_decapsulate_write(&mut mem_buf).await?;
420420
let _ = server.accept();
421421
info!(
@@ -429,11 +429,11 @@ pub async fn proxy<A: Endpoint<A> + 'static>(
429429
}
430430
} else if proxy_type == ProxyType::MobileDevice {
431431
// expecting version request from the HU here...
432-
let Some(pkt) = rx.recv().await else { todo!() };
432+
let pkt = rx.recv().await.ok_or("rx channel hung up")?;
433433
// sending to the MD
434434
pkt.transmit(&mut device).await?;
435435
// waiting for MD reply
436-
let Some(pkt) = rxr.recv().await else { todo!() };
436+
let pkt = rxr.recv().await.ok_or("reader channel hung up")?;
437437
let _ = pkt_debug(&pkt.payload).await;
438438
// sending reply back to the HU
439439
tx.send(pkt).await?;
@@ -454,7 +454,7 @@ pub async fn proxy<A: Endpoint<A> + 'static>(
454454
break;
455455
};
456456
ssl_encapsulate_transmit(&mut device, mem_buf.clone()).await?;
457-
let Some(pkt) = rxr.recv().await else { todo!() };
457+
let pkt = rxr.recv().await.ok_or("reader channel hung up")?;
458458
pkt.ssl_decapsulate_write(&mut mem_buf).await?;
459459
}
460460
}

0 commit comments

Comments
 (0)