mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-14 14:17:25 -05:00
optimize runtime performance, eliminate AV flags, and apply maximum JS obfuscation
This commit is contained in:
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
@@ -4232,7 +4232,6 @@ dependencies = [
|
||||
"tauri-plugin-opener",
|
||||
"tauri-plugin-process",
|
||||
"tauri-plugin-shell",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -14,5 +14,16 @@ tauri-plugin-process = "2"
|
||||
tauri-plugin-shell = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
url = "2"
|
||||
base64 = "0.22"
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
strip = true
|
||||
panic = "abort"
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 0
|
||||
debug = true
|
||||
incremental = true
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=src/main.rs");
|
||||
println!("cargo:rerun-if-changed=tauri.conf.json");
|
||||
tauri_build::build();
|
||||
}
|
||||
@@ -49,75 +49,9 @@ fn clean_path(path: &std::path::Path) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn kill_processes_on_ports(ports: &[u16]) {
|
||||
use std::os::windows::process::CommandExt;
|
||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||
|
||||
let output = Command::new("netstat")
|
||||
.args(["-ano", "-p", "tcp"])
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.output();
|
||||
|
||||
if let Ok(out) = output {
|
||||
let text = String::from_utf8_lossy(&out.stdout);
|
||||
for line in text.lines() {
|
||||
for port in ports {
|
||||
let pattern = format!(":{}", port);
|
||||
if line.contains(&pattern) && line.contains("LISTENING") {
|
||||
if let Some(pid_str) = line.split_whitespace().last() {
|
||||
if let Ok(pid) = pid_str.parse::<u32>() {
|
||||
if pid > 0 && pid != std::process::id() {
|
||||
let _ = Command::new("taskkill")
|
||||
.args(["/PID", &pid.to_string(), "/T", "/F"])
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.output();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn kill_processes_on_ports(ports: &[u16]) {
|
||||
for port in ports {
|
||||
let _ = Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!(
|
||||
"fuser -k -9 {}/tcp 2>/dev/null || lsof -ti :{} | xargs -r kill -9",
|
||||
port, port
|
||||
))
|
||||
.output();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn kill_process_tree(pid: u32) {
|
||||
use std::os::windows::process::CommandExt;
|
||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||
let _ = Command::new("taskkill")
|
||||
.args(["/PID", &pid.to_string(), "/T", "/F"])
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.output();
|
||||
kill_processes_on_ports(&[3000, 3001, 4890, 4891, 4892, 7860]);
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn kill_process_tree(pid: u32) {
|
||||
unsafe {
|
||||
libc_kill_pgid(pid);
|
||||
}
|
||||
kill_processes_on_ports(&[3000, 3001, 4890, 4891, 4892, 7860]);
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
unsafe fn libc_kill_pgid(pid: u32) {
|
||||
let _ = Command::new("kill")
|
||||
.args(["-9", &format!("-{}", pid)])
|
||||
.output();
|
||||
fn kill_child_process(child: &mut Child) {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
}
|
||||
|
||||
fn find_node_binary(app: &tauri::App) -> Option<String> {
|
||||
@@ -561,12 +495,17 @@ const LINK_HANDLER_SCRIPT: &str = r##"
|
||||
}
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', injectLiquidNavBar);
|
||||
} else {
|
||||
injectLiquidNavBar();
|
||||
}
|
||||
setInterval(injectLiquidNavBar, 1000);
|
||||
const navObserver = new MutationObserver(() => {
|
||||
if (!document.getElementById('vyla-floating-nav')) {
|
||||
injectLiquidNavBar();
|
||||
}
|
||||
});
|
||||
navObserver.observe(document.documentElement, { childList: true, subtree: true });
|
||||
"##;
|
||||
|
||||
#[tauri::command]
|
||||
@@ -671,9 +610,8 @@ fn main() {
|
||||
get_logo_base64
|
||||
])
|
||||
.manage(NodeServices(Mutex::new(None)))
|
||||
.setup(|app| {
|
||||
.setup(|app| {
|
||||
debug_log("Tauri setup started");
|
||||
kill_processes_on_ports(&[3000, 3001, 4890, 4891, 4892, 7860]);
|
||||
let app_data = app.path().app_data_dir().unwrap_or_default();
|
||||
let app_data_str = clean_path(&app_data);
|
||||
|
||||
@@ -683,7 +621,7 @@ fn main() {
|
||||
.decorations(false)
|
||||
.transparent(true)
|
||||
.resizable(true)
|
||||
.devtools(true)
|
||||
.devtools(cfg!(debug_assertions))
|
||||
.initialization_script("window.__VYLA_WINDOW_LABEL = 'main';")
|
||||
.initialization_script(LINK_HANDLER_SCRIPT)
|
||||
.build()?;
|
||||
@@ -903,21 +841,16 @@ fn main() {
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.on_window_event(|window, event| {
|
||||
.on_window_event(|window, event| {
|
||||
if let tauri::WindowEvent::Destroyed = event {
|
||||
if window.label() == "main" {
|
||||
let state: State<NodeServices> = window.state();
|
||||
if let Ok(mut lock) = state.0.lock() {
|
||||
if let Some(child) = lock.take() {
|
||||
let pid = child.id();
|
||||
debug_log(&format!(
|
||||
"[SHUTDOWN] Main window destroyed, killing process tree for PID {}",
|
||||
pid
|
||||
));
|
||||
kill_process_tree(pid);
|
||||
if let Some(mut child) = lock.take() {
|
||||
debug_log("[SHUTDOWN] Main window destroyed, terminating node process natively");
|
||||
kill_child_process(&mut child);
|
||||
}
|
||||
};
|
||||
kill_processes_on_ports(&[3000, 3001, 4890, 4891, 4892, 7860]);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user