feat(ironrdp-client): add ability to collect sspi-rs logs (#100)

This commit is contained in:
Alex Yusiuk
2023-03-29 22:34:07 +00:00
committed by GitHub
parent eba943d812
commit 4ad13df499
7 changed files with 138 additions and 7 deletions
Generated
+102 -2
View File
@@ -1652,6 +1652,8 @@ dependencies = [
"tokio",
"tokio-rustls",
"tokio-util",
"tracing",
"tracing-subscriber",
"whoami",
"winit 0.28.2",
"x509-parser 0.14.0",
@@ -1952,6 +1954,15 @@ dependencies = [
"libc",
]
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata",
]
[[package]]
name = "md-5"
version = "0.8.0"
@@ -2223,6 +2234,16 @@ dependencies = [
"minimal-lexical",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "num-bigint"
version = "0.2.6"
@@ -2550,6 +2571,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "owned_ttf_parser"
version = "0.18.1"
@@ -3051,6 +3078,24 @@ dependencies = [
"bitflags",
]
[[package]]
name = "regex"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.28"
@@ -3523,6 +3568,15 @@ dependencies = [
"keccak",
]
[[package]]
name = "sharded-slab"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
dependencies = [
"lazy_static",
]
[[package]]
name = "shared_library"
version = "0.1.9"
@@ -3682,9 +3736,9 @@ dependencies = [
[[package]]
name = "sspi"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e676b09028bca74185041e073a467e71112c19e4032fc290df82a4ad10c390e"
checksum = "f820e38002148b97ce7e90eb4c77fb81023c304b87a74f396893157d8a6521c9"
dependencies = [
"async-dnssd",
"bitflags",
@@ -3837,6 +3891,16 @@ dependencies = [
"syn 1.0.104",
]
[[package]]
name = "thread_local"
version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
dependencies = [
"cfg-if 1.0.0",
"once_cell",
]
[[package]]
name = "time"
version = "0.1.45"
@@ -4044,6 +4108,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-log"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
[[package]]
@@ -4142,6 +4236,12 @@ dependencies = [
"serde",
]
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "vcpkg"
version = "0.2.15"
+1 -1
View File
@@ -28,7 +28,7 @@ opt-level = "s"
ironrdp = { path = "../../ironrdp" }
ironrdp-session = { path = "../../ironrdp-session", features = ["dgw_ext"] } # FIXME: secret feature until session state machine is done
ironrdp-input = { path = "../../ironrdp-input" }
sspi = "0.7"
sspi = "0.8"
# Wasm
wasm-bindgen = "0.2.83"
+1 -1
View File
@@ -21,7 +21,7 @@ custom-protocol = [ "tauri/custom-protocol" ]
# Protocol
ironrdp = { path = "../../ironrdp" }
sspi = { version = "0.7", features = ["network_client"] }
sspi = { version = "0.8", features = ["network_client"] }
serde = { version = "1.0", features = ["derive"] }
# SSL
+1 -1
View File
@@ -18,7 +18,7 @@ native-tls = ["dep:async-native-tls", "ironrdp/native-tls"]
# Protocol
ironrdp = { path = "../ironrdp" }
sspi = { version = "0.7", features = ["network_client"] }
sspi = { version = "0.8", features = ["network_client"] }
# CLI
clap = { version = "4.0", features = ["derive", "cargo"] }
+3 -1
View File
@@ -19,7 +19,7 @@ native-tls = ["dep:async-native-tls", "ironrdp/native-tls"]
# Protocol
ironrdp = { path = "../ironrdp" }
ironrdp-input = { path = "../ironrdp-input" }
sspi = { version = "0.7", features = ["network_client"] } # TODO: enable dns_resolver at some point
sspi = { version = "0.8.0", features = ["network_client"] } # TODO: enable dns_resolver at some point
# GUI
softbuffer = "0.2.0"
@@ -49,3 +49,5 @@ chrono = "0.4.23"
whoami = "1.2.3"
anyhow = "1.0.68"
smallvec = "1.10.0"
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
tracing = "0.1.37"
+29
View File
@@ -1,11 +1,15 @@
#[macro_use]
extern crate log;
use std::fs::OpenOptions;
use anyhow::Context as _;
use ironrdp_client::config::Config;
use ironrdp_client::gui::GuiContext;
use ironrdp_client::rdp::{RdpClient, RdpInputEvent};
use tokio::runtime;
use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt;
use tracing_subscriber::EnvFilter;
fn main() -> anyhow::Result<()> {
let mut config = Config::parse_args().context("CLI arguments parsing")?;
@@ -57,5 +61,30 @@ fn setup_logging(log_file: &str) -> Result<(), fern::InitError> {
.chain(fern::log_file(log_file)?)
.apply()?;
// sspi-rs logging
if let Ok(path) = std::env::var("SSPI_LOG_FILE") {
let file = match OpenOptions::new().read(true).append(true).open(path) {
Ok(file) => file,
Err(e) => {
warn!("Can not open sspi-rs log file: {:?}", e);
return Ok(());
}
};
let fmt_layer = tracing_subscriber::fmt::layer()
.pretty()
.with_thread_names(true)
.with_writer(file);
let reg = tracing_subscriber::registry()
.with(fmt_layer)
.with(EnvFilter::from_env("SSPI_LOG_LEVEL"));
if let Err(err) = tracing::subscriber::set_global_default(reg) {
warn!("Can not set sspi-rs logger: {:?}", err);
}
}
Ok(())
}
+1 -1
View File
@@ -18,7 +18,7 @@ dgw_ext = []
ironrdp-core = { path = "../ironrdp-core" }
ironrdp-graphics = { path = "../ironrdp-graphics" }
ironrdp-rdcleanpath = { path = "../ironrdp-rdcleanpath" } # FIXME: Quick and dirty approach, this should not be here
sspi = "0.7"
sspi = "0.8"
bytes = "1"
log = "0.4"
whoami = "1"