Skip to content

Commit

Permalink
switch winreg to winreg2
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Dec 28, 2024
1 parent b0cdd85 commit 22aca7c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ targets = [
features = ["async"]

[features]
default = []
# default = [
# "verify_binary_signature",
# "panic_on_unsent_packets",
# "async",
# "winreg",
# "enable_inner_logging",
# ]
async = ["blocking", "futures"]
panic_on_unsent_packets = []
Expand Down Expand Up @@ -61,7 +61,7 @@ windows-sys = { version = "0.59", features = [
"Win32_System_LibraryLoader",
"Win32_Security_WinTrust",
] }
winreg = { version = "0.52.0", optional = true }
winreg = { package = "winreg2", version = "0.53", optional = true }

[dev-dependencies]
dotenvy = "0.15"
Expand Down
8 changes: 6 additions & 2 deletions src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ pub unsafe extern "stdcall" fn default_logger(
}) {
log::error!("Failed to log message: {}", e);
}
#[cfg(not(feature = "enable_inner_logging"))]
if _l == log::Level::Error {
log::error!("WinTun: {}", utf8_msg);
}
}

#[cfg(feature = "enable_inner_logging")]
Expand All @@ -84,11 +88,11 @@ fn get_worst_log_msg(container: &[LogItem]) -> Option<&LogItem> {

pub(crate) fn extract_wintun_log_error<T>(prifix: &str) -> Result<T, String> {
#[cfg(not(feature = "enable_inner_logging"))]
let info = "".to_string();
let info = "No inner logs".to_string();
#[cfg(feature = "enable_inner_logging")]
let info = get_worst_log_msg(&get_log())
.map(|item| item.msg.clone())
.unwrap_or_else(|| "No logs".to_string());
.unwrap_or_else(|| "No inner logs".to_string());
Err(format!("{} \"{}\"", prifix, info))
}

Expand Down

0 comments on commit 22aca7c

Please sign in to comment.