Skip to content

Commit 768ceb3

Browse files
committed
Only proxy HTTP assets + cleanup old proxy servers
Fixes #38
1 parent e013198 commit 768ceb3

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎src-tauri/src/lib.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,20 @@ async fn prep_launch(
548548
asset_url = offline_asset_url;
549549
main_url = offline_main_url;
550550
}
551-
} else if state.config.launcher.proxy_asset_downloads {
551+
} else if asset_url.starts_with("http://") && state.config.launcher.proxy_asset_downloads {
552552
let mut proxy = TcpProxy::default();
553553
proxy.set_base_path(asset_url.clone());
554+
554555
let listener = TcpListener::bind("127.0.0.1:0").await?;
555556
let proxy_addr = listener.local_addr()?;
556557
let new_asset_url = format!("http://{}", proxy_addr);
557558
asset_url = new_asset_url;
558559

560+
// Shut down any existing proxy before starting a new one
561+
if let Some(old_handle) = state.proxy.take() {
562+
old_handle.abort();
563+
}
564+
559565
let handle = tokio::spawn(async move {
560566
proxy.run(&listener).await;
561567
});

0 commit comments

Comments
 (0)