Skip to content

Commit ee96b5a

Browse files
committed
Use stagemole to retrieve metadata in installer-downloader
1 parent 63d105e commit ee96b5a

File tree

3 files changed

+20
-33
lines changed

3 files changed

+20
-33
lines changed

installer-downloader/src/controller.rs

+17-32
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use mullvad_update::{
1212
};
1313
use rand::seq::SliceRandom;
1414

15-
use std::sync::LazyLock;
1615
use tokio::sync::{mpsc, oneshot};
1716

1817
/// Actions handled by an async worker task in [handle_action_messages].
@@ -27,31 +26,6 @@ enum TaskMessage {
2726
/// See the [module-level docs](self).
2827
pub struct AppController {}
2928

30-
pub struct FakeVersionInfoProvider {}
31-
32-
static FAKE_VERSION: LazyLock<VersionInfo> = LazyLock::new(|| VersionInfo {
33-
stable: Version {
34-
version: "2025.1".parse().unwrap(),
35-
urls: vec![
36-
"https://releases.mullvad.net/desktop/releases/2025.4/MullvadVPN-2025.4.pkg".to_owned(),
37-
],
38-
size: 226928055,
39-
changelog: "a changelog".to_owned(),
40-
sha256: hex::decode("af81d35022f6d1abecc0eacf33b3c767efbe16a0edb07beec5911c114092d69b")
41-
.unwrap()
42-
.try_into()
43-
.unwrap(),
44-
},
45-
beta: None,
46-
});
47-
48-
#[async_trait::async_trait]
49-
impl VersionInfoProvider for FakeVersionInfoProvider {
50-
async fn get_version_info(&self, _params: VersionParameters) -> anyhow::Result<VersionInfo> {
51-
Ok(FAKE_VERSION.clone())
52-
}
53-
}
54-
5529
/// Public entry function for registering a [AppDelegate].
5630
pub fn initialize_controller<T: AppDelegate + 'static>(delegate: &mut T) {
5731
use mullvad_update::{api::HttpVersionInfoProvider, app::HttpAppDownloader};
@@ -62,20 +36,31 @@ pub fn initialize_controller<T: AppDelegate + 'static>(delegate: &mut T) {
6236
type DirProvider = crate::temp::TempDirProvider;
6337

6438
// Version info provider to use
65-
/*const TEST_PUBKEY: &str = include_str!("../../mullvad-update/test-pubkey");
39+
const STAGEMOLE_PUBKEY: &str = include_str!("../../mullvad-update/stagemole-pubkey");
40+
//"https://releases.mullvad.net/desktop/metadata/updater-windows.json"
6641
let verifying_key =
67-
mullvad_update::format::key::VerifyingKey::from_hex(TEST_PUBKEY).expect("valid key");
42+
mullvad_update::format::key::VerifyingKey::from_hex(STAGEMOLE_PUBKEY).expect("valid key");
6843
let version_provider = HttpVersionInfoProvider {
69-
url: "https://releases.mullvad.net/thing".to_owned(),
44+
url: get_metadata_url(),
7045
pinned_certificate: None,
7146
verifying_key,
72-
};*/
73-
74-
let version_provider = FakeVersionInfoProvider {};
47+
};
7548

7649
AppController::initialize::<_, Downloader<T>, _, DirProvider>(delegate, version_provider)
7750
}
7851

52+
/// JSON files should be stored at `<base url>/updates-<platform>.json`.
53+
fn get_metadata_url() -> String {
54+
const PLATFORM: &str = if cfg!(target_os = "windows") {
55+
"windows"
56+
} else if cfg!(target_os = "macos") {
57+
"macos"
58+
} else {
59+
panic!("Unsupported platform")
60+
};
61+
format!("https://releases.stagemole.eu/desktop/metadata/updates-{PLATFORM}.json")
62+
}
63+
7964
impl AppController {
8065
/// Initialize [AppController] using the provided delegate.
8166
///

installer-downloader/tests/controller.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
//! changes to, and update, snapshots are by running `cargo insta review`.
88
99
use insta::assert_yaml_snapshot;
10-
use installer_downloader::controller::{AppController, DirectoryProvider};
10+
use installer_downloader::controller::AppController;
1111
use installer_downloader::delegate::{AppDelegate, AppDelegateQueue, ErrorMessage};
12+
use installer_downloader::temp::DirectoryProvider;
1213
use installer_downloader::ui_downloader::UiAppDownloaderParameters;
1314
use mullvad_update::api::VersionInfoProvider;
1415
use mullvad_update::app::{AppDownloader, DownloadError};

mullvad-update/stagemole-pubkey

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a0cd8f582e3147d57f7c01ec0fd306c8315290cea55725c7d5c76f835b78b363

0 commit comments

Comments
 (0)