tamga-vdesktop 1.0.0 → 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 +520 -115
- 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 -72
- package/dist/helpers/x11_streamer.py +268 -0
- package/dist/server.js +501 -96
- package/package.json +4 -4
- 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 });
|
|
@@ -2455,23 +2517,34 @@ var LinuxAppSession = class {
|
|
|
2455
2517
|
const baseBin = path6.basename(finalCmd.split(/\s+/)[0] || "");
|
|
2456
2518
|
if (baseBin === "firefox" || baseBin === "firefox-esr") {
|
|
2457
2519
|
const userJsPath = path6.join(profileDir, "user.js");
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
"
|
|
2471
|
-
|
|
2472
|
-
|
|
2520
|
+
fs6.writeFileSync(
|
|
2521
|
+
userJsPath,
|
|
2522
|
+
[
|
|
2523
|
+
'user_pref("browser.shell.checkDefaultBrowser", false);',
|
|
2524
|
+
'user_pref("browser.aboutwelcome.enabled", false);',
|
|
2525
|
+
'user_pref("trailhead.firstrun.didSeeAboutWelcome", true);',
|
|
2526
|
+
'user_pref("datareporting.policy.firstRunURL", "");',
|
|
2527
|
+
'user_pref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);',
|
|
2528
|
+
'user_pref("datareporting.policy.dataSubmissionEnabled", false);',
|
|
2529
|
+
'user_pref("toolkit.telemetry.reportingpolicy.firstRun", false);',
|
|
2530
|
+
'user_pref("browser.startup.homepage", "https://www.google.com");',
|
|
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);',
|
|
2539
|
+
'user_pref("gfx.webrender.software", true);',
|
|
2540
|
+
'user_pref("gfx.x11-egl.force-disabled", true);',
|
|
2541
|
+
'user_pref("browser.download.dir", ' + JSON.stringify(path6.join(this.desktopDataRoot, "vfs", "Downloads")) + ");",
|
|
2542
|
+
'user_pref("browser.download.folderList", 2);'
|
|
2543
|
+
].join("\n") + "\n",
|
|
2544
|
+
"utf-8"
|
|
2545
|
+
);
|
|
2473
2546
|
finalCmd = `${finalCmd} --no-remote -profile "${profileDir}" --width=${this.width} --height=${this.height}`;
|
|
2474
|
-
} 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)) {
|
|
2475
2548
|
const extraFlags = [];
|
|
2476
2549
|
if (isRoot && !finalCmd.includes("--no-sandbox")) {
|
|
2477
2550
|
extraFlags.push("--no-sandbox");
|
|
@@ -2480,61 +2553,149 @@ var LinuxAppSession = class {
|
|
|
2480
2553
|
extraFlags.push(`--user-data-dir="${profileDir}"`);
|
|
2481
2554
|
}
|
|
2482
2555
|
if (!finalCmd.includes("--disable-gpu")) {
|
|
2483
|
-
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");
|
|
2484
2560
|
}
|
|
2485
2561
|
finalCmd = `${finalCmd} ${extraFlags.join(" ")}`;
|
|
2486
2562
|
}
|
|
2487
|
-
|
|
2488
|
-
this.appProc = spawn3("/bin/bash", ["-c", wrapped], {
|
|
2563
|
+
this.appProc = spawn3("/bin/bash", ["-c", `exec ${finalCmd}`], {
|
|
2489
2564
|
cwd: desktopFilesDir,
|
|
2490
2565
|
env: {
|
|
2491
2566
|
...baseEnv,
|
|
2492
2567
|
HOME: baseEnv.HOME || os4.homedir(),
|
|
2568
|
+
DONT_PROMPT_WSL_INSTALL: "1",
|
|
2493
2569
|
XDG_DOWNLOAD_DIR: path6.join(this.desktopDataRoot, "vfs", "Downloads")
|
|
2494
2570
|
},
|
|
2495
2571
|
stdio: "ignore"
|
|
2496
2572
|
});
|
|
2497
2573
|
this.appProc.on("exit", (code) => {
|
|
2498
|
-
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
|
+
};
|
|
2499
2648
|
for (const sub of this.subscribers) {
|
|
2500
|
-
sub.
|
|
2649
|
+
sub.onVideoFrame(frame, sendAckOnce);
|
|
2501
2650
|
}
|
|
2502
|
-
|
|
2651
|
+
setTimeout(sendAckOnce, 180).unref();
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
proc.on("exit", (code) => {
|
|
2655
|
+
if (!this.closed && code !== 0) {
|
|
2656
|
+
this.startFfmpegFallbackCapture();
|
|
2503
2657
|
}
|
|
2504
2658
|
});
|
|
2505
2659
|
}
|
|
2506
|
-
|
|
2660
|
+
startFfmpegFallbackCapture() {
|
|
2507
2661
|
if (this.closed) return;
|
|
2508
|
-
|
|
2662
|
+
this.streamerMode = "ffmpeg";
|
|
2663
|
+
if (this.streamerProc) {
|
|
2509
2664
|
try {
|
|
2510
|
-
this.
|
|
2665
|
+
this.streamerProc.kill("SIGTERM");
|
|
2511
2666
|
} catch {
|
|
2512
2667
|
}
|
|
2513
|
-
this.
|
|
2668
|
+
this.streamerProc = null;
|
|
2514
2669
|
}
|
|
2515
2670
|
const args = [
|
|
2516
2671
|
"-loglevel",
|
|
2517
2672
|
"error",
|
|
2673
|
+
"-fflags",
|
|
2674
|
+
"nobuffer",
|
|
2675
|
+
"-flags",
|
|
2676
|
+
"low_delay",
|
|
2518
2677
|
"-f",
|
|
2519
2678
|
"x11grab",
|
|
2520
2679
|
"-draw_mouse",
|
|
2521
|
-
"
|
|
2680
|
+
"0",
|
|
2522
2681
|
"-video_size",
|
|
2523
2682
|
`${this.width}x${this.height}`,
|
|
2524
2683
|
"-framerate",
|
|
2525
|
-
String(this.fps),
|
|
2684
|
+
String(Math.min(15, this.fps)),
|
|
2526
2685
|
"-i",
|
|
2527
2686
|
`${this.displayStr}.0+0,0`,
|
|
2528
2687
|
"-f",
|
|
2529
2688
|
"image2pipe",
|
|
2530
2689
|
"-vcodec",
|
|
2531
2690
|
"mjpeg",
|
|
2691
|
+
"-pix_fmt",
|
|
2692
|
+
"yuvj420p",
|
|
2532
2693
|
"-q:v",
|
|
2533
|
-
String(this.quality),
|
|
2694
|
+
String(this.quality + 1),
|
|
2534
2695
|
"-"
|
|
2535
2696
|
];
|
|
2536
|
-
const ff = spawn3("ffmpeg", args, { stdio: ["ignore", "pipe", "
|
|
2537
|
-
this.
|
|
2697
|
+
const ff = spawn3("ffmpeg", args, { stdio: ["ignore", "pipe", "ignore"] });
|
|
2698
|
+
this.streamerProc = ff;
|
|
2538
2699
|
let acc = Buffer.alloc(0);
|
|
2539
2700
|
const SOI = Buffer.from([255, 216]);
|
|
2540
2701
|
const EOI = Buffer.from([255, 217]);
|
|
@@ -2570,8 +2731,11 @@ var LinuxAppSession = class {
|
|
|
2570
2731
|
subscribe(sub) {
|
|
2571
2732
|
this.subscribers.add(sub);
|
|
2572
2733
|
sub.onEvent({ type: "title", title: this.title });
|
|
2734
|
+
sub.onEvent({ type: "cursor", cursor: this.cursor });
|
|
2573
2735
|
if (this.lastFrame) {
|
|
2574
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");
|
|
2575
2739
|
}
|
|
2576
2740
|
return () => {
|
|
2577
2741
|
this.subscribers.delete(sub);
|
|
@@ -2591,19 +2755,32 @@ var LinuxAppSession = class {
|
|
|
2591
2755
|
this.width = evenW;
|
|
2592
2756
|
this.height = evenH;
|
|
2593
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
|
+
}
|
|
2594
2764
|
if (this.resizeTimer) clearTimeout(this.resizeTimer);
|
|
2595
2765
|
this.resizeTimer = setTimeout(() => {
|
|
2596
|
-
if (!this.closed) {
|
|
2766
|
+
if (!this.closed && this.streamerMode === "ffmpeg") {
|
|
2597
2767
|
this.lastFrame = null;
|
|
2598
|
-
this.
|
|
2768
|
+
this.startFfmpegFallbackCapture();
|
|
2599
2769
|
}
|
|
2600
|
-
},
|
|
2770
|
+
}, 160);
|
|
2601
2771
|
}
|
|
2602
2772
|
close() {
|
|
2603
2773
|
if (this.closed) return;
|
|
2604
2774
|
this.closed = true;
|
|
2605
2775
|
if (this.resizeTimer) clearTimeout(this.resizeTimer);
|
|
2606
|
-
const procs = [
|
|
2776
|
+
const procs = [
|
|
2777
|
+
this.streamerProc,
|
|
2778
|
+
this.parecProc,
|
|
2779
|
+
this.x11BridgeProc,
|
|
2780
|
+
this.appProc,
|
|
2781
|
+
this.openboxProc,
|
|
2782
|
+
this.xvfbProc
|
|
2783
|
+
];
|
|
2607
2784
|
for (const p of procs) {
|
|
2608
2785
|
if (p) {
|
|
2609
2786
|
try {
|
|
@@ -2625,13 +2802,13 @@ var LinuxAppSession = class {
|
|
|
2625
2802
|
fs6.rmSync(this.tempDir, { recursive: true, force: true });
|
|
2626
2803
|
} catch {
|
|
2627
2804
|
}
|
|
2628
|
-
},
|
|
2805
|
+
}, 500);
|
|
2629
2806
|
if (this.pulseSinkName) {
|
|
2630
2807
|
try {
|
|
2631
|
-
execSync2(
|
|
2632
|
-
|
|
2633
|
-
timeout: 1500
|
|
2634
|
-
|
|
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
|
+
);
|
|
2635
2812
|
} catch {
|
|
2636
2813
|
}
|
|
2637
2814
|
}
|
|
@@ -2685,8 +2862,205 @@ var LinuxDisplayBridge = class {
|
|
|
2685
2862
|
}
|
|
2686
2863
|
};
|
|
2687
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
|
+
|
|
2688
3062
|
// server/index.ts
|
|
2689
|
-
var TAMGA_VERSION = "1.
|
|
3063
|
+
var TAMGA_VERSION = "1.1.0";
|
|
2690
3064
|
var MIME_MAP = {
|
|
2691
3065
|
html: "text/html; charset=utf-8",
|
|
2692
3066
|
htm: "text/html; charset=utf-8",
|
|
@@ -2716,16 +3090,16 @@ var MIME_MAP = {
|
|
|
2716
3090
|
zip: "application/zip"
|
|
2717
3091
|
};
|
|
2718
3092
|
function resolveClientDistDir() {
|
|
2719
|
-
const here =
|
|
3093
|
+
const here = path8.dirname(fileURLToPath2(import.meta.url));
|
|
2720
3094
|
const candidates = [
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
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")
|
|
2726
3100
|
];
|
|
2727
3101
|
for (const dir of candidates) {
|
|
2728
|
-
if (
|
|
3102
|
+
if (fs8.existsSync(path8.join(dir, "index.html"))) {
|
|
2729
3103
|
return dir;
|
|
2730
3104
|
}
|
|
2731
3105
|
}
|
|
@@ -2740,15 +3114,23 @@ async function startTamgaServer(opts = {}) {
|
|
|
2740
3114
|
};
|
|
2741
3115
|
const configPath = loaded.configPath;
|
|
2742
3116
|
setStorageRoot(config.dataDir);
|
|
3117
|
+
const authManager = new AuthManager(config);
|
|
3118
|
+
const vscodeManager = new VSCodeServerManager(config.dataDir);
|
|
2743
3119
|
const app = express();
|
|
2744
3120
|
app.set("trust proxy", config.trustProxy);
|
|
2745
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
|
+
});
|
|
2746
3129
|
app.use(express.json({ limit: "25mb" }));
|
|
2747
3130
|
const upload = multer({
|
|
2748
3131
|
storage: multer.memoryStorage(),
|
|
2749
3132
|
limits: { fileSize: 50 * 1024 * 1024 }
|
|
2750
3133
|
});
|
|
2751
|
-
const authManager = new AuthManager(config);
|
|
2752
3134
|
const registry = new DesktopRegistry();
|
|
2753
3135
|
const vfsInstances = /* @__PURE__ */ new Map();
|
|
2754
3136
|
const chromiumCluster = new ChromiumCluster();
|
|
@@ -2900,10 +3282,10 @@ async function startTamgaServer(opts = {}) {
|
|
|
2900
3282
|
res.status(404).end();
|
|
2901
3283
|
return;
|
|
2902
3284
|
}
|
|
2903
|
-
const ext =
|
|
3285
|
+
const ext = path8.extname(iconPath).slice(1).toLowerCase();
|
|
2904
3286
|
res.setHeader("Content-Type", MIME_MAP[ext] || "image/png");
|
|
2905
3287
|
res.setHeader("Cache-Control", "public, max-age=86400");
|
|
2906
|
-
|
|
3288
|
+
fs8.createReadStream(iconPath).pipe(res);
|
|
2907
3289
|
});
|
|
2908
3290
|
app.post("/api/apps/launch", async (req, res) => {
|
|
2909
3291
|
try {
|
|
@@ -2982,6 +3364,24 @@ async function startTamgaServer(opts = {}) {
|
|
|
2982
3364
|
}
|
|
2983
3365
|
res.json(job);
|
|
2984
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
|
+
});
|
|
2985
3385
|
app.get("/api/desktops", (_req, res) => {
|
|
2986
3386
|
res.json({ desktops: registry.list() });
|
|
2987
3387
|
});
|
|
@@ -3156,20 +3556,20 @@ async function startTamgaServer(opts = {}) {
|
|
|
3156
3556
|
const { vfs } = getDesktopContext(extractReqDesktopId(req));
|
|
3157
3557
|
const vPath = String(req.query.path || "");
|
|
3158
3558
|
const diskPath = vfs.resolveDiskPath(vPath);
|
|
3159
|
-
if (!
|
|
3559
|
+
if (!fs8.existsSync(diskPath) || fs8.statSync(diskPath).isDirectory()) {
|
|
3160
3560
|
res.status(404).send("Dosya bulunamad\u0131");
|
|
3161
3561
|
return;
|
|
3162
3562
|
}
|
|
3163
|
-
const ext =
|
|
3563
|
+
const ext = path8.extname(diskPath).slice(1).toLowerCase();
|
|
3164
3564
|
const mime = MIME_MAP[ext] || "application/octet-stream";
|
|
3165
3565
|
res.setHeader("Content-Type", mime);
|
|
3166
3566
|
if (req.query.download === "1") {
|
|
3167
3567
|
res.setHeader(
|
|
3168
3568
|
"Content-Disposition",
|
|
3169
|
-
`attachment; filename*=UTF-8''${encodeURIComponent(
|
|
3569
|
+
`attachment; filename*=UTF-8''${encodeURIComponent(path8.basename(diskPath))}`
|
|
3170
3570
|
);
|
|
3171
3571
|
}
|
|
3172
|
-
|
|
3572
|
+
fs8.createReadStream(diskPath).pipe(res);
|
|
3173
3573
|
} catch (e) {
|
|
3174
3574
|
res.status(400).send(e.message);
|
|
3175
3575
|
}
|
|
@@ -3217,14 +3617,14 @@ async function startTamgaServer(opts = {}) {
|
|
|
3217
3617
|
try {
|
|
3218
3618
|
const { vfs } = getDesktopContext(extractReqDesktopId(req));
|
|
3219
3619
|
const diskPath = vfs.resolveWallpaperPath(req.params.fileName);
|
|
3220
|
-
if (!
|
|
3620
|
+
if (!fs8.existsSync(diskPath) || fs8.statSync(diskPath).isDirectory()) {
|
|
3221
3621
|
res.status(404).send("Arka plan bulunamad\u0131");
|
|
3222
3622
|
return;
|
|
3223
3623
|
}
|
|
3224
|
-
const ext =
|
|
3624
|
+
const ext = path8.extname(diskPath).slice(1).toLowerCase();
|
|
3225
3625
|
res.setHeader("Content-Type", MIME_MAP[ext] || "image/png");
|
|
3226
3626
|
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
|
|
3227
|
-
|
|
3627
|
+
fs8.createReadStream(diskPath).pipe(res);
|
|
3228
3628
|
} catch (e) {
|
|
3229
3629
|
res.status(400).send(e.message);
|
|
3230
3630
|
}
|
|
@@ -3255,10 +3655,10 @@ async function startTamgaServer(opts = {}) {
|
|
|
3255
3655
|
next();
|
|
3256
3656
|
return;
|
|
3257
3657
|
}
|
|
3258
|
-
res.sendFile(
|
|
3658
|
+
res.sendFile(path8.join(clientDist, "index.html"));
|
|
3259
3659
|
});
|
|
3260
3660
|
}
|
|
3261
|
-
const server =
|
|
3661
|
+
const server = http2.createServer(app);
|
|
3262
3662
|
const desktopWss = new WebSocketServer({ noServer: true });
|
|
3263
3663
|
const terminalWss = new WebSocketServer({ noServer: true });
|
|
3264
3664
|
const appWss = new WebSocketServer({ noServer: true });
|
|
@@ -3267,9 +3667,11 @@ async function startTamgaServer(opts = {}) {
|
|
|
3267
3667
|
ws.send(JSON.stringify(payload));
|
|
3268
3668
|
}
|
|
3269
3669
|
}
|
|
3270
|
-
function sendBinary(ws, packet) {
|
|
3271
|
-
if (ws.readyState === WebSocket.OPEN && ws.bufferedAmount <
|
|
3272
|
-
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?.();
|
|
3273
3675
|
}
|
|
3274
3676
|
}
|
|
3275
3677
|
server.on("upgrade", (req, socket, head) => {
|
|
@@ -3279,7 +3681,9 @@ async function startTamgaServer(opts = {}) {
|
|
|
3279
3681
|
return;
|
|
3280
3682
|
}
|
|
3281
3683
|
const reqUrl = new URL(req.url || "/ws", "http://localhost");
|
|
3282
|
-
if (reqUrl.pathname
|
|
3684
|
+
if (reqUrl.pathname.startsWith("/vscode-web")) {
|
|
3685
|
+
vscodeManager.proxyUpgrade(req, socket, head);
|
|
3686
|
+
} else if (reqUrl.pathname === "/ws") {
|
|
3283
3687
|
desktopWss.handleUpgrade(req, socket, head, (ws) => {
|
|
3284
3688
|
desktopWss.emit("connection", ws, req);
|
|
3285
3689
|
});
|
|
@@ -3393,11 +3797,11 @@ async function startTamgaServer(opts = {}) {
|
|
|
3393
3797
|
return;
|
|
3394
3798
|
}
|
|
3395
3799
|
const unsub = session.subscribe({
|
|
3396
|
-
onVideoFrame: (jpeg) => {
|
|
3800
|
+
onVideoFrame: (jpeg, done) => {
|
|
3397
3801
|
const pkt = Buffer.allocUnsafe(1 + jpeg.length);
|
|
3398
3802
|
pkt[0] = PACKET_VIDEO_JPEG;
|
|
3399
3803
|
jpeg.copy(pkt, 1);
|
|
3400
|
-
sendBinary(ws, pkt);
|
|
3804
|
+
sendBinary(ws, pkt, done);
|
|
3401
3805
|
},
|
|
3402
3806
|
onAudioChunk: (pcm) => {
|
|
3403
3807
|
const pkt = Buffer.allocUnsafe(1 + pcm.length);
|
|
@@ -3439,6 +3843,7 @@ async function startTamgaServer(opts = {}) {
|
|
|
3439
3843
|
clearInterval(telemetryTimer);
|
|
3440
3844
|
terminalManager.destroyAll();
|
|
3441
3845
|
linuxDisplayBridge.destroyAll();
|
|
3846
|
+
vscodeManager.stop();
|
|
3442
3847
|
server.close(() => process.exit(0));
|
|
3443
3848
|
setTimeout(() => process.exit(0), 2e3).unref();
|
|
3444
3849
|
};
|
|
@@ -3460,7 +3865,7 @@ async function startTamgaServer(opts = {}) {
|
|
|
3460
3865
|
return { server, config };
|
|
3461
3866
|
}
|
|
3462
3867
|
var selfPath = fileURLToPath2(import.meta.url);
|
|
3463
|
-
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);
|
|
3464
3869
|
if (isDirectRun) {
|
|
3465
3870
|
const devPort = Number(process.env.PORT || 3001);
|
|
3466
3871
|
startTamgaServer({ host: "127.0.0.1", port: devPort }).catch((err) => {
|
|
@@ -3538,11 +3943,11 @@ Se\xE7enekler:
|
|
|
3538
3943
|
`);
|
|
3539
3944
|
}
|
|
3540
3945
|
async function cmdInit(flags) {
|
|
3541
|
-
const configPath = typeof flags.config === "string" ?
|
|
3946
|
+
const configPath = typeof flags.config === "string" ? path9.resolve(flags.config) : getDefaultConfigPath();
|
|
3542
3947
|
const nonInteractive = Boolean(flags["non-interactive"]);
|
|
3543
3948
|
let port = Number(flags.port || 4800);
|
|
3544
3949
|
let host = String(flags.host || "0.0.0.0");
|
|
3545
|
-
let dataDir = typeof flags["data-dir"] === "string" ?
|
|
3950
|
+
let dataDir = typeof flags["data-dir"] === "string" ? path9.resolve(flags["data-dir"]) : getDefaultDataDir();
|
|
3546
3951
|
let authEnabled = flags["no-auth"] ? false : true;
|
|
3547
3952
|
let username = String(flags.user || "admin");
|
|
3548
3953
|
let password = typeof flags.password === "string" ? flags.password : "";
|
|
@@ -3554,7 +3959,7 @@ Ayar dosyas\u0131: ${configPath}
|
|
|
3554
3959
|
`);
|
|
3555
3960
|
port = Number(await ask(rl, "Dinlenecek port", String(port))) || 4800;
|
|
3556
3961
|
host = await ask(rl, "Dinlenecek adres (d\u0131\u015F eri\u015Fim i\xE7in 0.0.0.0)", host);
|
|
3557
|
-
dataDir =
|
|
3962
|
+
dataDir = path9.resolve(await ask(rl, "Veri dizini", dataDir));
|
|
3558
3963
|
const authAns = await ask(rl, "Giri\u015F ekran\u0131 / parola korumas\u0131 aktif olsun mu? (e/h)", authEnabled ? "e" : "h");
|
|
3559
3964
|
authEnabled = authAns.toLowerCase().startsWith("e") || authAns.toLowerCase().startsWith("y");
|
|
3560
3965
|
if (authEnabled) {
|
|
@@ -3574,7 +3979,7 @@ Ayar dosyas\u0131: ${configPath}
|
|
|
3574
3979
|
password: password || "tamga2026"
|
|
3575
3980
|
});
|
|
3576
3981
|
saveConfig(configPath, cfg);
|
|
3577
|
-
|
|
3982
|
+
fs9.mkdirSync(dataDir, { recursive: true });
|
|
3578
3983
|
console.log(`
|
|
3579
3984
|
\u2713 Yap\u0131land\u0131rma kaydedildi: ${configPath}`);
|
|
3580
3985
|
console.log(` Port : ${cfg.port} (${cfg.host})`);
|
|
@@ -3596,7 +4001,7 @@ function cmdSetupLinux(flags) {
|
|
|
3596
4001
|
"set -e",
|
|
3597
4002
|
"export DEBIAN_FRONTEND=noninteractive",
|
|
3598
4003
|
"apt-get update -y",
|
|
3599
|
-
"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"
|
|
3600
4005
|
];
|
|
3601
4006
|
if (withFirefox) {
|
|
3602
4007
|
parts.push(`
|
|
@@ -3631,10 +4036,10 @@ function cmdService(subCmd, flags) {
|
|
|
3631
4036
|
}
|
|
3632
4037
|
const unitName = "tamga-vdesktop.service";
|
|
3633
4038
|
const unitPath = `/etc/systemd/system/${unitName}`;
|
|
3634
|
-
const configPath = typeof flags.config === "string" ?
|
|
4039
|
+
const configPath = typeof flags.config === "string" ? path9.resolve(flags.config) : getDefaultConfigPath();
|
|
3635
4040
|
switch (subCmd) {
|
|
3636
4041
|
case "install": {
|
|
3637
|
-
if (!
|
|
4042
|
+
if (!fs9.existsSync(configPath)) {
|
|
3638
4043
|
const cfg = createDefaultConfig({
|
|
3639
4044
|
port: Number(flags.port || 4800),
|
|
3640
4045
|
host: String(flags.host || "0.0.0.0"),
|
|
@@ -3645,7 +4050,7 @@ function cmdService(subCmd, flags) {
|
|
|
3645
4050
|
console.log(`Varsay\u0131lan yap\u0131land\u0131rma olu\u015Fturuldu: ${configPath}`);
|
|
3646
4051
|
}
|
|
3647
4052
|
const nodeBin = process.execPath;
|
|
3648
|
-
const cliEntry =
|
|
4053
|
+
const cliEntry = path9.resolve(process.argv[1]);
|
|
3649
4054
|
const unitContent = `[Unit]
|
|
3650
4055
|
Description=TamgaVDesktop Virtual Desktop Server
|
|
3651
4056
|
After=network-online.target
|
|
@@ -3663,9 +4068,9 @@ LimitNOFILE=65536
|
|
|
3663
4068
|
[Install]
|
|
3664
4069
|
WantedBy=multi-user.target
|
|
3665
4070
|
`;
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
4071
|
+
fs9.writeFileSync(unitPath, unitContent, "utf-8");
|
|
4072
|
+
execSync4("systemctl daemon-reload", { stdio: "inherit" });
|
|
4073
|
+
execSync4(`systemctl enable --now ${unitName}`, { stdio: "inherit" });
|
|
3669
4074
|
console.log(`
|
|
3670
4075
|
\u2713 ${unitName} kuruldu ve ba\u015Flat\u0131ld\u0131.`);
|
|
3671
4076
|
console.log(` Durum : tamga-vdesktop service status`);
|
|
@@ -3675,7 +4080,7 @@ WantedBy=multi-user.target
|
|
|
3675
4080
|
case "start":
|
|
3676
4081
|
case "stop":
|
|
3677
4082
|
case "restart":
|
|
3678
|
-
|
|
4083
|
+
execSync4(`systemctl ${subCmd} ${unitName}`, { stdio: "inherit" });
|
|
3679
4084
|
break;
|
|
3680
4085
|
case "status":
|
|
3681
4086
|
spawnSync("systemctl", ["status", unitName, "--no-pager"], { stdio: "inherit" });
|
|
@@ -3685,11 +4090,11 @@ WantedBy=multi-user.target
|
|
|
3685
4090
|
break;
|
|
3686
4091
|
case "uninstall":
|
|
3687
4092
|
try {
|
|
3688
|
-
|
|
4093
|
+
execSync4(`systemctl disable --now ${unitName}`, { stdio: "inherit" });
|
|
3689
4094
|
} catch {
|
|
3690
4095
|
}
|
|
3691
|
-
if (
|
|
3692
|
-
|
|
4096
|
+
if (fs9.existsSync(unitPath)) fs9.unlinkSync(unitPath);
|
|
4097
|
+
execSync4("systemctl daemon-reload", { stdio: "inherit" });
|
|
3693
4098
|
console.log(`\u2713 ${unitName} kald\u0131r\u0131ld\u0131.`);
|
|
3694
4099
|
break;
|
|
3695
4100
|
default:
|
|
@@ -3718,7 +4123,7 @@ TamgaVDesktop v${TAMGA_VERSION} \u2014 Sistem Te\u015Fhisi`);
|
|
|
3718
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`);
|
|
3719
4124
|
console.log(`\u0130\u015Fletim Sistemi : ${status.distro}`);
|
|
3720
4125
|
console.log(`Node.js : ${process.version}`);
|
|
3721
|
-
console.log(`Ayar Dosyas\u0131 : ${configPath} (${
|
|
4126
|
+
console.log(`Ayar Dosyas\u0131 : ${configPath} (${fs9.existsSync(configPath) ? "mevcut" : "varsay\u0131lan"})`);
|
|
3722
4127
|
console.log(`Dinleme Adresi : ${config.host}:${config.port}`);
|
|
3723
4128
|
console.log(`Veri Dizini : ${config.dataDir}`);
|
|
3724
4129
|
console.log(`Giri\u015F Korumas\u0131 : ${config.auth.enabled ? `Aktif (${config.auth.username})` : "Kapal\u0131"}`);
|