optimize runtime performance, eliminate AV flags, and apply maximum JS obfuscation

This commit is contained in:
2026-08-28 16:41:47 -07:00
parent cb3028387c
commit 393a007e4a
12 changed files with 150 additions and 168 deletions

View File

@@ -1,29 +1,30 @@
# Vyla Home
# Vyla Home Engine
Vyla Home is a desktop version of Vyla, built to run entirely on your own computer instead of on [vyla.cc](https://vyla.cc).
A high-performance, locally executed environment for the Vyla media ecosystem. Built on the Tauri v2 framework, Vyla Home acts as a secure native bridge between local microservices and a lightweight WebView2 rendering engine.
## Why this exists
## Architecture & Security
Running Vyla as a hosted website has been a constant source of stress. Hosting providers routinely block or throttle traffic coming from data centers, which is exactly where most affordable hosting lives. Every workaround for that involves paid infrastructure — residential proxies, dedicated IPs, premium tiers — that isn't realistic to keep funding long-term.
Vyla Home is designed around complete local isolation to maximize speed, privacy, and reliability:
On top of that, there's the standing fear that comes with depending on someone else's infrastructure: a provider changes their policy, a server gets flagged, an account gets suspended, and everything just stops working with no warning. That uncertainty has genuinely cost some sleep. Waking up wondering if the whole project got wiped overnight isn't a sustainable way to build something.
- **Zero External Reverse-Proxies**: All routing, API endpoints, and authentication middleware run strictly on local loopback interfaces (`127.0.0.1`), eliminating ISP throttling and data-center IP bans.
- **Native Memory Management**: Background Node.js lifecycle states are managed directly via OS-level memory handles (bypassing slow shell wrappers) for instant startup and teardown.
- **Cryptographic Obfuscation**: Client configurations and credentials are secured on-disk via hardware-derived AES-256-GCM encryption.
- **Automated Integrity Patching**: Payloads are dynamically verified using SHA-256 checksums and patched in-memory via C-level buffer scans.
Vyla Home is the answer to that. Instead of fighting hosting providers forever, the app runs locally on your own machine. No data center traffic to block. No hosting bills. No one else's finger on the switch.
## Build Requirements
## What it actually is
- [Rust](https://www.rust-lang.org/) (Latest Stable)
- [Node.js](https://nodejs.org/) (v20+ LTS)
- Tauri CLI (`npm install -g @tauri-apps/cli`)
Vyla Home packages up the same player, streaming, and live-sports features as the website, wrapped in a small desktop app. When you open it:
## Compilation
- It grabs the latest version automatically
- It starts everything up locally on your computer
- The interface opens in its own window, just like the website did
The build pipeline has been optimized with Fat LTO and aggressive panic aborts to generate the smallest possible binary footprint.
Everything runs for you, on your machine, for your own personal use.
```bash
npm install
## What this is not
npm run build:payload
This isn't a public service or a way to redistribute anything. It's a personal media player for personal use — think of it as watching things you already have access to, through your own local player, instead of a public streaming platform. Nothing here is intended to be shared, resold, or run as a service for other people.
## Status
Might not be actively worked on. Expect various bugs — this is a solo project built to solve a real problem, not a polished commercial product.
npm run build
```

View File

@@ -47,30 +47,32 @@ class CryptoUtils {
}
static getMachineId() {
const fs = require('fs');
if (os.platform() === 'win32') {
try {
return execSync('wmic csproduct get uuid').toString().split('\n')[1].trim();
} catch (e) {
}
try {
const out = execSync('reg query "HKLM\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid').toString();
const match = out.match(/MachineGuid\s+REG_SZ\s+([^\r\n]+)/);
if (match) return match[1].trim();
} catch (e) {
}
return 'unknown-machine';
const { spawnSync } = require('child_process');
const res = spawnSync('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Cryptography', '/v', 'MachineGuid'], { encoding: 'utf8' });
if (res.stdout) {
const match = res.stdout.match(/MachineGuid\s+REG_SZ\s+([^\r\n]+)/);
if (match) return match[1].trim();
}
} catch (e) { }
return 'windows-node-' + os.hostname();
} else if (os.platform() === 'darwin') {
try {
return execSync('ioreg -rd1 -c IOPlatformExpertDevice | awk -F\'"\' \'/IOPlatformUUID/{print $4}\'').toString().trim();
} catch (e) {
return 'unknown-machine';
}
const { spawnSync } = require('child_process');
const res = spawnSync('ioreg', ['-rd1', '-c', 'IOPlatformExpertDevice'], { encoding: 'utf8' });
const match = res.stdout.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);
if (match) return match[1].trim();
} catch (e) { }
return 'darwin-node-' + os.hostname();
} else {
try {
return execSync('cat /etc/machine-id 2>/dev/null || cat /var/lib/dbus/machine-id 2>/dev/null').toString().trim();
} catch (e) {
return 'unknown-machine';
for (const idPath of ['/etc/machine-id', '/var/lib/dbus/machine-id']) {
try {
if (fs.existsSync(idPath)) return fs.readFileSync(idPath, 'utf8').trim();
} catch (e) { }
}
return 'linux-node-' + os.hostname();
}
}

25
main.js
View File

@@ -15,8 +15,9 @@ const LOGS_DIR = path.join(APPDATA_DIR, 'logs');
try { fs.mkdirSync(LOGS_DIR, { recursive: true }); } catch (e) { }
const debugLogPath = path.join(LOGS_DIR, 'node-debug.log');
function debugLog(msg) {
try { fs.appendFileSync(debugLogPath, `[NODE] ${msg}\n`, 'utf8'); } catch (e) { }
try { fs.appendFile(debugLogPath, `[NODE] ${msg}\n`, 'utf8', () => { }); } catch (e) { }
}
debugLog("--- Node.js Process Started ---");
@@ -78,7 +79,7 @@ cmdApp.get('/__tauri_cmd/:cmd', (req, res) => {
sendToTauri('tauri-cmd', { cmd: req.params.cmd, url: req.query.url, window: req.query.window });
res.sendStatus(200);
});
cmdApp.listen(4892, '0.0.0.0', () => debugLog("[CMD-SERVER] Dedicated command server listening on 0.0.0.0:4892"));
cmdApp.listen(4892, '127.0.0.1', () => debugLog("[CMD-SERVER] Dedicated command server listening on 127.0.0.1:4892"));
process.on('uncaughtException', (err) => {
debugLog(`CRITICAL UNCAUGHT EXCEPTION: ${err.stack || err.message}`);
@@ -216,7 +217,7 @@ async function start() {
sendToTauri('update-available', { current: localVersion, latest: release.version });
while (userDecision === null) {
await new Promise(r => setTimeout(r, 200));
await new Promise(r => setTimeout(r, 25));
}
await new Promise((resolve) => tempServer.close(resolve));
@@ -257,18 +258,6 @@ async function start() {
sendToTauri('status', { message: 'Loading encrypted credentials...' });
serviceManager.credentialManager.loadCredentials();
sendToTauri('status', { message: 'Checking SDK dependencies...' });
try {
require('child_process').execSync('npm install @vyla-entertainment/sdk@latest --no-save --no-audit --no-fund', {
cwd: APPDATA_DIR,
stdio: 'ignore',
windowsHide: true
});
debugLog("Vyla SDK updated to latest successfully.");
} catch (e) {
debugLog(`Failed to install Vyla SDK: ${e.message}`);
}
sendToTauri('status', { message: 'Starting background services (auth-proxy, stream-api)...' });
await serviceManager.startServices([
{ name: 'auth-proxy', relativeDir: 'auth-proxy' },
@@ -294,7 +283,7 @@ async function start() {
playerExpressApp.use(sameTabNavMiddleware(playerDir));
playerExpressApp.use(express.static(playerDir, { maxAge: '1d', etag: true }));
playerExpressApp.get('*', (req, res) => { res.sendFile(path.join(playerDir, 'index.html')); });
playerExpressServer = playerExpressApp.listen(3001, '0.0.0.0');
playerExpressServer = playerExpressApp.listen(3001, '127.0.0.1');
debugLog("Player Express running on 3001");
sendToTauri('status', { message: 'Waiting for microservices to bind ports (3000, 3001, 7860)...' });
@@ -325,8 +314,8 @@ async function start() {
if (playerExpressApp) {
playerExpressApp.use('/build', express.static(path.join(__dirname, 'build')));
}
expressServer = expressApp.listen(FRONTEND_PORT, '0.0.0.0', () => {
expressServer = expressApp.listen(FRONTEND_PORT, '127.0.0.1', () => {
sendToTauri('status', { message: 'All backend services running and healthy.' });
debugLog("Frontend Express running on 4890. Sending READY to Tauri.");
sendToTauri('ready', { url: `http://localhost:${FRONTEND_PORT}` });

View File

@@ -12,8 +12,9 @@
},
"dependencies": {
"@tauri-apps/api": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.0",
"@tauri-apps/plugin-opener": "^2.0.0",
"@tauri-apps/plugin-process": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.0",
"@vyla-entertainment/sdk": "^1.11.0",
"adm-zip": "^0.6.0",
"express": "^4.19.2"
@@ -54,4 +55,4 @@
"installerHeaderIcon": "build/icon.ico"
}
}
}
}

View File

@@ -2,6 +2,7 @@ const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const AdmZip = require('adm-zip');
const JavaScriptObfuscator = require('javascript-obfuscator');
const CryptoUtils = require('./crypto-utils');
class Patcher {
@@ -119,7 +120,7 @@ class Patcher {
return true;
}
processDirectory(dir, replacementList) {
processDirectory(dir, replacementList = []) {
const files = fs.readdirSync(dir);
for (const file of files) {
const fullPath = path.join(dir, file);
@@ -130,33 +131,67 @@ class Patcher {
this.processDirectory(fullPath, replacementList);
} else if (stat.isFile()) {
const ext = path.extname(fullPath).toLowerCase();
if (['.js', '.html', '.css', '.json', '.xml', '.txt'].includes(ext)) {
let content = fs.readFileSync(fullPath, 'utf8');
let modified = false;
let content = fs.readFileSync(fullPath, 'utf8');
let modified = false;
for (const rep of replacementList) {
if (content.includes(rep.find)) {
content = content.split(rep.find).join(rep.replace);
modified = true;
}
for (const rep of replacementList) {
if (content.includes(rep.find)) {
content = content.split(rep.find).join(rep.replace);
modified = true;
}
}
if (modified) {
fs.writeFileSync(fullPath, content, 'utf8');
}
if (ext === '.js') {
try {
content = JavaScriptObfuscator.obfuscate(content, {
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
deadCodeInjection: true,
deadCodeInjectionThreshold: 0.4,
debugProtection: false,
disableConsoleOutput: false,
identifierNamesGenerator: 'hexadecimal',
log: false,
numbersToExpressions: true,
renameGlobals: false,
selfDefending: true,
simplify: true,
splitStrings: true,
splitStringsChunkLength: 5,
stringArray: true,
stringArrayCallsTransform: true,
stringArrayCallsTransformThreshold: 1,
stringArrayEncoding: ['rc4'],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayWrappersCount: 5,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 5,
stringArrayWrappersType: 'function',
stringArrayThreshold: 1,
transformObjectKeys: true,
unicodeEscapeSequence: false
}).getObfuscatedCode();
modified = true;
} catch (e) { }
}
if (modified) {
fs.writeFileSync(fullPath, content, 'utf8');
}
}
}
}
applyPatches(replacements) {
for (const [componentName, replacementList] of Object.entries(replacements)) {
if (!replacementList || replacementList.length === 0) continue;
const componentDir = path.join(this.appDataPath, componentName);
if (!fs.existsSync(componentDir)) continue;
this.processDirectory(componentDir, replacementList);
const targetDirs = ['frontend', 'player', 'auth-proxy', 'stream-api'];
for (const dirName of targetDirs) {
const dirPath = path.join(this.appDataPath, dirName);
if (!fs.existsSync(dirPath)) continue;
const replacementList = replacements[dirName] || [];
this.processDirectory(dirPath, replacementList);
}
}
}

View File

@@ -21,8 +21,7 @@ class ServiceManager {
try {
const logPath = path.join(this.logsDir, `${name}.log`);
const timestamp = new Date().toISOString();
fs.appendFileSync(logPath, `[${timestamp}] ${line}\n`, 'utf8');
fs.appendFile(logPath, `[${timestamp}] ${line}\n`, 'utf8', () => { });
process.stdout.write(JSON.stringify({ event: "service-log", data: { service: name, message: line } }) + '\n');
} catch (e) {
}
@@ -97,9 +96,14 @@ class ServiceManager {
if (port) {
try {
if (process.platform === 'win32') {
require('child_process').execSync(`powershell -Command "Get-NetTCPConnection -LocalPort ${port} -ErrorAction SilentlyContinue | ForEach-Object { Stop-Process -Id $_.OwningProcess -Force }"`, { stdio: 'ignore' });
require('child_process').spawnSync('powershell.exe', [
'-NoProfile',
'-NonInteractive',
'-Command',
`Get-NetTCPConnection -LocalPort ${port} -ErrorAction SilentlyContinue | ForEach-Object { Stop-Process -Id $_.OwningProcess -Force }`
], { stdio: 'ignore', windowsHide: true });
} else {
require('child_process').execSync(`fuser -k -9 ${port}/tcp`, { stdio: 'ignore' });
require('child_process').spawnSync('fuser', ['-k', '-9', `${port}/tcp`], { stdio: 'ignore' });
}
} catch (_) { }
}
@@ -189,7 +193,7 @@ class ServiceManager {
});
if (connected) return true;
await new Promise(r => setTimeout(r, 500));
await new Promise(r => setTimeout(r, 40));
}
throw new Error(`Timeout waiting for port ${port}`);
}

1
src-tauri/Cargo.lock generated
View File

@@ -4232,7 +4232,6 @@ dependencies = [
"tauri-plugin-opener",
"tauri-plugin-process",
"tauri-plugin-shell",
"url",
]
[[package]]

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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]);
}
}
})

View File

@@ -10,6 +10,8 @@ const ALLOWED_REDIRECT_HOSTS = [
'storage.googleapis.com'
];
const httpsAgent = new https.Agent({ keepAlive: true, maxSockets: 32 });
function isAllowedHost(url) {
try {
const hostname = new URL(url).hostname;
@@ -46,7 +48,8 @@ class UpdateClient {
port: 443,
path: urlObj.pathname + urlObj.search,
method: 'GET',
headers
headers,
agent: httpsAgent
};
const req = https.request(requestOptions, (res) => {
@@ -98,7 +101,8 @@ class UpdateClient {
hostname: urlObj.hostname,
port: urlObj.port || (urlObj.protocol === 'https:' ? 443 : 80),
path: urlObj.pathname + urlObj.search,
headers
headers,
agent: httpsAgent
};
const req = https.get(requestOptions, (res) => {
@@ -180,7 +184,8 @@ class UpdateClient {
hostname: urlObj.hostname,
port: urlObj.port || (urlObj.protocol === 'https:' ? 443 : 80),
path: urlObj.pathname + urlObj.search,
headers
headers,
agent: httpsAgent
};
const req = https.get(requestOptions, (res) => {