Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace windows-sys with windows #1976

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 137 additions & 11 deletions nym-vpn-core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions nym-vpn-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ serde_json = "1.0"
sha2 = "0.10"
si-scale = "0.2.3"
signature = "2.2.0"
socket2 = "0.5.8"
sqlx = "0.7.4"
strum = "0.26"
strum_macros = "0.26"
Expand Down Expand Up @@ -167,7 +166,7 @@ vergen = { version = "8.3.1", default-features = false }
which = { version = "7.0", default-features = false }
widestring = "1.0"
windows-service = "0.7.0"
windows-sys = "0.52"
windows = "0.59"
x25519-dalek = "2.0"
zeroize = "1.6.0"

Expand Down
2 changes: 1 addition & 1 deletion nym-vpn-core/crates/nym-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ tracing.workspace = true
libc.workspace = true
thiserror.workspace = true

[target.'cfg(windows)'.dependencies.windows-sys]
[target.'cfg(windows)'.dependencies.windows]
workspace = true
features = ["Win32_Foundation"]
17 changes: 0 additions & 17 deletions nym-vpn-core/crates/nym-common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,6 @@ impl BoxedError {
}
}

/// Helper macro allowing simpler handling of Windows FFI returning `WIN32_ERROR`
/// status codes. Converts a `WIN32_ERROR` into an `io::Result<()>`.
///
/// The caller of this macro must have `windows_sys` as a dependency.
#[cfg(windows)]
#[macro_export]
macro_rules! win32_err {
($expr:expr) => {{
let status = $expr;
if status == ::windows_sys::Win32::Foundation::NO_ERROR {
Ok(())
} else {
Err(::std::io::Error::from_raw_os_error(status as i32))
}
}};
}

pub mod flood {
use std::time::{Duration, Instant};

Expand Down
2 changes: 1 addition & 1 deletion nym-vpn-core/crates/nym-dns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ winreg = { version = "0.52", features = ["transactions"] }
nym-windows = { path = "../nym-windows" }
nym-common = { path = "../nym-common" }

[target.'cfg(windows)'.dependencies.windows-sys]
[target.'cfg(windows)'.dependencies.windows]
workspace = true
features = [
"Win32_Foundation",
Expand Down
4 changes: 2 additions & 2 deletions nym-vpn-core/crates/nym-dns/src/windows/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use super::{iphlpapi, netsh, tcpip};
use crate::{DnsMonitorT, ResolvedDnsConfig};
use windows_sys::Win32::System::Rpc::RPC_S_SERVER_UNAVAILABLE;
use windows::Win32::System::Rpc::RPC_S_SERVER_UNAVAILABLE;

pub struct DnsMonitor {
current_monitor: InnerMonitor,
Expand Down Expand Up @@ -86,7 +86,7 @@ impl DnsMonitor {
fn fallback_due_to_dnscache(&mut self, result: &Result<(), super::Error>) -> bool {
let is_dnscache_error = match result {
Err(super::Error::Iphlpapi(iphlpapi::Error::SetInterfaceDnsSettings(error))) => {
error.raw_os_error() == Some(RPC_S_SERVER_UNAVAILABLE)
error.code() == RPC_S_SERVER_UNAVAILABLE.to_hresult()
}
Err(super::Error::Netsh(netsh::Error::Netsh(Some(1)))) => true,
_ => false,
Expand Down
Loading
Loading