Skip to content

Commit 84a249b

Browse files
Merge branch 'deps'
2 parents 2865a03 + 33063c8 commit 84a249b

File tree

18 files changed

+1311
-1240
lines changed

18 files changed

+1311
-1240
lines changed

Cargo.lock

+673-597
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ log = "0.4"
7878
shadowsocks = { version = "1.16" }
7979
shadowsocks-service = { version = "1.16" }
8080

81-
windows-sys = "0.48.0"
81+
windows-sys = "0.52.0"
8282

8383
chrono = { version = "0.4.26", default-features = false}
8484
clap = { version = "4.4.18", features = ["cargo", "derive"] }

mullvad-daemon/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ objc = { version = "0.2.7", features = ["exception", "verify_message"] }
6565
[target.'cfg(windows)'.dependencies]
6666
ctrlc = "3.0"
6767
windows-service = "0.6.0"
68-
winapi = { version = "0.3", features = ["winnt", "excpt"] }
68+
winapi = { version = "0.3", features = ["winnt", "excpt", "winerror"] }
6969
dirs = "5.0.1"
7070
talpid-windows = { path = "../talpid-windows" }
7171

mullvad-daemon/src/migrations/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,12 @@ mod windows {
208208
use talpid_types::ErrorExt;
209209
use tokio::fs;
210210
use windows_sys::Win32::{
211-
Foundation::{ERROR_SUCCESS, HANDLE, PSID},
211+
Foundation::{LocalFree, ERROR_SUCCESS, HLOCAL, PSID},
212212
Security::{
213213
Authorization::{GetNamedSecurityInfoW, SE_FILE_OBJECT, SE_OBJECT_TYPE},
214214
IsWellKnownSid, WinBuiltinAdministratorsSid, WinLocalSystemSid,
215215
OWNER_SECURITY_INFORMATION, SECURITY_DESCRIPTOR, SID, WELL_KNOWN_SID_TYPE,
216216
},
217-
System::Memory::LocalFree,
218217
};
219218

220219
#[allow(non_camel_case_types)]
@@ -386,7 +385,7 @@ mod windows {
386385

387386
impl Drop for SecurityInformation {
388387
fn drop(&mut self) {
389-
unsafe { LocalFree(self.security_descriptor as HANDLE) };
388+
unsafe { LocalFree(self.security_descriptor as HLOCAL) };
390389
}
391390
}
392391

mullvad-management-interface/src/types/conversions/account.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::types;
2-
use chrono::TimeZone;
2+
use chrono::DateTime;
33
use mullvad_types::account::{AccountData, VoucherSubmission};
44

55
use super::FromProtobufTypeError;
@@ -23,12 +23,12 @@ impl TryFrom<types::VoucherSubmission> for VoucherSubmission {
2323
let new_expiry = submission
2424
.new_expiry
2525
.ok_or(FromProtobufTypeError::InvalidArgument("missing expiry"))?;
26-
let ndt =
27-
chrono::NaiveDateTime::from_timestamp_opt(new_expiry.seconds, new_expiry.nanos as u32)
28-
.unwrap();
26+
27+
let new_expiry = DateTime::from_timestamp(new_expiry.seconds, new_expiry.nanos as u32)
28+
.ok_or(FromProtobufTypeError::InvalidArgument("invalid timestamp"))?;
2929

3030
Ok(VoucherSubmission {
31-
new_expiry: chrono::Utc.from_utc_datetime(&ndt),
31+
new_expiry,
3232
time_added: submission.seconds_added,
3333
})
3434
}
@@ -53,12 +53,13 @@ impl TryFrom<types::AccountData> for AccountData {
5353
let expiry = data
5454
.expiry
5555
.ok_or(FromProtobufTypeError::InvalidArgument("missing expiry"))?;
56-
let ndt =
57-
chrono::NaiveDateTime::from_timestamp_opt(expiry.seconds, expiry.nanos as u32).unwrap();
56+
57+
let expiry = DateTime::from_timestamp(expiry.seconds, expiry.nanos as u32)
58+
.ok_or(FromProtobufTypeError::InvalidArgument("invalid timestamp"))?;
5859

5960
Ok(AccountData {
6061
id: data.id,
61-
expiry: chrono::Utc.from_utc_datetime(&ndt),
62+
expiry,
6263
})
6364
}
6465
}

mullvad-management-interface/src/types/conversions/device.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
use crate::types::{conversions::bytes_to_pubkey, proto, FromProtobufTypeError};
2-
use chrono::TimeZone;
2+
use chrono::DateTime;
33
use prost_types::Timestamp;
44

55
impl TryFrom<proto::Device> for mullvad_types::device::Device {
66
type Error = FromProtobufTypeError;
77

88
fn try_from(device: proto::Device) -> Result<Self, Self::Error> {
9+
let created_seconds = device
10+
.created
11+
.ok_or(FromProtobufTypeError::InvalidArgument(
12+
"missing 'created' field",
13+
))?
14+
.seconds;
15+
16+
let created = DateTime::from_timestamp(created_seconds, 0)
17+
.ok_or(FromProtobufTypeError::InvalidArgument("invalid timestamp"))?;
18+
919
Ok(mullvad_types::device::Device {
1020
id: device.id,
1121
name: device.name,
1222
pubkey: bytes_to_pubkey(&device.pubkey)?,
1323
hijack_dns: device.hijack_dns,
14-
created: chrono::Utc.from_utc_datetime(
15-
&chrono::NaiveDateTime::from_timestamp_opt(
16-
device
17-
.created
18-
.ok_or(FromProtobufTypeError::InvalidArgument(
19-
"missing 'created' field",
20-
))?
21-
.seconds,
22-
0,
23-
)
24-
.unwrap(),
25-
),
24+
created,
2625
})
2726
}
2827
}

mullvad-management-interface/src/types/conversions/wireguard.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::FromProtobufTypeError;
22
use crate::types::proto;
3-
use chrono::TimeZone;
3+
use chrono::DateTime;
44
use prost_types::Timestamp;
55

66
impl From<mullvad_types::wireguard::PublicKey> for proto::PublicKey {
@@ -24,13 +24,14 @@ impl TryFrom<proto::PublicKey> for mullvad_types::wireguard::PublicKey {
2424
.ok_or(FromProtobufTypeError::InvalidArgument(
2525
"missing 'created' timestamp",
2626
))?;
27-
let ndt = chrono::NaiveDateTime::from_timestamp_opt(created.seconds, created.nanos as u32)
28-
.unwrap();
27+
28+
let created = DateTime::from_timestamp(created.seconds, created.nanos as u32)
29+
.ok_or(FromProtobufTypeError::InvalidArgument("invalid timestamp"))?;
2930

3031
Ok(mullvad_types::wireguard::PublicKey {
3132
key: talpid_types::net::wireguard::PublicKey::try_from(public_key.key.as_slice())
3233
.map_err(|_| FromProtobufTypeError::InvalidArgument("invalid wireguard key"))?,
33-
created: chrono::Utc.from_utc_datetime(&ndt),
34+
created,
3435
})
3536
}
3637
}

mullvad-paths/src/windows.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use windows_sys::{
1212
core::{GUID, PWSTR},
1313
Win32::{
1414
Foundation::{
15-
CloseHandle, ERROR_INSUFFICIENT_BUFFER, ERROR_SUCCESS, GENERIC_ALL, GENERIC_READ,
16-
HANDLE, INVALID_HANDLE_VALUE, LUID, S_OK,
15+
CloseHandle, LocalFree, ERROR_INSUFFICIENT_BUFFER, ERROR_SUCCESS, GENERIC_ALL,
16+
GENERIC_READ, HANDLE, INVALID_HANDLE_VALUE, LUID, S_OK,
1717
},
1818
Security::{
1919
self, AdjustTokenPrivileges,
@@ -31,7 +31,6 @@ use windows_sys::{
3131
Storage::FileSystem::MAX_SID_SIZE,
3232
System::{
3333
Com::CoTaskMemFree,
34-
Memory::LocalFree,
3534
ProcessStatus::EnumProcesses,
3635
Threading::{
3736
GetCurrentThread, OpenProcess, OpenProcessToken, OpenThreadToken,
@@ -244,7 +243,7 @@ fn set_security_permissions(path: &Path) -> Result<()> {
244243
)
245244
};
246245

247-
unsafe { LocalFree(new_dacl as isize) };
246+
unsafe { LocalFree(new_dacl.cast()) };
248247

249248
if result != ERROR_SUCCESS {
250249
Err(Error::SetDirPermissionFailed(
@@ -402,7 +401,8 @@ fn get_known_folder_path(
402401
user_token: HANDLE,
403402
) -> std::io::Result<PathBuf> {
404403
let mut folder_path: PWSTR = ptr::null_mut();
405-
let status = unsafe { SHGetKnownFolderPath(folder_id, flags, user_token, &mut folder_path) };
404+
let status =
405+
unsafe { SHGetKnownFolderPath(folder_id, flags as u32, user_token, &mut folder_path) };
406406
let result = if status == S_OK {
407407
let path = unsafe { WideCStr::from_ptr_str(folder_path) };
408408
Ok(PathBuf::from(path.to_os_string()))

talpid-core/src/dns/windows/iphlpapi.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ use windows_sys::{
1818
core::GUID,
1919
s, w,
2020
Win32::{
21-
Foundation::{ERROR_PROC_NOT_FOUND, WIN32_ERROR},
21+
Foundation::{FreeLibrary, ERROR_PROC_NOT_FOUND, WIN32_ERROR},
2222
NetworkManagement::IpHelper::{
2323
DNS_INTERFACE_SETTINGS, DNS_INTERFACE_SETTINGS_VERSION1, DNS_SETTING_IPV6,
2424
DNS_SETTING_NAMESERVER,
2525
},
26-
System::LibraryLoader::{
27-
FreeLibrary, GetProcAddress, LoadLibraryExW, LOAD_LIBRARY_SEARCH_SYSTEM32,
28-
},
26+
System::LibraryLoader::{GetProcAddress, LoadLibraryExW, LOAD_LIBRARY_SEARCH_SYSTEM32},
2927
},
3028
};
3129

talpid-core/src/split_tunnel/windows/windows.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ use std::{
1010
};
1111
use windows_sys::Win32::{
1212
Foundation::{CloseHandle, ERROR_INSUFFICIENT_BUFFER, FILETIME, HANDLE},
13-
Storage::FileSystem::{GetFinalPathNameByHandleW, QueryDosDeviceW},
13+
Storage::FileSystem::{GetFinalPathNameByHandleW, QueryDosDeviceW, VOLUME_NAME_NT},
1414
System::{
1515
ProcessStatus::GetProcessImageFileNameW,
1616
Threading::{GetProcessTimes, OpenProcess, PROCESS_QUERY_LIMITED_INFORMATION},
17-
WindowsProgramming::VOLUME_NAME_NT,
1817
},
1918
};
2019

talpid-openvpn/src/wintun.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ use widestring::{U16CStr, U16CString};
55
use windows_sys::{
66
core::GUID,
77
Win32::{
8-
Foundation::HMODULE,
8+
Foundation::{FreeLibrary, HMODULE},
99
NetworkManagement::{IpHelper::ConvertInterfaceLuidToGuid, Ndis::NET_LUID_LH},
1010
System::{
1111
Com::StringFromGUID2,
12-
LibraryLoader::{
13-
FreeLibrary, GetProcAddress, LoadLibraryExW, LOAD_WITH_ALTERED_SEARCH_PATH,
14-
},
12+
LibraryLoader::{GetProcAddress, LoadLibraryExW, LOAD_WITH_ALTERED_SEARCH_PATH},
1513
Registry::REG_SAM_FLAGS,
1614
},
1715
},

talpid-types/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ workspace = true
1313
[dependencies]
1414
serde = { version = "1.0", features = ["derive"] }
1515
ipnetwork = "0.16"
16-
base64 = "0.13"
16+
base64 = "0.22.0"
1717
x25519-dalek = { version = "2.0.1", features = ["static_secrets", "zeroize", "getrandom"] }
1818
thiserror = { workspace = true }
1919
zeroize = "1.5.7"

talpid-types/src/net/wireguard.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::net::{Endpoint, GenericTunnelOptions, TransportProtocol};
2+
use base64::{engine::general_purpose::STANDARD, Engine};
23
use ipnetwork::IpNetwork;
34
use serde::{Deserialize, Deserializer, Serialize, Serializer};
45
use std::{
@@ -105,7 +106,7 @@ impl PrivateKey {
105106
}
106107

107108
pub fn to_base64(&self) -> String {
108-
base64::encode(self.0.to_bytes())
109+
STANDARD.encode(self.0.to_bytes())
109110
}
110111

111112
pub fn from_base64(key: &str) -> Result<Self, InvalidKey> {
@@ -135,7 +136,7 @@ impl fmt::Debug for PrivateKey {
135136

136137
impl fmt::Display for PrivateKey {
137138
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
138-
write!(f, "{}", &base64::encode((self.0).to_bytes()))
139+
write!(f, "{}", &STANDARD.encode((self.0).to_bytes()))
139140
}
140141
}
141142

@@ -177,7 +178,7 @@ impl PublicKey {
177178
}
178179

179180
pub fn to_base64(&self) -> String {
180-
base64::encode(self.as_bytes())
181+
STANDARD.encode(self.as_bytes())
181182
}
182183

183184
pub fn from_base64(key: &str) -> Result<Self, InvalidKey> {
@@ -272,15 +273,15 @@ impl From<Box<[u8; 32]>> for PresharedKey {
272273

273274
impl fmt::Debug for PresharedKey {
274275
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
275-
write!(f, "{}", &base64::encode(self.as_bytes()))
276+
write!(f, "{}", &STANDARD.encode(self.as_bytes()))
276277
}
277278
}
278279

279280
fn serialize_key<S>(key: &[u8; 32], serializer: S) -> Result<S::Ok, S::Error>
280281
where
281282
S: Serializer,
282283
{
283-
serializer.serialize_str(&base64::encode(key))
284+
serializer.serialize_str(&STANDARD.encode(key))
284285
}
285286

286287
fn deserialize_key<'de, D, K>(deserializer: D) -> Result<K, D::Error>
@@ -295,7 +296,7 @@ where
295296
}
296297

297298
fn key_from_base64<K: From<[u8; 32]>>(key: &str) -> Result<K, InvalidKey> {
298-
let bytes = base64::decode(key).map_err(InvalidKey::Format)?;
299+
let bytes = STANDARD.decode(key).map_err(InvalidKey::Format)?;
299300
if bytes.len() != 32 {
300301
return Err(InvalidKey::Length(bytes.len()));
301302
}

talpid-wireguard/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ workspace = true
1212

1313
[dependencies]
1414
thiserror = { workspace = true }
15-
base64 = "0.13"
1615
futures = "0.3.15"
1716
hex = "0.4"
1817
ipnetwork = "0.16"

talpid-wireguard/src/ping_monitor/icmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Pinger {
9090
// Asserting that `index` is non-zero since otherwise `if_nametoindex` would have return
9191
// an error
9292
socket
93-
.bind_device_by_index(std::num::NonZeroU32::new(index))
93+
.bind_device_by_index_v4(std::num::NonZeroU32::new(index))
9494
.map_err(Error::BindSocketByDevice)?;
9595

9696
Ok(())

talpid-wireguard/src/wireguard_nt/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ use widestring::{U16CStr, U16CString};
2727
use windows_sys::{
2828
core::GUID,
2929
Win32::{
30-
Foundation::{BOOL, ERROR_MORE_DATA, HMODULE},
30+
Foundation::{FreeLibrary, BOOL, ERROR_MORE_DATA, HMODULE},
3131
NetworkManagement::Ndis::NET_LUID_LH,
3232
Networking::WinSock::{
3333
ADDRESS_FAMILY, AF_INET, AF_INET6, IN6_ADDR, IN_ADDR, SOCKADDR_INET,
3434
},
35-
System::LibraryLoader::{
36-
FreeLibrary, GetProcAddress, LoadLibraryExW, LOAD_WITH_ALTERED_SEARCH_PATH,
37-
},
35+
System::LibraryLoader::{GetProcAddress, LoadLibraryExW, LOAD_WITH_ALTERED_SEARCH_PATH},
3836
},
3937
};
4038

0 commit comments

Comments
 (0)