Skip to content

Commit 569409e

Browse files
committed
config: change DPI from Option to value
1 parent 1fb9bbd commit 569409e

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

contrib/config.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
mitm = false
6767

6868
# Force DPI
69-
# dpi = 130
69+
# 0 = don't change DPI
70+
dpi = 0
7071

7172
# remove tap restriction
7273
remove_tap_restriction = false

src/io_uring.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub async fn io_loop(
198198
tcp_start: Arc<Notify>,
199199
read_timeout: Duration,
200200
mitm: bool,
201-
dpi: Option<u16>,
201+
dpi: u16,
202202
developer_mode: bool,
203203
disable_media_sink: bool,
204204
disable_tts_sink: bool,

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub struct AppConfig {
148148
timeout_secs: u16,
149149
bt_timeout_secs: u16,
150150
mitm: bool,
151-
dpi: Option<u16>,
151+
dpi: u16,
152152
remove_tap_restriction: bool,
153153
video_in_motion: bool,
154154
disable_media_sink: bool,
@@ -183,7 +183,7 @@ impl Default for AppConfig {
183183
timeout_secs: 10,
184184
bt_timeout_secs: 120,
185185
mitm: false,
186-
dpi: None,
186+
dpi: 0,
187187
remove_tap_restriction: false,
188188
video_in_motion: false,
189189
disable_media_sink: false,

src/mitm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ pub async fn pkt_debug(
262262
pub async fn pkt_modify_hook(
263263
proxy_type: ProxyType,
264264
pkt: &mut Packet,
265-
dpi: Option<u16>,
265+
dpi: u16,
266266
developer_mode: bool,
267267
disable_media_sink: bool,
268268
disable_tts_sink: bool,
@@ -352,7 +352,7 @@ pub async fn pkt_modify_hook(
352352
let mut msg = ServiceDiscoveryResponse::parse_from_bytes(data)?;
353353

354354
// DPI
355-
if let Some(new_dpi) = dpi {
355+
if dpi > 0 {
356356
if let Some(svc) = msg
357357
.services
358358
.iter_mut()
@@ -362,13 +362,13 @@ pub async fn pkt_modify_hook(
362362
let prev_val = svc.media_sink_service.video_configs[0].density();
363363
// set new value
364364
svc.media_sink_service.as_mut().unwrap().video_configs[0]
365-
.set_density(new_dpi.into());
365+
.set_density(dpi.into());
366366
info!(
367367
"{} <yellow>{:?}</>: replacing DPI value: from <b>{}</> to <b>{}</>",
368368
get_name(proxy_type),
369369
control.unwrap(),
370370
prev_val,
371-
new_dpi
371+
dpi
372372
);
373373
}
374374
}
@@ -650,7 +650,7 @@ pub async fn proxy<A: Endpoint<A> + 'static>(
650650
tx: Sender<Packet>,
651651
mut rx: Receiver<Packet>,
652652
mut rxr: Receiver<Packet>,
653-
dpi: Option<u16>,
653+
dpi: u16,
654654
developer_mode: bool,
655655
disable_media_sink: bool,
656656
disable_tts_sink: bool,

0 commit comments

Comments
 (0)