From db28e8525c10b54707434ec17a918dbca4eb38d6 Mon Sep 17 00:00:00 2001 From: Begild Date: Fri, 20 Sep 2024 08:54:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8rust=E7=9A=84=E5=AE=8F?= =?UTF-8?q?=E6=9D=A5=E6=8E=A7=E5=88=B6=E7=BC=96=E8=AF=91=EF=BC=8C=E6=98=AF?= =?UTF-8?q?=E7=9A=84=E5=8F=AF=E4=BB=A5=E9=80=82=E9=85=8D=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E7=8E=AF=E5=A2=83=E5=92=8C=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E7=9A=84=E6=AD=A3=E5=BC=8F=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 3 ++- src/lib.rs | 10 ++++++++-- src/main.rs | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2925093..8e1f3aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,4 +30,5 @@ env = { "RUST_LOG" = "debug" } [features] -atime_read = [] \ No newline at end of file +ekko_simulated = [] # 开启本地模拟,用于debug测试开发 +# default = ["ekko_simulated"] diff --git a/src/lib.rs b/src/lib.rs index 178a4db..ff05f08 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -235,14 +235,16 @@ impl MsgSyncPipe { } pub fn reply_msg(&mut self) { // read pipe file to update access time - #[cfg(features = "atime_read")] + #[cfg(not(feature = "ekko_simulated"))] { + print!("read pipe file to update access time"); let mut file = File::options().read(true).open(&self.pipe_file).unwrap(); let mut buffer = Vec::new(); let _ = file.read_to_end(&mut buffer); } - #[cfg(not(features = "atime_read"))] + #[cfg(feature = "ekko_simulated")] { + print!("write pipe file to update access time"); let mut file = File::options().write(true).open(&self.pipe_file).unwrap(); let _ = file.write("sstar_l0l3clip_sync".as_bytes()); drop(file); @@ -283,6 +285,7 @@ impl MsgSyncPipe { let sub_path = path.next().unwrap().to_string(); for drive in 'C'..='Z' { let sub_path = format!("{}:{}", drive, sub_path); + #[cfg(feature = "ekko_simulated")] let sub_path = sub_path.replace("baoyucang", "BYC10"); log::trace!("trying to find pipe file in {}", sub_path); let sync_pipe = Path::new(&sub_path).join("sync_pipe"); @@ -294,7 +297,10 @@ impl MsgSyncPipe { return Err("You should mapping l0 c:\\ to l3".into()) } } +#[cfg(feature = "ekko_simulated")] static VM_EXE_NAME:&str = "mstsc.exe"; +#[cfg(not(feature = "ekko_simulated"))] +static VM_EXE_NAME:&str = "vmware_view.exe"; // 同步获取消息的线程 async fn msg_reciver(ctx:Arc>) { let mut ctx = ctx.lock().await; diff --git a/src/main.rs b/src/main.rs index 0f92628..e8d654a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,8 +9,11 @@ use tokio::sync::Mutex; use std::sync::Arc; use clap::{App, Arg}; -// const SERVER:&str = "172.19.36.79"; + +#[cfg(feature = "ekko_simulated")] const SERVER:&str = "192.168.0.116:5000"; +#[cfg(not(feature = "ekko_simulated"))] +const SERVER:&str = "172.19.36.79"; fn param_parser() -> (Character, String) { let mut character = Character::Consumer;