@@ -24,7 +24,13 @@ use crate::io_uring::Endpoint;
24
24
use crate :: io_uring:: BUFFER_LEN ;
25
25
26
26
// module name for logging engine
27
- const NAME : & str = "<i><bright-black> mitm: </>" ;
27
+ fn get_name ( proxy_type : ProxyType ) -> String {
28
+ let proxy = match proxy_type {
29
+ ProxyType :: HeadUnit => "HU" ,
30
+ ProxyType :: MobileDevice => "MD" ,
31
+ } ;
32
+ format ! ( "<i><bright-black> mitm/{}: </>" , proxy)
33
+ }
28
34
29
35
// Just a generic Result type to ease error handling for us. Errors in multithreaded
30
36
// async contexts needs some extra restrictions
@@ -219,6 +225,7 @@ pub async fn pkt_debug(payload: &[u8]) -> Result<()> {
219
225
220
226
/// packet modification hook
221
227
pub async fn pkt_modify_hook (
228
+ proxy_type : ProxyType ,
222
229
pkt : & mut Packet ,
223
230
dpi : Option < u16 > ,
224
231
developer_mode : bool ,
@@ -254,7 +261,7 @@ pub async fn pkt_modify_hook(
254
261
. set_density ( new_dpi. into ( ) ) ;
255
262
info ! (
256
263
"{} <yellow>{:?}</>: replacing DPI value: from <b>{}</> to <b>{}</>" ,
257
- NAME ,
264
+ get_name ( proxy_type ) ,
258
265
control. unwrap( ) ,
259
266
prev_val,
260
267
new_dpi
@@ -267,7 +274,7 @@ pub async fn pkt_modify_hook(
267
274
. retain ( |svc| svc. media_sink_service . audio_type ( ) != AUDIO_STREAM_MEDIA ) ;
268
275
info ! (
269
276
"{} <yellow>{:?}</>: media sink disabled" ,
270
- NAME ,
277
+ get_name ( proxy_type ) ,
271
278
control. unwrap( ) ,
272
279
) ;
273
280
}
@@ -278,7 +285,7 @@ pub async fn pkt_modify_hook(
278
285
msg. set_model ( "Desktop Head Unit" . into ( ) ) ;
279
286
info ! (
280
287
"{} <yellow>{:?}</>: enabling developer mode" ,
281
- NAME ,
288
+ get_name ( proxy_type ) ,
282
289
control. unwrap( ) ,
283
290
) ;
284
291
}
@@ -455,7 +462,7 @@ pub async fn proxy<A: Endpoint<A> + 'static>(
455
462
let _ = server. accept ( ) ;
456
463
info ! (
457
464
"{} 🔒 stage #{} of {}: SSL handshake: {}" ,
458
- NAME ,
465
+ get_name ( proxy_type ) ,
459
466
i,
460
467
STEPS ,
461
468
server. ssl( ) . state_string_long( )
@@ -479,7 +486,7 @@ pub async fn proxy<A: Endpoint<A> + 'static>(
479
486
let _ = server. do_handshake ( ) ;
480
487
info ! (
481
488
"{} 🔒 stage #{} of {}: SSL handshake: {}" ,
482
- NAME ,
489
+ get_name ( proxy_type ) ,
483
490
i,
484
491
STEPS ,
485
492
server. ssl( ) . state_string_long( )
@@ -498,7 +505,14 @@ pub async fn proxy<A: Endpoint<A> + 'static>(
498
505
loop {
499
506
// handling data from opposite device's thread, which needs to be transmitted
500
507
if let Ok ( mut pkt) = rx. try_recv ( ) {
501
- pkt_modify_hook ( & mut pkt, dpi, developer_mode, disable_media_sink) . await ?;
508
+ pkt_modify_hook (
509
+ proxy_type,
510
+ & mut pkt,
511
+ dpi,
512
+ developer_mode,
513
+ disable_media_sink,
514
+ )
515
+ . await ?;
502
516
pkt. encrypt_payload ( & mut mem_buf, & mut server) . await ?;
503
517
pkt. transmit ( & mut device) . await ?;
504
518
0 commit comments