summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2024-04-11 13:56:33 +0200
committerDavid Lönnhager <david.l@mullvad.net>2024-04-30 16:22:52 +0200
commit7c538002ed1821db83bd17283514190961a0a68f (patch)
tree99b00f53f74a61f1449f8445f1d0871107b6b1a4
parent8287a14f70dafbc1b59a752e006bf6b9d2242523 (diff)
downloadmullvadvpn-7c538002ed1821db83bd17283514190961a0a68f.tar.xz
mullvadvpn-7c538002ed1821db83bd17283514190961a0a68f.zip
Print actual and min supported ST version
-rw-r--r--talpid-core/src/split_tunnel/macos/process.rs41
-rw-r--r--talpid-platform-metadata/src/macos.rs12
2 files changed, 38 insertions, 15 deletions
diff --git a/talpid-core/src/split_tunnel/macos/process.rs b/talpid-core/src/split_tunnel/macos/process.rs
index dfb13a0b70..a69c05b55b 100644
--- a/talpid-core/src/split_tunnel/macos/process.rs
+++ b/talpid-core/src/split_tunnel/macos/process.rs
@@ -7,6 +7,7 @@
use futures::channel::oneshot;
use libc::{proc_listallpids, proc_pidpath};
+use once_cell::sync::Lazy;
use serde::Deserialize;
use std::collections::HashSet;
use std::{
@@ -25,14 +26,19 @@ use tokio::io::{AsyncBufReadExt, BufReader};
const SHUTDOWN_TIMEOUT: Duration = Duration::from_secs(3);
const EARLY_FAIL_TIMEOUT: Duration = Duration::from_millis(500);
+static MIN_OS_VERSION: Lazy<MacosVersion> =
+ Lazy::new(|| MacosVersion::from_raw_version("13.0.0").unwrap());
+
#[derive(thiserror::Error, Debug)]
pub enum Error {
/// Failed to detect macOS version
#[error("Failed to detect macOS version")]
DetectMacosVersion(#[source] io::Error),
/// Only macOS 13 and later is supported
- #[error("Unsupported macOS version")]
- UnsupportedMacosVersion,
+ #[error("Unsupported macOS version: {actual}, expected at least {}", *MIN_OS_VERSION)]
+ UnsupportedMacosVersion {
+ actual: talpid_platform_metadata::MacosVersion,
+ },
/// Failed to start eslogger listener
#[error("Failed to start eslogger")]
StartMonitor(#[source] io::Error),
@@ -468,14 +474,33 @@ fn parse_eslogger_error(stderr_str: &str) -> Option<Error> {
/// Check whether the current macOS version is supported, and return an error otherwise
fn check_os_version_support() -> Result<(), Error> {
match MacosVersion::new().map_err(Error::DetectMacosVersion) {
- Ok(version) => {
- if version.major_version() <= 12 {
- return Err(Error::UnsupportedMacosVersion);
- }
- }
+ Ok(version) => check_os_version_support_inner(version),
Err(error) => {
log::error!("Failed to detect macOS version: {error}");
+ Ok(())
}
}
- Ok(())
+}
+
+fn check_os_version_support_inner(version: MacosVersion) -> Result<(), Error> {
+ if version >= *MIN_OS_VERSION {
+ Ok(())
+ } else {
+ Err(Error::UnsupportedMacosVersion { actual: version })
+ }
+}
+
+#[test]
+fn test_min_os_version() {
+ assert!(check_os_version_support_inner(MIN_OS_VERSION.clone()).is_ok());
+
+ // test unsupported version
+ assert!(
+ check_os_version_support_inner(MacosVersion::from_raw_version("12.1").unwrap()).is_err()
+ );
+
+ // test supported version
+ assert!(
+ check_os_version_support_inner(MacosVersion::from_raw_version("13.0").unwrap()).is_ok()
+ );
}
diff --git a/talpid-platform-metadata/src/macos.rs b/talpid-platform-metadata/src/macos.rs
index 7949f34539..f68cabb82b 100644
--- a/talpid-platform-metadata/src/macos.rs
+++ b/talpid-platform-metadata/src/macos.rs
@@ -125,13 +125,11 @@ fn test_version_order() {
MacosVersion::from_raw_version("13.0.0").unwrap()
);
- assert!(
- !(MacosVersion::from_raw_version("13.0").unwrap()
- < MacosVersion::from_raw_version("13.0.0").unwrap())
- );
- assert!(
- !(MacosVersion::from_raw_version("13.0").unwrap()
- > MacosVersion::from_raw_version("13.0.0").unwrap())
+ assert_eq!(
+ MacosVersion::from_raw_version("13.0")
+ .unwrap()
+ .partial_cmp(&MacosVersion::from_raw_version("13.0.0").unwrap()),
+ Some(Ordering::Equal),
);
// test major version