From 7aee57038dcec690281ceda33063bad891091a91 Mon Sep 17 00:00:00 2001 From: DecDuck Date: Fri, 18 Jul 2025 20:08:12 +1000 Subject: [PATCH] Fix client running behind reverse proxy (#69) * fix: reverse proxy 400 due to duplicate header * fix: clippy * bump version and update ci --- desktop/.github/workflows/release.yml | 9 ++++--- desktop/package.json | 2 +- desktop/src-tauri/Cargo.lock | 2 +- desktop/src-tauri/Cargo.toml | 2 +- .../src/error/remote_access_error.rs | 4 +++- .../src/games/downloads/download_agent.rs | 16 ++----------- .../src/games/downloads/download_logic.rs | 24 +++++++++---------- desktop/src-tauri/tauri.conf.json | 2 +- 8 files changed, 24 insertions(+), 37 deletions(-) diff --git a/desktop/.github/workflows/release.yml b/desktop/.github/workflows/release.yml index 3ea73f9a..129f754a 100644 --- a/desktop/.github/workflows/release.yml +++ b/desktop/.github/workflows/release.yml @@ -22,9 +22,9 @@ jobs: args: '--target aarch64-apple-darwin' - platform: 'macos-latest' # for Intel based macs. args: '--target x86_64-apple-darwin' - - platform: 'ubuntu-24.04' # for Tauri v1 you could replace this with ubuntu-20.04. + - platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04. args: '' - - platform: 'ubuntu-24.04-arm' + - platform: 'ubuntu-22.04-arm' args: '--target aarch64-unknown-linux-gnu' - platform: 'windows-latest' args: '' @@ -48,12 +48,11 @@ jobs: targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} - name: install dependencies (ubuntu only) - if: matrix.platform == 'ubuntu-24.04' # This must match the platform value defined above. + if: matrix.platform == 'ubuntu-22.04' || matrix.platform == 'ubuntu-22.04-arm' # This must match the platform value defined above. run: | sudo apt-get update - sudo apt-get install -y libglib2.0-dev libgtk-3-dev libwebkit2gtk-4.1-dev + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf # webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2. - # You can remove the one that doesn't apply to your app to speed up the workflow a bit. - name: install frontend dependencies run: yarn install # change this to npm, pnpm or bun depending on which one you use. diff --git a/desktop/package.json b/desktop/package.json index cd54f92a..a64eb418 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -1,7 +1,7 @@ { "name": "drop-app", "private": true, - "version": "0.3.0-rc-6", + "version": "0.3.0-rc-7", "type": "module", "scripts": { "build": "nuxt build", diff --git a/desktop/src-tauri/Cargo.lock b/desktop/src-tauri/Cargo.lock index d43f0683..9f4a86e9 100644 --- a/desktop/src-tauri/Cargo.lock +++ b/desktop/src-tauri/Cargo.lock @@ -1247,7 +1247,7 @@ dependencies = [ [[package]] name = "drop-app" -version = "0.3.0-rc-6" +version = "0.3.0-rc-7" dependencies = [ "atomic-instant-full", "boxcar", diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml index 4495d743..9268f9a4 100644 --- a/desktop/src-tauri/Cargo.toml +++ b/desktop/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "drop-app" -version = "0.3.0-rc-6" +version = "0.3.0-rc-7" description = "The client application for the open-source, self-hosted game distribution platform Drop" authors = ["Drop OSS"] edition = "2021" diff --git a/desktop/src-tauri/src/error/remote_access_error.rs b/desktop/src-tauri/src/error/remote_access_error.rs index 6717c6e3..689db9af 100644 --- a/desktop/src-tauri/src/error/remote_access_error.rs +++ b/desktop/src-tauri/src/error/remote_access_error.rs @@ -18,6 +18,7 @@ pub enum RemoteAccessError { HandshakeFailed(String), GameNotFound(String), InvalidResponse(DropServerError), + UnparseableResponse(String), ManifestDownloadFailed(StatusCode, String), OutOfSync, Cache(cacache::Error), @@ -48,7 +49,8 @@ impl Display for RemoteAccessError { RemoteAccessError::InvalidEndpoint => write!(f, "invalid drop endpoint"), RemoteAccessError::HandshakeFailed(message) => write!(f, "failed to complete handshake: {message}"), RemoteAccessError::GameNotFound(id) => write!(f, "could not find game on server: {id}"), - RemoteAccessError::InvalidResponse(error) => write!(f, "server returned an invalid response: {} {}", error.status_code, error.status_message), + RemoteAccessError::InvalidResponse(error) => write!(f, "server returned an invalid response: {}, {}", error.status_code, error.status_message), + RemoteAccessError::UnparseableResponse(error) => write!(f, "server returned an invalid response: {error}"), RemoteAccessError::ManifestDownloadFailed(status, response) => write!( f, "failed to download game manifest: {status} {response}" diff --git a/desktop/src-tauri/src/games/downloads/download_agent.rs b/desktop/src-tauri/src/games/downloads/download_agent.rs index 1bbd85ac..7a452cbd 100644 --- a/desktop/src-tauri/src/games/downloads/download_agent.rs +++ b/desktop/src-tauri/src/games/downloads/download_agent.rs @@ -313,18 +313,9 @@ impl GameDownloadAgent { match download_game_chunk(context, &self.control_flag, progress_handle, request) { Ok(true) => { - debug!( - "Finished context #{} with checksum {}", - index, context.checksum - ); completed_indexes.push(context.checksum.clone()); } - Ok(false) => { - debug!( - "Didn't finish context #{} with checksum {}", - index, context.checksum - ); - } + Ok(false) => {} Err(e) => { error!("{e}"); sender.send(DownloadManagerSignal::Error(e)).unwrap(); @@ -350,10 +341,7 @@ impl GameDownloadAgent { .map(|x| { ( x.checksum.clone(), - context_map_lock - .get(&x.checksum) - .cloned() - .unwrap_or(false), + context_map_lock.get(&x.checksum).cloned().unwrap_or(false), ) }) .collect::>(); diff --git a/desktop/src-tauri/src/games/downloads/download_logic.rs b/desktop/src-tauri/src/games/downloads/download_logic.rs index 69473e03..5985a620 100644 --- a/desktop/src-tauri/src/games/downloads/download_logic.rs +++ b/desktop/src-tauri/src/games/downloads/download_logic.rs @@ -3,6 +3,7 @@ use crate::download_manager::util::download_thread_control_flag::{ }; use crate::download_manager::util::progress_object::ProgressHandle; use crate::error::application_download_error::ApplicationDownloadError; +use crate::error::drop_server_error::DropServerError; use crate::error::remote_access_error::RemoteAccessError; use crate::games::downloads::manifest::DropDownloadContext; use crate::remote::auth::generate_authorization_header; @@ -40,11 +41,9 @@ impl DropWriter { // Write automatically pushes to file and hasher impl Write for DropWriter { fn write(&mut self, buf: &[u8]) -> io::Result { - self.hasher.write_all(buf).map_err(|e| { - io::Error::other( - format!("Unable to write to hasher: {e}"), - ) - })?; + self.hasher + .write_all(buf) + .map_err(|e| io::Error::other(format!("Unable to write to hasher: {e}")))?; self.destination.write(buf) } @@ -134,17 +133,11 @@ pub fn download_game_chunk( progress: ProgressHandle, request: RequestBuilder, ) -> Result { - debug!( - "Starting download chunk {}, {}, {} #{}", - ctx.file_name, ctx.index, ctx.offset, ctx.checksum - ); // If we're paused if control_flag.get() == DownloadThreadControlFlag::Stop { progress.set(0); return Ok(false); } - let request = request.header("Authorization", generate_authorization_header()); - let response = request .header("Authorization", generate_authorization_header()) .send() @@ -152,9 +145,14 @@ pub fn download_game_chunk( if response.status() != 200 { debug!("chunk request got status code: {}", response.status()); - let err = response.json().unwrap(); + let raw_res = response.text().unwrap(); + if let Ok(err) = serde_json::from_str::(&raw_res) { + return Err(ApplicationDownloadError::Communication( + RemoteAccessError::InvalidResponse(err), + )); + }; return Err(ApplicationDownloadError::Communication( - RemoteAccessError::InvalidResponse(err), + RemoteAccessError::UnparseableResponse(raw_res), )); } diff --git a/desktop/src-tauri/tauri.conf.json b/desktop/src-tauri/tauri.conf.json index 6ee15df7..0487174f 100644 --- a/desktop/src-tauri/tauri.conf.json +++ b/desktop/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2.0.0", "productName": "Drop Desktop Client", - "version": "0.3.0-rc-6", + "version": "0.3.0-rc-7", "identifier": "dev.drop.app", "build": { "beforeDevCommand": "yarn dev --port 1432",