tamga-vdesktop 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +499 -100
- package/dist/client/assets/index-C0HIq_1z.css +32 -0
- package/dist/client/assets/index-Cb0WKMVS.js +410 -0
- package/dist/client/index.html +2 -2
- package/dist/helpers/x11_bridge.py +195 -76
- package/dist/helpers/x11_streamer.py +268 -0
- package/dist/server.js +480 -81
- package/package.json +1 -1
- package/dist/client/assets/index-Dc9pcCtt.js +0 -410
- package/dist/client/assets/index-PKZga7Cp.css +0 -32
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// server/cli.ts
|
|
4
|
-
import
|
|
4
|
+
import fs9 from "node:fs";
|
|
5
5
|
import os6 from "node:os";
|
|
6
|
-
import
|
|
6
|
+
import path9 from "node:path";
|
|
7
7
|
import readline from "node:readline";
|
|
8
|
-
import { execSync as
|
|
8
|
+
import { execSync as execSync4, spawnSync } from "node:child_process";
|
|
9
9
|
|
|
10
10
|
// server/config.ts
|
|
11
11
|
import fs from "node:fs";
|
|
@@ -191,17 +191,18 @@ echo "deb [signed-by=/etc/apt/keyrings/antigravity-repo-key.gpg] https://us-cent
|
|
|
191
191
|
apt-get update -y && apt-get install -y antigravity`
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
|
-
id: "
|
|
195
|
-
name: "
|
|
196
|
-
description: "
|
|
197
|
-
binaryNames: ["
|
|
198
|
-
defaultCommand: "
|
|
194
|
+
id: "chrome",
|
|
195
|
+
name: "Google Chrome",
|
|
196
|
+
description: "Resmi Google Chrome web taray\u0131c\u0131s\u0131 (.deb, Snap olmadan)",
|
|
197
|
+
binaryNames: ["google-chrome-stable", "google-chrome"],
|
|
198
|
+
defaultCommand: "google-chrome-stable",
|
|
199
199
|
category: "browser",
|
|
200
200
|
needsNoSandbox: true,
|
|
201
201
|
installScript: `set -e
|
|
202
202
|
export DEBIAN_FRONTEND=noninteractive
|
|
203
|
-
|
|
204
|
-
apt-get
|
|
203
|
+
wget -q -O /tmp/google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
204
|
+
apt-get update -y && apt-get install -y /tmp/google-chrome.deb
|
|
205
|
+
rm -f /tmp/google-chrome.deb`
|
|
205
206
|
},
|
|
206
207
|
{
|
|
207
208
|
id: "mousepad",
|
|
@@ -442,10 +443,10 @@ apt-get update -y && apt-get install -y ${cleanPkg}`;
|
|
|
442
443
|
// server/index.ts
|
|
443
444
|
import express from "express";
|
|
444
445
|
import cors from "cors";
|
|
445
|
-
import
|
|
446
|
+
import http2 from "node:http";
|
|
446
447
|
import os5 from "node:os";
|
|
447
|
-
import
|
|
448
|
-
import
|
|
448
|
+
import path8 from "node:path";
|
|
449
|
+
import fs8 from "node:fs";
|
|
449
450
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
450
451
|
import multer from "multer";
|
|
451
452
|
import { WebSocketServer, WebSocket } from "ws";
|
|
@@ -2256,6 +2257,25 @@ function findFreeDisplay(inUse) {
|
|
|
2256
2257
|
}
|
|
2257
2258
|
return 100 + Math.floor(Math.random() * 100);
|
|
2258
2259
|
}
|
|
2260
|
+
function hasTurboJpegAndXDamage() {
|
|
2261
|
+
const candidates = [
|
|
2262
|
+
"/lib/x86_64-linux-gnu/libturbojpeg.so.0",
|
|
2263
|
+
"/usr/lib/x86_64-linux-gnu/libturbojpeg.so.0",
|
|
2264
|
+
"/lib/aarch64-linux-gnu/libturbojpeg.so.0",
|
|
2265
|
+
"/usr/lib/aarch64-linux-gnu/libturbojpeg.so.0",
|
|
2266
|
+
"/usr/lib/libturbojpeg.so.0"
|
|
2267
|
+
];
|
|
2268
|
+
const hasTj = candidates.some((p) => fs6.existsSync(p));
|
|
2269
|
+
const dmgCandidates = [
|
|
2270
|
+
"/lib/x86_64-linux-gnu/libXdamage.so.1",
|
|
2271
|
+
"/usr/lib/x86_64-linux-gnu/libXdamage.so.1",
|
|
2272
|
+
"/lib/aarch64-linux-gnu/libXdamage.so.1",
|
|
2273
|
+
"/usr/lib/aarch64-linux-gnu/libXdamage.so.1",
|
|
2274
|
+
"/usr/lib/libXdamage.so.1"
|
|
2275
|
+
];
|
|
2276
|
+
const hasDmg = dmgCandidates.some((p) => fs6.existsSync(p));
|
|
2277
|
+
return hasTj && hasDmg;
|
|
2278
|
+
}
|
|
2259
2279
|
function buildOpenboxRcXml() {
|
|
2260
2280
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
2261
2281
|
<openbox_config xmlns="http://openbox.org/3.4/rc">
|
|
@@ -2281,6 +2301,7 @@ var LinuxAppSession = class {
|
|
|
2281
2301
|
displayNum;
|
|
2282
2302
|
displayStr;
|
|
2283
2303
|
title;
|
|
2304
|
+
cursor = "default";
|
|
2284
2305
|
width;
|
|
2285
2306
|
height;
|
|
2286
2307
|
startedAt = Date.now();
|
|
@@ -2295,12 +2316,14 @@ var LinuxAppSession = class {
|
|
|
2295
2316
|
openboxProc = null;
|
|
2296
2317
|
appProc = null;
|
|
2297
2318
|
x11BridgeProc = null;
|
|
2298
|
-
|
|
2319
|
+
streamerProc = null;
|
|
2320
|
+
streamerMode = "xdamage";
|
|
2299
2321
|
parecProc = null;
|
|
2300
2322
|
pulseSinkName = "";
|
|
2301
2323
|
subscribers = /* @__PURE__ */ new Set();
|
|
2302
2324
|
lastFrame = null;
|
|
2303
2325
|
resizeTimer = null;
|
|
2326
|
+
hadWindow = false;
|
|
2304
2327
|
closed = false;
|
|
2305
2328
|
onCloseCb;
|
|
2306
2329
|
constructor(opts, displayNum, onCloseCb) {
|
|
@@ -2318,10 +2341,13 @@ var LinuxAppSession = class {
|
|
|
2318
2341
|
this.height = Math.max(300, Math.min(1080, Math.round(opts.height || 680)));
|
|
2319
2342
|
this.width = this.width - this.width % 2;
|
|
2320
2343
|
this.height = this.height - this.height % 2;
|
|
2321
|
-
this.fps = Math.max(
|
|
2344
|
+
this.fps = Math.max(10, Math.min(30, opts.fps || 24));
|
|
2322
2345
|
this.quality = Math.max(2, Math.min(10, opts.quality || 4));
|
|
2323
2346
|
this.enableAudio = opts.enableAudio ?? true;
|
|
2324
|
-
this.tempDir = path6.join(
|
|
2347
|
+
this.tempDir = path6.join(
|
|
2348
|
+
os4.tmpdir(),
|
|
2349
|
+
`tamga-gui-${this.sessionId.replace(/[^a-z0-9_-]/gi, "")}`
|
|
2350
|
+
);
|
|
2325
2351
|
this.onCloseCb = onCloseCb;
|
|
2326
2352
|
}
|
|
2327
2353
|
async start() {
|
|
@@ -2330,13 +2356,27 @@ var LinuxAppSession = class {
|
|
|
2330
2356
|
fs6.writeFileSync(obRcPath, buildOpenboxRcXml(), "utf-8");
|
|
2331
2357
|
this.xvfbProc = spawn3(
|
|
2332
2358
|
"Xvfb",
|
|
2333
|
-
[
|
|
2359
|
+
[
|
|
2360
|
+
this.displayStr,
|
|
2361
|
+
"-screen",
|
|
2362
|
+
"0",
|
|
2363
|
+
"1920x1080x24",
|
|
2364
|
+
"-ac",
|
|
2365
|
+
"+extension",
|
|
2366
|
+
"RANDR",
|
|
2367
|
+
"+extension",
|
|
2368
|
+
"DAMAGE",
|
|
2369
|
+
"+extension",
|
|
2370
|
+
"XFIXES",
|
|
2371
|
+
"+render",
|
|
2372
|
+
"-noreset"
|
|
2373
|
+
],
|
|
2334
2374
|
{ stdio: "ignore" }
|
|
2335
2375
|
);
|
|
2336
2376
|
const xSocket = `/tmp/.X11-unix/X${this.displayNum}`;
|
|
2337
2377
|
for (let i = 0; i < 40; i++) {
|
|
2338
2378
|
if (fs6.existsSync(xSocket)) break;
|
|
2339
|
-
await new Promise((r) => setTimeout(r,
|
|
2379
|
+
await new Promise((r) => setTimeout(r, 60));
|
|
2340
2380
|
}
|
|
2341
2381
|
const baseEnv = {
|
|
2342
2382
|
...process.env,
|
|
@@ -2345,7 +2385,8 @@ var LinuxAppSession = class {
|
|
|
2345
2385
|
GDK_SCALE: "1",
|
|
2346
2386
|
QT_AUTO_SCREEN_SCALE_FACTOR: "0",
|
|
2347
2387
|
MOZ_ENABLE_WAYLAND: "0",
|
|
2348
|
-
GTK_CSD: "0"
|
|
2388
|
+
GTK_CSD: "0",
|
|
2389
|
+
NO_AT_BRIDGE: "1"
|
|
2349
2390
|
};
|
|
2350
2391
|
this.openboxProc = spawn3("openbox", ["--config-file", obRcPath], {
|
|
2351
2392
|
env: baseEnv,
|
|
@@ -2356,24 +2397,28 @@ var LinuxAppSession = class {
|
|
|
2356
2397
|
}
|
|
2357
2398
|
this.startX11Bridge(baseEnv);
|
|
2358
2399
|
this.launchTargetApp(baseEnv);
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
}
|
|
2400
|
+
if (hasTurboJpegAndXDamage()) {
|
|
2401
|
+
this.startXDamageStreamer(baseEnv);
|
|
2402
|
+
} else {
|
|
2403
|
+
this.startFfmpegFallbackCapture();
|
|
2404
|
+
}
|
|
2362
2405
|
}
|
|
2363
2406
|
setupPulseAudio(baseEnv) {
|
|
2364
2407
|
try {
|
|
2365
2408
|
try {
|
|
2366
|
-
execSync2("pactl info", { stdio: "ignore", timeout:
|
|
2409
|
+
execSync2("pactl info", { stdio: "ignore", timeout: 1200 });
|
|
2367
2410
|
} catch {
|
|
2368
|
-
spawn3(
|
|
2369
|
-
|
|
2370
|
-
|
|
2411
|
+
spawn3(
|
|
2412
|
+
"pulseaudio",
|
|
2413
|
+
["--daemonize=yes", "--exit-idle-time=-1", "--disallow-module-loading=0", "--no-cpu-limit"],
|
|
2414
|
+
{ stdio: "ignore" }
|
|
2415
|
+
);
|
|
2371
2416
|
}
|
|
2372
2417
|
const sinkName = `tamga_${this.sessionId.replace(/[^a-z0-9]/gi, "").slice(-10)}`;
|
|
2373
2418
|
try {
|
|
2374
2419
|
execSync2(
|
|
2375
2420
|
`pactl load-module module-null-sink sink_name=${sinkName} sink_properties=device.description=${sinkName}`,
|
|
2376
|
-
{ stdio: "ignore", timeout:
|
|
2421
|
+
{ stdio: "ignore", timeout: 1500 }
|
|
2377
2422
|
);
|
|
2378
2423
|
this.pulseSinkName = sinkName;
|
|
2379
2424
|
baseEnv.PULSE_SINK = sinkName;
|
|
@@ -2417,10 +2462,14 @@ var LinuxAppSession = class {
|
|
|
2417
2462
|
}
|
|
2418
2463
|
startX11Bridge(baseEnv) {
|
|
2419
2464
|
const scriptPath = resolveHelperPath("x11_bridge.py");
|
|
2420
|
-
const proc = spawn3(
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2465
|
+
const proc = spawn3(
|
|
2466
|
+
"python3",
|
|
2467
|
+
["-u", scriptPath, this.displayStr, String(this.width), String(this.height)],
|
|
2468
|
+
{
|
|
2469
|
+
env: baseEnv,
|
|
2470
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
2471
|
+
}
|
|
2472
|
+
);
|
|
2424
2473
|
this.x11BridgeProc = proc;
|
|
2425
2474
|
let lineBuf = "";
|
|
2426
2475
|
proc.stdout?.on("data", (chunk) => {
|
|
@@ -2433,7 +2482,16 @@ var LinuxAppSession = class {
|
|
|
2433
2482
|
try {
|
|
2434
2483
|
const msg = JSON.parse(line);
|
|
2435
2484
|
if (msg.type === "title" && typeof msg.title === "string") {
|
|
2485
|
+
this.hadWindow = true;
|
|
2436
2486
|
this.title = msg.title;
|
|
2487
|
+
} else if (msg.type === "cursor" && typeof msg.cursor === "string") {
|
|
2488
|
+
this.cursor = msg.cursor;
|
|
2489
|
+
} else if (msg.type === "all_windows_closed" && !this.closed) {
|
|
2490
|
+
for (const sub of this.subscribers) {
|
|
2491
|
+
sub.onEvent({ type: "app_exit", code: 0 });
|
|
2492
|
+
}
|
|
2493
|
+
this.close();
|
|
2494
|
+
return;
|
|
2437
2495
|
}
|
|
2438
2496
|
for (const sub of this.subscribers) {
|
|
2439
2497
|
sub.onEvent(msg);
|
|
@@ -2446,7 +2504,11 @@ var LinuxAppSession = class {
|
|
|
2446
2504
|
});
|
|
2447
2505
|
}
|
|
2448
2506
|
launchTargetApp(baseEnv) {
|
|
2449
|
-
const profileDir = path6.join(
|
|
2507
|
+
const profileDir = path6.join(
|
|
2508
|
+
this.desktopDataRoot,
|
|
2509
|
+
"app-profiles",
|
|
2510
|
+
this.appId.replace(/[^a-z0-9_-]/gi, "_")
|
|
2511
|
+
);
|
|
2450
2512
|
fs6.mkdirSync(profileDir, { recursive: true });
|
|
2451
2513
|
const desktopFilesDir = path6.join(this.desktopDataRoot, "vfs", "Desktop");
|
|
2452
2514
|
fs6.mkdirSync(desktopFilesDir, { recursive: true });
|
|
@@ -2467,6 +2529,13 @@ var LinuxAppSession = class {
|
|
|
2467
2529
|
'user_pref("toolkit.telemetry.reportingpolicy.firstRun", false);',
|
|
2468
2530
|
'user_pref("browser.startup.homepage", "https://www.google.com");',
|
|
2469
2531
|
'user_pref("browser.tabs.inTitlebar", 0);',
|
|
2532
|
+
'user_pref("general.smoothScroll", false);',
|
|
2533
|
+
'user_pref("toolkit.cosmeticAnimations.enabled", false);',
|
|
2534
|
+
'user_pref("ui.prefersReducedMotion", 1);',
|
|
2535
|
+
'user_pref("dom.ipc.processCount", 2);',
|
|
2536
|
+
'user_pref("browser.sessionstore.interval", 60000);',
|
|
2537
|
+
'user_pref("browser.newtabpage.activity-stream.feeds.topsites", false);',
|
|
2538
|
+
'user_pref("browser.newtabpage.activity-stream.feeds.section.topstories", false);',
|
|
2470
2539
|
'user_pref("gfx.webrender.software", true);',
|
|
2471
2540
|
'user_pref("gfx.x11-egl.force-disabled", true);',
|
|
2472
2541
|
'user_pref("browser.download.dir", ' + JSON.stringify(path6.join(this.desktopDataRoot, "vfs", "Downloads")) + ");",
|
|
@@ -2475,7 +2544,7 @@ var LinuxAppSession = class {
|
|
|
2475
2544
|
"utf-8"
|
|
2476
2545
|
);
|
|
2477
2546
|
finalCmd = `${finalCmd} --no-remote -profile "${profileDir}" --width=${this.width} --height=${this.height}`;
|
|
2478
|
-
} else if (this.needsNoSandbox || ["code", "antigravity", "chromium", "chromium-browser", "google-chrome"].includes(baseBin)) {
|
|
2547
|
+
} else if (this.needsNoSandbox || ["code", "antigravity", "chromium", "chromium-browser", "google-chrome", "google-chrome-stable"].includes(baseBin)) {
|
|
2479
2548
|
const extraFlags = [];
|
|
2480
2549
|
if (isRoot && !finalCmd.includes("--no-sandbox")) {
|
|
2481
2550
|
extraFlags.push("--no-sandbox");
|
|
@@ -2484,49 +2553,135 @@ var LinuxAppSession = class {
|
|
|
2484
2553
|
extraFlags.push(`--user-data-dir="${profileDir}"`);
|
|
2485
2554
|
}
|
|
2486
2555
|
if (!finalCmd.includes("--disable-gpu")) {
|
|
2487
|
-
extraFlags.push("--disable-gpu
|
|
2556
|
+
extraFlags.push("--disable-gpu", "--disable-dev-shm-usage");
|
|
2557
|
+
}
|
|
2558
|
+
if ((baseBin === "code" || baseBin === "antigravity") && !finalCmd.includes("--verbose")) {
|
|
2559
|
+
extraFlags.push("--verbose");
|
|
2488
2560
|
}
|
|
2489
2561
|
finalCmd = `${finalCmd} ${extraFlags.join(" ")}`;
|
|
2490
2562
|
}
|
|
2491
|
-
|
|
2492
|
-
this.appProc = spawn3("/bin/bash", ["-c", wrapped], {
|
|
2563
|
+
this.appProc = spawn3("/bin/bash", ["-c", `exec ${finalCmd}`], {
|
|
2493
2564
|
cwd: desktopFilesDir,
|
|
2494
2565
|
env: {
|
|
2495
2566
|
...baseEnv,
|
|
2496
2567
|
HOME: baseEnv.HOME || os4.homedir(),
|
|
2568
|
+
DONT_PROMPT_WSL_INSTALL: "1",
|
|
2497
2569
|
XDG_DOWNLOAD_DIR: path6.join(this.desktopDataRoot, "vfs", "Downloads")
|
|
2498
2570
|
},
|
|
2499
2571
|
stdio: "ignore"
|
|
2500
2572
|
});
|
|
2501
2573
|
this.appProc.on("exit", (code) => {
|
|
2502
|
-
if (
|
|
2574
|
+
if (this.closed) return;
|
|
2575
|
+
setTimeout(() => {
|
|
2576
|
+
if (this.closed) return;
|
|
2577
|
+
try {
|
|
2578
|
+
const out = execSync2(`wmctrl -l`, {
|
|
2579
|
+
env: { ...process.env, DISPLAY: this.displayStr },
|
|
2580
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
2581
|
+
timeout: 1200
|
|
2582
|
+
}).toString("utf-8").trim();
|
|
2583
|
+
if (out.length > 0) {
|
|
2584
|
+
this.hadWindow = true;
|
|
2585
|
+
return;
|
|
2586
|
+
}
|
|
2587
|
+
} catch {
|
|
2588
|
+
}
|
|
2589
|
+
if (!this.hadWindow || code !== 0) {
|
|
2590
|
+
for (const sub of this.subscribers) {
|
|
2591
|
+
sub.onEvent({ type: "app_exit", code: code ?? 0 });
|
|
2592
|
+
}
|
|
2593
|
+
this.close();
|
|
2594
|
+
}
|
|
2595
|
+
}, 1500);
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2598
|
+
startXDamageStreamer(baseEnv) {
|
|
2599
|
+
this.streamerMode = "xdamage";
|
|
2600
|
+
const scriptPath = resolveHelperPath("x11_streamer.py");
|
|
2601
|
+
const jpegQual = Math.max(60, Math.min(88, 92 - this.quality * 4));
|
|
2602
|
+
const proc = spawn3(
|
|
2603
|
+
"python3",
|
|
2604
|
+
[
|
|
2605
|
+
"-u",
|
|
2606
|
+
scriptPath,
|
|
2607
|
+
this.displayStr,
|
|
2608
|
+
String(this.width),
|
|
2609
|
+
String(this.height),
|
|
2610
|
+
String(this.fps),
|
|
2611
|
+
String(jpegQual)
|
|
2612
|
+
],
|
|
2613
|
+
{
|
|
2614
|
+
env: baseEnv,
|
|
2615
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
2616
|
+
}
|
|
2617
|
+
);
|
|
2618
|
+
this.streamerProc = proc;
|
|
2619
|
+
let acc = Buffer.alloc(0);
|
|
2620
|
+
proc.stdout?.on("data", (chunk) => {
|
|
2621
|
+
if (this.closed) return;
|
|
2622
|
+
acc = Buffer.concat([acc, chunk]);
|
|
2623
|
+
while (acc.length >= 4) {
|
|
2624
|
+
const frameLen = acc.readUInt32BE(0);
|
|
2625
|
+
if (frameLen <= 0 || frameLen > 5 * 1024 * 1024) {
|
|
2626
|
+
acc = Buffer.alloc(0);
|
|
2627
|
+
break;
|
|
2628
|
+
}
|
|
2629
|
+
if (acc.length < 4 + frameLen) {
|
|
2630
|
+
break;
|
|
2631
|
+
}
|
|
2632
|
+
const frame = Buffer.from(acc.subarray(4, 4 + frameLen));
|
|
2633
|
+
acc = acc.subarray(4 + frameLen);
|
|
2634
|
+
this.lastFrame = frame;
|
|
2635
|
+
if (this.subscribers.size === 0) {
|
|
2636
|
+
if (proc.stdin?.writable) proc.stdin.write("a\n");
|
|
2637
|
+
continue;
|
|
2638
|
+
}
|
|
2639
|
+
let ackSent = false;
|
|
2640
|
+
const sendAckOnce = () => {
|
|
2641
|
+
if (!ackSent) {
|
|
2642
|
+
ackSent = true;
|
|
2643
|
+
if (!this.closed && proc.stdin?.writable) {
|
|
2644
|
+
proc.stdin.write("a\n");
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
};
|
|
2503
2648
|
for (const sub of this.subscribers) {
|
|
2504
|
-
sub.
|
|
2649
|
+
sub.onVideoFrame(frame, sendAckOnce);
|
|
2505
2650
|
}
|
|
2506
|
-
|
|
2651
|
+
setTimeout(sendAckOnce, 180).unref();
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
proc.on("exit", (code) => {
|
|
2655
|
+
if (!this.closed && code !== 0) {
|
|
2656
|
+
this.startFfmpegFallbackCapture();
|
|
2507
2657
|
}
|
|
2508
2658
|
});
|
|
2509
2659
|
}
|
|
2510
|
-
|
|
2660
|
+
startFfmpegFallbackCapture() {
|
|
2511
2661
|
if (this.closed) return;
|
|
2512
|
-
|
|
2662
|
+
this.streamerMode = "ffmpeg";
|
|
2663
|
+
if (this.streamerProc) {
|
|
2513
2664
|
try {
|
|
2514
|
-
this.
|
|
2665
|
+
this.streamerProc.kill("SIGTERM");
|
|
2515
2666
|
} catch {
|
|
2516
2667
|
}
|
|
2517
|
-
this.
|
|
2668
|
+
this.streamerProc = null;
|
|
2518
2669
|
}
|
|
2519
2670
|
const args = [
|
|
2520
2671
|
"-loglevel",
|
|
2521
2672
|
"error",
|
|
2673
|
+
"-fflags",
|
|
2674
|
+
"nobuffer",
|
|
2675
|
+
"-flags",
|
|
2676
|
+
"low_delay",
|
|
2522
2677
|
"-f",
|
|
2523
2678
|
"x11grab",
|
|
2524
2679
|
"-draw_mouse",
|
|
2525
|
-
"
|
|
2680
|
+
"0",
|
|
2526
2681
|
"-video_size",
|
|
2527
2682
|
`${this.width}x${this.height}`,
|
|
2528
2683
|
"-framerate",
|
|
2529
|
-
String(this.fps),
|
|
2684
|
+
String(Math.min(15, this.fps)),
|
|
2530
2685
|
"-i",
|
|
2531
2686
|
`${this.displayStr}.0+0,0`,
|
|
2532
2687
|
"-f",
|
|
@@ -2536,11 +2691,11 @@ var LinuxAppSession = class {
|
|
|
2536
2691
|
"-pix_fmt",
|
|
2537
2692
|
"yuvj420p",
|
|
2538
2693
|
"-q:v",
|
|
2539
|
-
String(this.quality),
|
|
2694
|
+
String(this.quality + 1),
|
|
2540
2695
|
"-"
|
|
2541
2696
|
];
|
|
2542
|
-
const ff = spawn3("ffmpeg", args, { stdio: ["ignore", "pipe", "
|
|
2543
|
-
this.
|
|
2697
|
+
const ff = spawn3("ffmpeg", args, { stdio: ["ignore", "pipe", "ignore"] });
|
|
2698
|
+
this.streamerProc = ff;
|
|
2544
2699
|
let acc = Buffer.alloc(0);
|
|
2545
2700
|
const SOI = Buffer.from([255, 216]);
|
|
2546
2701
|
const EOI = Buffer.from([255, 217]);
|
|
@@ -2576,8 +2731,11 @@ var LinuxAppSession = class {
|
|
|
2576
2731
|
subscribe(sub) {
|
|
2577
2732
|
this.subscribers.add(sub);
|
|
2578
2733
|
sub.onEvent({ type: "title", title: this.title });
|
|
2734
|
+
sub.onEvent({ type: "cursor", cursor: this.cursor });
|
|
2579
2735
|
if (this.lastFrame) {
|
|
2580
2736
|
sub.onVideoFrame(this.lastFrame);
|
|
2737
|
+
} else if (this.streamerMode === "xdamage" && this.streamerProc?.stdin?.writable) {
|
|
2738
|
+
this.streamerProc.stdin.write(JSON.stringify({ type: "refresh" }) + "\n");
|
|
2581
2739
|
}
|
|
2582
2740
|
return () => {
|
|
2583
2741
|
this.subscribers.delete(sub);
|
|
@@ -2597,19 +2755,32 @@ var LinuxAppSession = class {
|
|
|
2597
2755
|
this.width = evenW;
|
|
2598
2756
|
this.height = evenH;
|
|
2599
2757
|
this.sendInput({ type: "resize", width: evenW, height: evenH });
|
|
2758
|
+
if (this.streamerMode === "xdamage" && this.streamerProc?.stdin?.writable) {
|
|
2759
|
+
this.streamerProc.stdin.write(
|
|
2760
|
+
JSON.stringify({ type: "resize", width: evenW, height: evenH }) + "\n"
|
|
2761
|
+
);
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
2600
2764
|
if (this.resizeTimer) clearTimeout(this.resizeTimer);
|
|
2601
2765
|
this.resizeTimer = setTimeout(() => {
|
|
2602
|
-
if (!this.closed) {
|
|
2766
|
+
if (!this.closed && this.streamerMode === "ffmpeg") {
|
|
2603
2767
|
this.lastFrame = null;
|
|
2604
|
-
this.
|
|
2768
|
+
this.startFfmpegFallbackCapture();
|
|
2605
2769
|
}
|
|
2606
|
-
},
|
|
2770
|
+
}, 160);
|
|
2607
2771
|
}
|
|
2608
2772
|
close() {
|
|
2609
2773
|
if (this.closed) return;
|
|
2610
2774
|
this.closed = true;
|
|
2611
2775
|
if (this.resizeTimer) clearTimeout(this.resizeTimer);
|
|
2612
|
-
const procs = [
|
|
2776
|
+
const procs = [
|
|
2777
|
+
this.streamerProc,
|
|
2778
|
+
this.parecProc,
|
|
2779
|
+
this.x11BridgeProc,
|
|
2780
|
+
this.appProc,
|
|
2781
|
+
this.openboxProc,
|
|
2782
|
+
this.xvfbProc
|
|
2783
|
+
];
|
|
2613
2784
|
for (const p of procs) {
|
|
2614
2785
|
if (p) {
|
|
2615
2786
|
try {
|
|
@@ -2631,13 +2802,13 @@ var LinuxAppSession = class {
|
|
|
2631
2802
|
fs6.rmSync(this.tempDir, { recursive: true, force: true });
|
|
2632
2803
|
} catch {
|
|
2633
2804
|
}
|
|
2634
|
-
},
|
|
2805
|
+
}, 500);
|
|
2635
2806
|
if (this.pulseSinkName) {
|
|
2636
2807
|
try {
|
|
2637
|
-
execSync2(
|
|
2638
|
-
|
|
2639
|
-
timeout: 1500
|
|
2640
|
-
|
|
2808
|
+
execSync2(
|
|
2809
|
+
`pactl list short modules | grep "${this.pulseSinkName}" | awk '{print $1}' | xargs -r -n1 pactl unload-module`,
|
|
2810
|
+
{ stdio: "ignore", timeout: 1500 }
|
|
2811
|
+
);
|
|
2641
2812
|
} catch {
|
|
2642
2813
|
}
|
|
2643
2814
|
}
|
|
@@ -2691,8 +2862,205 @@ var LinuxDisplayBridge = class {
|
|
|
2691
2862
|
}
|
|
2692
2863
|
};
|
|
2693
2864
|
|
|
2865
|
+
// server/vscodeManager.ts
|
|
2866
|
+
import fs7 from "node:fs";
|
|
2867
|
+
import http from "node:http";
|
|
2868
|
+
import net from "node:net";
|
|
2869
|
+
import path7 from "node:path";
|
|
2870
|
+
import { execSync as execSync3, spawn as spawn4 } from "node:child_process";
|
|
2871
|
+
function hasCodeBinary() {
|
|
2872
|
+
try {
|
|
2873
|
+
const out = execSync3("command -v code", {
|
|
2874
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
2875
|
+
shell: "/bin/sh"
|
|
2876
|
+
}).toString("utf-8").trim();
|
|
2877
|
+
return Boolean(out);
|
|
2878
|
+
} catch {
|
|
2879
|
+
return false;
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
var VSCodeServerManager = class {
|
|
2883
|
+
proc = null;
|
|
2884
|
+
starting = null;
|
|
2885
|
+
ready = false;
|
|
2886
|
+
port = 4899;
|
|
2887
|
+
dataDir;
|
|
2888
|
+
statusMessage = "VS Code Web sunucusu haz\u0131rlan\u0131yor...";
|
|
2889
|
+
constructor(dataDir) {
|
|
2890
|
+
this.dataDir = dataDir;
|
|
2891
|
+
}
|
|
2892
|
+
isInstalled() {
|
|
2893
|
+
return hasCodeBinary();
|
|
2894
|
+
}
|
|
2895
|
+
getStatus() {
|
|
2896
|
+
return {
|
|
2897
|
+
installed: this.isInstalled(),
|
|
2898
|
+
ready: this.ready,
|
|
2899
|
+
statusMessage: this.statusMessage
|
|
2900
|
+
};
|
|
2901
|
+
}
|
|
2902
|
+
async ensureStarted() {
|
|
2903
|
+
if (this.ready && this.proc && this.proc.exitCode === null) {
|
|
2904
|
+
return;
|
|
2905
|
+
}
|
|
2906
|
+
if (this.starting) {
|
|
2907
|
+
return this.starting;
|
|
2908
|
+
}
|
|
2909
|
+
if (!this.isInstalled()) {
|
|
2910
|
+
throw new Error("VS Code sunucuda kurulu de\u011Fil. Uygulamalar penceresinden kurabilirsiniz.");
|
|
2911
|
+
}
|
|
2912
|
+
this.starting = (async () => {
|
|
2913
|
+
const cliDir = path7.join(this.dataDir, "vscode-cli");
|
|
2914
|
+
const srvDir = path7.join(this.dataDir, "vscode-server");
|
|
2915
|
+
fs7.mkdirSync(cliDir, { recursive: true });
|
|
2916
|
+
fs7.mkdirSync(srvDir, { recursive: true });
|
|
2917
|
+
this.ready = false;
|
|
2918
|
+
this.statusMessage = "VS Code Web motoru ba\u015Flat\u0131l\u0131yor (ilk a\xE7\u0131l\u0131\u015Fta bile\u015Fenler indirilebilir)...";
|
|
2919
|
+
const proc = spawn4(
|
|
2920
|
+
"code",
|
|
2921
|
+
[
|
|
2922
|
+
"serve-web",
|
|
2923
|
+
"--host",
|
|
2924
|
+
"127.0.0.1",
|
|
2925
|
+
"--port",
|
|
2926
|
+
String(this.port),
|
|
2927
|
+
"--without-connection-token",
|
|
2928
|
+
"--accept-server-license-terms",
|
|
2929
|
+
"--server-base-path",
|
|
2930
|
+
"/vscode-web",
|
|
2931
|
+
"--cli-data-dir",
|
|
2932
|
+
cliDir,
|
|
2933
|
+
"--server-data-dir",
|
|
2934
|
+
srvDir,
|
|
2935
|
+
"--disable-telemetry"
|
|
2936
|
+
],
|
|
2937
|
+
{
|
|
2938
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
2939
|
+
env: {
|
|
2940
|
+
...process.env,
|
|
2941
|
+
DONT_PROMPT_WSL_INSTALL: "1"
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
);
|
|
2945
|
+
this.proc = proc;
|
|
2946
|
+
proc.stdout?.on("data", (chunk) => {
|
|
2947
|
+
const line = chunk.toString("utf-8").trim();
|
|
2948
|
+
if (line.toLowerCase().includes("downloading")) {
|
|
2949
|
+
this.statusMessage = "VS Code Web sunucu paketi indiriliyor...";
|
|
2950
|
+
}
|
|
2951
|
+
});
|
|
2952
|
+
proc.on("exit", () => {
|
|
2953
|
+
this.ready = false;
|
|
2954
|
+
this.proc = null;
|
|
2955
|
+
});
|
|
2956
|
+
for (let i = 0; i < 180; i++) {
|
|
2957
|
+
if (proc.exitCode !== null) {
|
|
2958
|
+
throw new Error("VS Code Web sunucusu beklenmedik \u015Fekilde kapand\u0131.");
|
|
2959
|
+
}
|
|
2960
|
+
const alive = await this.probeHttp();
|
|
2961
|
+
if (alive) {
|
|
2962
|
+
this.ready = true;
|
|
2963
|
+
this.statusMessage = "Haz\u0131r";
|
|
2964
|
+
return;
|
|
2965
|
+
}
|
|
2966
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
2967
|
+
}
|
|
2968
|
+
throw new Error("VS Code Web sunucusu zaman a\u015F\u0131m\u0131na u\u011Frad\u0131.");
|
|
2969
|
+
})();
|
|
2970
|
+
try {
|
|
2971
|
+
await this.starting;
|
|
2972
|
+
} finally {
|
|
2973
|
+
this.starting = null;
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
probeHttp() {
|
|
2977
|
+
return new Promise((resolve) => {
|
|
2978
|
+
const req = http.get(
|
|
2979
|
+
{
|
|
2980
|
+
host: "127.0.0.1",
|
|
2981
|
+
port: this.port,
|
|
2982
|
+
path: "/vscode-web/",
|
|
2983
|
+
timeout: 800
|
|
2984
|
+
},
|
|
2985
|
+
(res) => {
|
|
2986
|
+
res.resume();
|
|
2987
|
+
resolve((res.statusCode || 500) < 500);
|
|
2988
|
+
}
|
|
2989
|
+
);
|
|
2990
|
+
req.on("error", () => resolve(false));
|
|
2991
|
+
req.on("timeout", () => {
|
|
2992
|
+
req.destroy();
|
|
2993
|
+
resolve(false);
|
|
2994
|
+
});
|
|
2995
|
+
});
|
|
2996
|
+
}
|
|
2997
|
+
proxyHttp = (req, res) => {
|
|
2998
|
+
if (!this.ready) {
|
|
2999
|
+
res.status(503).send("VS Code haz\u0131rlan\u0131yor...");
|
|
3000
|
+
return;
|
|
3001
|
+
}
|
|
3002
|
+
const headers = { ...req.headers, host: `127.0.0.1:${this.port}` };
|
|
3003
|
+
const upstream = http.request(
|
|
3004
|
+
{
|
|
3005
|
+
host: "127.0.0.1",
|
|
3006
|
+
port: this.port,
|
|
3007
|
+
method: req.method,
|
|
3008
|
+
path: req.originalUrl,
|
|
3009
|
+
headers
|
|
3010
|
+
},
|
|
3011
|
+
(upRes) => {
|
|
3012
|
+
const outHeaders = { ...upRes.headers };
|
|
3013
|
+
delete outHeaders["x-frame-options"];
|
|
3014
|
+
if (typeof outHeaders["content-security-policy"] === "string") {
|
|
3015
|
+
outHeaders["content-security-policy"] = outHeaders["content-security-policy"].replace(
|
|
3016
|
+
/frame-ancestors[^;]*;?/gi,
|
|
3017
|
+
""
|
|
3018
|
+
);
|
|
3019
|
+
}
|
|
3020
|
+
res.writeHead(upRes.statusCode || 200, outHeaders);
|
|
3021
|
+
upRes.pipe(res);
|
|
3022
|
+
}
|
|
3023
|
+
);
|
|
3024
|
+
upstream.on("error", () => {
|
|
3025
|
+
if (!res.headersSent) res.status(502).end("VS Code ba\u011Flant\u0131 hatas\u0131");
|
|
3026
|
+
});
|
|
3027
|
+
req.pipe(upstream);
|
|
3028
|
+
};
|
|
3029
|
+
proxyUpgrade(req, clientSocket, head) {
|
|
3030
|
+
const upstream = net.connect(this.port, "127.0.0.1", () => {
|
|
3031
|
+
const lines = [`${req.method || "GET"} ${req.url || "/vscode-web/"} HTTP/${req.httpVersion}`];
|
|
3032
|
+
for (let i = 0; i < req.rawHeaders.length; i += 2) {
|
|
3033
|
+
const k = req.rawHeaders[i];
|
|
3034
|
+
const v = req.rawHeaders[i + 1];
|
|
3035
|
+
if (k.toLowerCase() === "host") {
|
|
3036
|
+
lines.push(`Host: 127.0.0.1:${this.port}`);
|
|
3037
|
+
} else {
|
|
3038
|
+
lines.push(`${k}: ${v}`);
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
lines.push("", "");
|
|
3042
|
+
upstream.write(lines.join("\r\n"));
|
|
3043
|
+
if (head && head.length > 0) upstream.write(head);
|
|
3044
|
+
upstream.pipe(clientSocket);
|
|
3045
|
+
clientSocket.pipe(upstream);
|
|
3046
|
+
});
|
|
3047
|
+
upstream.on("error", () => clientSocket.destroy());
|
|
3048
|
+
clientSocket.on("error", () => upstream.destroy());
|
|
3049
|
+
}
|
|
3050
|
+
stop() {
|
|
3051
|
+
if (this.proc) {
|
|
3052
|
+
try {
|
|
3053
|
+
this.proc.kill("SIGTERM");
|
|
3054
|
+
} catch {
|
|
3055
|
+
}
|
|
3056
|
+
this.proc = null;
|
|
3057
|
+
}
|
|
3058
|
+
this.ready = false;
|
|
3059
|
+
}
|
|
3060
|
+
};
|
|
3061
|
+
|
|
2694
3062
|
// server/index.ts
|
|
2695
|
-
var TAMGA_VERSION = "1.0
|
|
3063
|
+
var TAMGA_VERSION = "1.1.0";
|
|
2696
3064
|
var MIME_MAP = {
|
|
2697
3065
|
html: "text/html; charset=utf-8",
|
|
2698
3066
|
htm: "text/html; charset=utf-8",
|
|
@@ -2722,16 +3090,16 @@ var MIME_MAP = {
|
|
|
2722
3090
|
zip: "application/zip"
|
|
2723
3091
|
};
|
|
2724
3092
|
function resolveClientDistDir() {
|
|
2725
|
-
const here =
|
|
3093
|
+
const here = path8.dirname(fileURLToPath2(import.meta.url));
|
|
2726
3094
|
const candidates = [
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
3095
|
+
path8.resolve(here, "client"),
|
|
3096
|
+
path8.resolve(here, "../dist/client"),
|
|
3097
|
+
path8.resolve(here, "../client"),
|
|
3098
|
+
path8.resolve(process.cwd(), "dist/client"),
|
|
3099
|
+
path8.resolve(process.cwd(), "dist")
|
|
2732
3100
|
];
|
|
2733
3101
|
for (const dir of candidates) {
|
|
2734
|
-
if (
|
|
3102
|
+
if (fs8.existsSync(path8.join(dir, "index.html"))) {
|
|
2735
3103
|
return dir;
|
|
2736
3104
|
}
|
|
2737
3105
|
}
|
|
@@ -2746,15 +3114,23 @@ async function startTamgaServer(opts = {}) {
|
|
|
2746
3114
|
};
|
|
2747
3115
|
const configPath = loaded.configPath;
|
|
2748
3116
|
setStorageRoot(config.dataDir);
|
|
3117
|
+
const authManager = new AuthManager(config);
|
|
3118
|
+
const vscodeManager = new VSCodeServerManager(config.dataDir);
|
|
2749
3119
|
const app = express();
|
|
2750
3120
|
app.set("trust proxy", config.trustProxy);
|
|
2751
3121
|
app.use(cors({ origin: true, credentials: true }));
|
|
3122
|
+
app.use("/vscode-web", (req, res) => {
|
|
3123
|
+
if (!authManager.isRequestAuthorized(req.headers.cookie, req.headers.authorization)) {
|
|
3124
|
+
res.status(401).send("Oturum a\xE7man\u0131z gerekiyor.");
|
|
3125
|
+
return;
|
|
3126
|
+
}
|
|
3127
|
+
vscodeManager.proxyHttp(req, res);
|
|
3128
|
+
});
|
|
2752
3129
|
app.use(express.json({ limit: "25mb" }));
|
|
2753
3130
|
const upload = multer({
|
|
2754
3131
|
storage: multer.memoryStorage(),
|
|
2755
3132
|
limits: { fileSize: 50 * 1024 * 1024 }
|
|
2756
3133
|
});
|
|
2757
|
-
const authManager = new AuthManager(config);
|
|
2758
3134
|
const registry = new DesktopRegistry();
|
|
2759
3135
|
const vfsInstances = /* @__PURE__ */ new Map();
|
|
2760
3136
|
const chromiumCluster = new ChromiumCluster();
|
|
@@ -2906,10 +3282,10 @@ async function startTamgaServer(opts = {}) {
|
|
|
2906
3282
|
res.status(404).end();
|
|
2907
3283
|
return;
|
|
2908
3284
|
}
|
|
2909
|
-
const ext =
|
|
3285
|
+
const ext = path8.extname(iconPath).slice(1).toLowerCase();
|
|
2910
3286
|
res.setHeader("Content-Type", MIME_MAP[ext] || "image/png");
|
|
2911
3287
|
res.setHeader("Cache-Control", "public, max-age=86400");
|
|
2912
|
-
|
|
3288
|
+
fs8.createReadStream(iconPath).pipe(res);
|
|
2913
3289
|
});
|
|
2914
3290
|
app.post("/api/apps/launch", async (req, res) => {
|
|
2915
3291
|
try {
|
|
@@ -2988,6 +3364,24 @@ async function startTamgaServer(opts = {}) {
|
|
|
2988
3364
|
}
|
|
2989
3365
|
res.json(job);
|
|
2990
3366
|
});
|
|
3367
|
+
app.get("/api/apps/vscode-status", (_req, res) => {
|
|
3368
|
+
res.json(vscodeManager.getStatus());
|
|
3369
|
+
});
|
|
3370
|
+
app.post("/api/apps/vscode-start", async (req, res) => {
|
|
3371
|
+
try {
|
|
3372
|
+
const desktopId = sanitizeDesktopId(extractReqDesktopId(req));
|
|
3373
|
+
const { vfs } = getDesktopContext(desktopId);
|
|
3374
|
+
await vscodeManager.ensureStarted();
|
|
3375
|
+
const targetVPath = String(req.body?.folderPath || "/Projects");
|
|
3376
|
+
const diskFolder = vfs.resolveDiskPath(targetVPath);
|
|
3377
|
+
fs8.mkdirSync(diskFolder, { recursive: true });
|
|
3378
|
+
res.json({
|
|
3379
|
+
url: `/vscode-web/?folder=${encodeURIComponent(diskFolder)}`
|
|
3380
|
+
});
|
|
3381
|
+
} catch (e) {
|
|
3382
|
+
res.status(400).json({ error: e.message });
|
|
3383
|
+
}
|
|
3384
|
+
});
|
|
2991
3385
|
app.get("/api/desktops", (_req, res) => {
|
|
2992
3386
|
res.json({ desktops: registry.list() });
|
|
2993
3387
|
});
|
|
@@ -3162,20 +3556,20 @@ async function startTamgaServer(opts = {}) {
|
|
|
3162
3556
|
const { vfs } = getDesktopContext(extractReqDesktopId(req));
|
|
3163
3557
|
const vPath = String(req.query.path || "");
|
|
3164
3558
|
const diskPath = vfs.resolveDiskPath(vPath);
|
|
3165
|
-
if (!
|
|
3559
|
+
if (!fs8.existsSync(diskPath) || fs8.statSync(diskPath).isDirectory()) {
|
|
3166
3560
|
res.status(404).send("Dosya bulunamad\u0131");
|
|
3167
3561
|
return;
|
|
3168
3562
|
}
|
|
3169
|
-
const ext =
|
|
3563
|
+
const ext = path8.extname(diskPath).slice(1).toLowerCase();
|
|
3170
3564
|
const mime = MIME_MAP[ext] || "application/octet-stream";
|
|
3171
3565
|
res.setHeader("Content-Type", mime);
|
|
3172
3566
|
if (req.query.download === "1") {
|
|
3173
3567
|
res.setHeader(
|
|
3174
3568
|
"Content-Disposition",
|
|
3175
|
-
`attachment; filename*=UTF-8''${encodeURIComponent(
|
|
3569
|
+
`attachment; filename*=UTF-8''${encodeURIComponent(path8.basename(diskPath))}`
|
|
3176
3570
|
);
|
|
3177
3571
|
}
|
|
3178
|
-
|
|
3572
|
+
fs8.createReadStream(diskPath).pipe(res);
|
|
3179
3573
|
} catch (e) {
|
|
3180
3574
|
res.status(400).send(e.message);
|
|
3181
3575
|
}
|
|
@@ -3223,14 +3617,14 @@ async function startTamgaServer(opts = {}) {
|
|
|
3223
3617
|
try {
|
|
3224
3618
|
const { vfs } = getDesktopContext(extractReqDesktopId(req));
|
|
3225
3619
|
const diskPath = vfs.resolveWallpaperPath(req.params.fileName);
|
|
3226
|
-
if (!
|
|
3620
|
+
if (!fs8.existsSync(diskPath) || fs8.statSync(diskPath).isDirectory()) {
|
|
3227
3621
|
res.status(404).send("Arka plan bulunamad\u0131");
|
|
3228
3622
|
return;
|
|
3229
3623
|
}
|
|
3230
|
-
const ext =
|
|
3624
|
+
const ext = path8.extname(diskPath).slice(1).toLowerCase();
|
|
3231
3625
|
res.setHeader("Content-Type", MIME_MAP[ext] || "image/png");
|
|
3232
3626
|
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
|
|
3233
|
-
|
|
3627
|
+
fs8.createReadStream(diskPath).pipe(res);
|
|
3234
3628
|
} catch (e) {
|
|
3235
3629
|
res.status(400).send(e.message);
|
|
3236
3630
|
}
|
|
@@ -3261,10 +3655,10 @@ async function startTamgaServer(opts = {}) {
|
|
|
3261
3655
|
next();
|
|
3262
3656
|
return;
|
|
3263
3657
|
}
|
|
3264
|
-
res.sendFile(
|
|
3658
|
+
res.sendFile(path8.join(clientDist, "index.html"));
|
|
3265
3659
|
});
|
|
3266
3660
|
}
|
|
3267
|
-
const server =
|
|
3661
|
+
const server = http2.createServer(app);
|
|
3268
3662
|
const desktopWss = new WebSocketServer({ noServer: true });
|
|
3269
3663
|
const terminalWss = new WebSocketServer({ noServer: true });
|
|
3270
3664
|
const appWss = new WebSocketServer({ noServer: true });
|
|
@@ -3273,9 +3667,11 @@ async function startTamgaServer(opts = {}) {
|
|
|
3273
3667
|
ws.send(JSON.stringify(payload));
|
|
3274
3668
|
}
|
|
3275
3669
|
}
|
|
3276
|
-
function sendBinary(ws, packet) {
|
|
3277
|
-
if (ws.readyState === WebSocket.OPEN && ws.bufferedAmount <
|
|
3278
|
-
ws.send(packet, { binary: true });
|
|
3670
|
+
function sendBinary(ws, packet, cb) {
|
|
3671
|
+
if (ws.readyState === WebSocket.OPEN && ws.bufferedAmount < 512e3) {
|
|
3672
|
+
ws.send(packet, { binary: true }, () => cb?.());
|
|
3673
|
+
} else {
|
|
3674
|
+
cb?.();
|
|
3279
3675
|
}
|
|
3280
3676
|
}
|
|
3281
3677
|
server.on("upgrade", (req, socket, head) => {
|
|
@@ -3285,7 +3681,9 @@ async function startTamgaServer(opts = {}) {
|
|
|
3285
3681
|
return;
|
|
3286
3682
|
}
|
|
3287
3683
|
const reqUrl = new URL(req.url || "/ws", "http://localhost");
|
|
3288
|
-
if (reqUrl.pathname
|
|
3684
|
+
if (reqUrl.pathname.startsWith("/vscode-web")) {
|
|
3685
|
+
vscodeManager.proxyUpgrade(req, socket, head);
|
|
3686
|
+
} else if (reqUrl.pathname === "/ws") {
|
|
3289
3687
|
desktopWss.handleUpgrade(req, socket, head, (ws) => {
|
|
3290
3688
|
desktopWss.emit("connection", ws, req);
|
|
3291
3689
|
});
|
|
@@ -3399,11 +3797,11 @@ async function startTamgaServer(opts = {}) {
|
|
|
3399
3797
|
return;
|
|
3400
3798
|
}
|
|
3401
3799
|
const unsub = session.subscribe({
|
|
3402
|
-
onVideoFrame: (jpeg) => {
|
|
3800
|
+
onVideoFrame: (jpeg, done) => {
|
|
3403
3801
|
const pkt = Buffer.allocUnsafe(1 + jpeg.length);
|
|
3404
3802
|
pkt[0] = PACKET_VIDEO_JPEG;
|
|
3405
3803
|
jpeg.copy(pkt, 1);
|
|
3406
|
-
sendBinary(ws, pkt);
|
|
3804
|
+
sendBinary(ws, pkt, done);
|
|
3407
3805
|
},
|
|
3408
3806
|
onAudioChunk: (pcm) => {
|
|
3409
3807
|
const pkt = Buffer.allocUnsafe(1 + pcm.length);
|
|
@@ -3445,6 +3843,7 @@ async function startTamgaServer(opts = {}) {
|
|
|
3445
3843
|
clearInterval(telemetryTimer);
|
|
3446
3844
|
terminalManager.destroyAll();
|
|
3447
3845
|
linuxDisplayBridge.destroyAll();
|
|
3846
|
+
vscodeManager.stop();
|
|
3448
3847
|
server.close(() => process.exit(0));
|
|
3449
3848
|
setTimeout(() => process.exit(0), 2e3).unref();
|
|
3450
3849
|
};
|
|
@@ -3466,7 +3865,7 @@ async function startTamgaServer(opts = {}) {
|
|
|
3466
3865
|
return { server, config };
|
|
3467
3866
|
}
|
|
3468
3867
|
var selfPath = fileURLToPath2(import.meta.url);
|
|
3469
|
-
var isDirectRun = Boolean(process.argv[1]) && !selfPath.endsWith("cli.js") &&
|
|
3868
|
+
var isDirectRun = Boolean(process.argv[1]) && !selfPath.endsWith("cli.js") && path8.resolve(process.argv[1]) === path8.resolve(selfPath);
|
|
3470
3869
|
if (isDirectRun) {
|
|
3471
3870
|
const devPort = Number(process.env.PORT || 3001);
|
|
3472
3871
|
startTamgaServer({ host: "127.0.0.1", port: devPort }).catch((err) => {
|
|
@@ -3544,11 +3943,11 @@ Se\xE7enekler:
|
|
|
3544
3943
|
`);
|
|
3545
3944
|
}
|
|
3546
3945
|
async function cmdInit(flags) {
|
|
3547
|
-
const configPath = typeof flags.config === "string" ?
|
|
3946
|
+
const configPath = typeof flags.config === "string" ? path9.resolve(flags.config) : getDefaultConfigPath();
|
|
3548
3947
|
const nonInteractive = Boolean(flags["non-interactive"]);
|
|
3549
3948
|
let port = Number(flags.port || 4800);
|
|
3550
3949
|
let host = String(flags.host || "0.0.0.0");
|
|
3551
|
-
let dataDir = typeof flags["data-dir"] === "string" ?
|
|
3950
|
+
let dataDir = typeof flags["data-dir"] === "string" ? path9.resolve(flags["data-dir"]) : getDefaultDataDir();
|
|
3552
3951
|
let authEnabled = flags["no-auth"] ? false : true;
|
|
3553
3952
|
let username = String(flags.user || "admin");
|
|
3554
3953
|
let password = typeof flags.password === "string" ? flags.password : "";
|
|
@@ -3560,7 +3959,7 @@ Ayar dosyas\u0131: ${configPath}
|
|
|
3560
3959
|
`);
|
|
3561
3960
|
port = Number(await ask(rl, "Dinlenecek port", String(port))) || 4800;
|
|
3562
3961
|
host = await ask(rl, "Dinlenecek adres (d\u0131\u015F eri\u015Fim i\xE7in 0.0.0.0)", host);
|
|
3563
|
-
dataDir =
|
|
3962
|
+
dataDir = path9.resolve(await ask(rl, "Veri dizini", dataDir));
|
|
3564
3963
|
const authAns = await ask(rl, "Giri\u015F ekran\u0131 / parola korumas\u0131 aktif olsun mu? (e/h)", authEnabled ? "e" : "h");
|
|
3565
3964
|
authEnabled = authAns.toLowerCase().startsWith("e") || authAns.toLowerCase().startsWith("y");
|
|
3566
3965
|
if (authEnabled) {
|
|
@@ -3580,7 +3979,7 @@ Ayar dosyas\u0131: ${configPath}
|
|
|
3580
3979
|
password: password || "tamga2026"
|
|
3581
3980
|
});
|
|
3582
3981
|
saveConfig(configPath, cfg);
|
|
3583
|
-
|
|
3982
|
+
fs9.mkdirSync(dataDir, { recursive: true });
|
|
3584
3983
|
console.log(`
|
|
3585
3984
|
\u2713 Yap\u0131land\u0131rma kaydedildi: ${configPath}`);
|
|
3586
3985
|
console.log(` Port : ${cfg.port} (${cfg.host})`);
|
|
@@ -3602,7 +4001,7 @@ function cmdSetupLinux(flags) {
|
|
|
3602
4001
|
"set -e",
|
|
3603
4002
|
"export DEBIAN_FRONTEND=noninteractive",
|
|
3604
4003
|
"apt-get update -y",
|
|
3605
|
-
"apt-get install -y --no-install-recommends xvfb openbox ffmpeg libxtst6 libx11-6 libxfixes3 libxext6 xclip xdotool wmctrl dbus-x11 x11-utils pulseaudio pulseaudio-utils fonts-dejavu-core fonts-liberation fonts-noto-color-emoji desktop-file-utils hicolor-icon-theme wget gnupg ca-certificates curl"
|
|
4004
|
+
"apt-get install -y --no-install-recommends xvfb openbox ffmpeg libturbojpeg libxdamage1 libxtst6 libx11-6 libxfixes3 libxext6 xclip xdotool wmctrl dbus-x11 x11-utils pulseaudio pulseaudio-utils fonts-dejavu-core fonts-liberation fonts-noto-color-emoji desktop-file-utils hicolor-icon-theme wget gnupg ca-certificates curl"
|
|
3606
4005
|
];
|
|
3607
4006
|
if (withFirefox) {
|
|
3608
4007
|
parts.push(`
|
|
@@ -3637,10 +4036,10 @@ function cmdService(subCmd, flags) {
|
|
|
3637
4036
|
}
|
|
3638
4037
|
const unitName = "tamga-vdesktop.service";
|
|
3639
4038
|
const unitPath = `/etc/systemd/system/${unitName}`;
|
|
3640
|
-
const configPath = typeof flags.config === "string" ?
|
|
4039
|
+
const configPath = typeof flags.config === "string" ? path9.resolve(flags.config) : getDefaultConfigPath();
|
|
3641
4040
|
switch (subCmd) {
|
|
3642
4041
|
case "install": {
|
|
3643
|
-
if (!
|
|
4042
|
+
if (!fs9.existsSync(configPath)) {
|
|
3644
4043
|
const cfg = createDefaultConfig({
|
|
3645
4044
|
port: Number(flags.port || 4800),
|
|
3646
4045
|
host: String(flags.host || "0.0.0.0"),
|
|
@@ -3651,7 +4050,7 @@ function cmdService(subCmd, flags) {
|
|
|
3651
4050
|
console.log(`Varsay\u0131lan yap\u0131land\u0131rma olu\u015Fturuldu: ${configPath}`);
|
|
3652
4051
|
}
|
|
3653
4052
|
const nodeBin = process.execPath;
|
|
3654
|
-
const cliEntry =
|
|
4053
|
+
const cliEntry = path9.resolve(process.argv[1]);
|
|
3655
4054
|
const unitContent = `[Unit]
|
|
3656
4055
|
Description=TamgaVDesktop Virtual Desktop Server
|
|
3657
4056
|
After=network-online.target
|
|
@@ -3669,9 +4068,9 @@ LimitNOFILE=65536
|
|
|
3669
4068
|
[Install]
|
|
3670
4069
|
WantedBy=multi-user.target
|
|
3671
4070
|
`;
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
4071
|
+
fs9.writeFileSync(unitPath, unitContent, "utf-8");
|
|
4072
|
+
execSync4("systemctl daemon-reload", { stdio: "inherit" });
|
|
4073
|
+
execSync4(`systemctl enable --now ${unitName}`, { stdio: "inherit" });
|
|
3675
4074
|
console.log(`
|
|
3676
4075
|
\u2713 ${unitName} kuruldu ve ba\u015Flat\u0131ld\u0131.`);
|
|
3677
4076
|
console.log(` Durum : tamga-vdesktop service status`);
|
|
@@ -3681,7 +4080,7 @@ WantedBy=multi-user.target
|
|
|
3681
4080
|
case "start":
|
|
3682
4081
|
case "stop":
|
|
3683
4082
|
case "restart":
|
|
3684
|
-
|
|
4083
|
+
execSync4(`systemctl ${subCmd} ${unitName}`, { stdio: "inherit" });
|
|
3685
4084
|
break;
|
|
3686
4085
|
case "status":
|
|
3687
4086
|
spawnSync("systemctl", ["status", unitName, "--no-pager"], { stdio: "inherit" });
|
|
@@ -3691,11 +4090,11 @@ WantedBy=multi-user.target
|
|
|
3691
4090
|
break;
|
|
3692
4091
|
case "uninstall":
|
|
3693
4092
|
try {
|
|
3694
|
-
|
|
4093
|
+
execSync4(`systemctl disable --now ${unitName}`, { stdio: "inherit" });
|
|
3695
4094
|
} catch {
|
|
3696
4095
|
}
|
|
3697
|
-
if (
|
|
3698
|
-
|
|
4096
|
+
if (fs9.existsSync(unitPath)) fs9.unlinkSync(unitPath);
|
|
4097
|
+
execSync4("systemctl daemon-reload", { stdio: "inherit" });
|
|
3699
4098
|
console.log(`\u2713 ${unitName} kald\u0131r\u0131ld\u0131.`);
|
|
3700
4099
|
break;
|
|
3701
4100
|
default:
|
|
@@ -3724,7 +4123,7 @@ TamgaVDesktop v${TAMGA_VERSION} \u2014 Sistem Te\u015Fhisi`);
|
|
|
3724
4123
|
console.log(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
3725
4124
|
console.log(`\u0130\u015Fletim Sistemi : ${status.distro}`);
|
|
3726
4125
|
console.log(`Node.js : ${process.version}`);
|
|
3727
|
-
console.log(`Ayar Dosyas\u0131 : ${configPath} (${
|
|
4126
|
+
console.log(`Ayar Dosyas\u0131 : ${configPath} (${fs9.existsSync(configPath) ? "mevcut" : "varsay\u0131lan"})`);
|
|
3728
4127
|
console.log(`Dinleme Adresi : ${config.host}:${config.port}`);
|
|
3729
4128
|
console.log(`Veri Dizini : ${config.dataDir}`);
|
|
3730
4129
|
console.log(`Giri\u015F Korumas\u0131 : ${config.auth.enabled ? `Aktif (${config.auth.username})` : "Kapal\u0131"}`);
|