summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkus Pettersson <markus.pettersson@mullvad.net>2025-01-14 09:21:36 +0100
committerMarkus Pettersson <markus.pettersson@mullvad.net>2025-01-14 09:21:36 +0100
commitd23d7ba36a6b12a057fe46848d4b138ce392cede (patch)
tree0c2b82b1119c786cbcf490fbcb6ac8723935b568
parent8dcbb3979003ab30f7f86eb8bb90eb03ba36a184 (diff)
parent406405f4523264f0ba0bebb29acecc4a57265f7c (diff)
downloadmullvadvpn-d23d7ba36a6b12a057fe46848d4b138ce392cede.tar.xz
mullvadvpn-d23d7ba36a6b12a057fe46848d4b138ce392cede.zip
Merge branch 'fix-clippy-lints'
-rw-r--r--Cargo.lock33
-rw-r--r--mullvad-daemon/Cargo.toml2
-rw-r--r--mullvad-daemon/src/macos_launch_daemon.rs28
-rw-r--r--talpid-core/src/split_tunnel/macos/process.rs2
-rw-r--r--talpid-dbus/src/systemd_resolved.rs3
-rw-r--r--talpid-types/src/net/proxy.rs4
6 files changed, 26 insertions, 46 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 66b17974d1..13e2e0d7e6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2274,15 +2274,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9106e1d747ffd48e6be5bb2d97fa706ed25b144fbee4d5c02eae110cd8d6badd"
[[package]]
-name = "malloc_buf"
-version = "0.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
-dependencies = [
- "libc",
-]
-
-[[package]]
name = "match_cfg"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2544,7 +2535,7 @@ dependencies = [
"mullvad-types",
"mullvad-version",
"nix 0.23.2",
- "objc",
+ "objc2",
"regex",
"serde",
"serde_json",
@@ -2987,20 +2978,13 @@ dependencies = [
]
[[package]]
-name = "objc"
-version = "0.2.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
-dependencies = [
- "malloc_buf",
- "objc_exception",
-]
-
-[[package]]
name = "objc-sys"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310"
+dependencies = [
+ "cc",
+]
[[package]]
name = "objc2"
@@ -3096,15 +3080,6 @@ dependencies = [
]
[[package]]
-name = "objc_exception"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4"
-dependencies = [
- "cc",
-]
-
-[[package]]
name = "object"
version = "0.32.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml
index d8b1a2b1c6..4c9fce37ec 100644
--- a/mullvad-daemon/Cargo.toml
+++ b/mullvad-daemon/Cargo.toml
@@ -62,7 +62,7 @@ simple-signal = "1.1"
talpid-dbus = { path = "../talpid-dbus" }
[target.'cfg(target_os="macos")'.dependencies]
-objc = { version = "0.2.7", features = ["exception", "verify_message"] }
+objc2 = { version = "0.5.2", features = ["exception"] }
[target.'cfg(windows)'.dependencies]
ctrlc = "3.0"
diff --git a/mullvad-daemon/src/macos_launch_daemon.rs b/mullvad-daemon/src/macos_launch_daemon.rs
index 945e61828b..0c9c89080c 100644
--- a/mullvad-daemon/src/macos_launch_daemon.rs
+++ b/mullvad-daemon/src/macos_launch_daemon.rs
@@ -5,10 +5,11 @@
//! must be checked so that the user can be directed to approve the launch
//! daemon in the system settings.
-use objc::{class, msg_send, sel, sel_impl};
+use libc::c_longlong;
+use objc2::{class, msg_send, runtime::AnyObject, Encode, Encoding, RefEncode};
use std::ffi::CStr;
-type Id = *mut objc::runtime::Object;
+type Id = *mut AnyObject;
// Framework that contains `SMAppService`.
#[link(name = "ServiceManagement", kind = "framework")]
@@ -18,18 +19,23 @@ extern "C" {}
#[repr(C)]
#[derive(Debug)]
struct NSOperatingSystemVersion {
- major_version: libc::c_longlong,
- minor_version: libc::c_longlong,
- patch_version: libc::c_longlong,
+ major_version: c_longlong,
+ minor_version: c_longlong,
+ patch_version: c_longlong,
}
-/// Implement Objective-C type encoding for the struct. Allows the `objc` crate
+/// Implement Objective-C type encoding for the struct. Allows the `objc2` crate
/// to perform function signature matching before performing calls into the Objective-C
-/// runtime. This is needed to be able to enable the `verify_message` feature on `objc`.
-unsafe impl objc::Encode for NSOperatingSystemVersion {
- fn encode() -> objc::Encoding {
- unsafe { objc::Encoding::from_str("{?=qqq}") }
- }
+/// runtime.
+unsafe impl Encode for NSOperatingSystemVersion {
+ const ENCODING: Encoding = Encoding::Struct(
+ "NSOperatingSystemVersion",
+ &[Encoding::LongLong, Encoding::LongLong, Encoding::LongLong],
+ );
+}
+
+unsafe impl RefEncode for NSOperatingSystemVersion {
+ const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// Authorization status of the Mullvad daemon.
diff --git a/talpid-core/src/split_tunnel/macos/process.rs b/talpid-core/src/split_tunnel/macos/process.rs
index 05f83b2497..7b3d644cd5 100644
--- a/talpid-core/src/split_tunnel/macos/process.rs
+++ b/talpid-core/src/split_tunnel/macos/process.rs
@@ -567,7 +567,7 @@ mod test {
msg.contains('\n'),
"Message does not contain a newline!! Make sure to add a newline to '{msg}'"
);
- let (stdout_read, mut stdout_write) = simplex(msg.as_bytes().len());
+ let (stdout_read, mut stdout_write) = simplex(msg.len());
// "print" to "stdout" after `duration`.
tokio::spawn(async move {
tokio::time::sleep(lag).await;
diff --git a/talpid-dbus/src/systemd_resolved.rs b/talpid-dbus/src/systemd_resolved.rs
index b678d5bf20..7dad235ac7 100644
--- a/talpid-dbus/src/systemd_resolved.rs
+++ b/talpid-dbus/src/systemd_resolved.rs
@@ -208,8 +208,7 @@ impl SystemdResolved {
let parts = contents.trim().split(' ');
parts
.map(str::parse::<IpAddr>)
- .map(|maybe_ip| maybe_ip.map(|addr| addr.is_loopback()).unwrap_or(false))
- .any(|is_loopback| is_loopback)
+ .any(|maybe_ip| maybe_ip.map(|addr| addr.is_loopback()).unwrap_or(false))
})
.unwrap_or(false);
diff --git a/talpid-types/src/net/proxy.rs b/talpid-types/src/net/proxy.rs
index d60b2df436..c73db5a355 100644
--- a/talpid-types/src/net/proxy.rs
+++ b/talpid-types/src/net/proxy.rs
@@ -159,12 +159,12 @@ impl SocksAuth {
/// assert!(too_long_username.is_err());
/// ```
pub fn new(username: String, password: String) -> Result<Self, Error> {
- if !(1..=255).contains(&password.as_bytes().len()) {
+ if !(1..=255).contains(&password.len()) {
return Err(Error::InvalidSocksAuthValues(
"Password length should between 1 and 255 bytes",
));
}
- if !(1..=255).contains(&username.as_bytes().len()) {
+ if !(1..=255).contains(&username.len()) {
return Err(Error::InvalidSocksAuthValues(
"Username length should between 1 and 255 bytes",
));