mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-20 14:45:42 +02:00
refactor(wss): simplify container ID validation and update Docker command structure
This commit is contained in:
@@ -3,7 +3,7 @@ import { findServerById, IS_CLOUD, validateRequest } from "@dokploy/server";
|
||||
import { spawn } from "node-pty";
|
||||
import { Client } from "ssh2";
|
||||
import { WebSocketServer } from "ws";
|
||||
import { getShell, isValidContainerId, isValidShell } from "./utils";
|
||||
import { isValidContainerId, isValidShell } from "./utils";
|
||||
|
||||
export const setupDockerContainerTerminalWebSocketServer = (
|
||||
server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>,
|
||||
@@ -34,11 +34,6 @@ export const setupDockerContainerTerminalWebSocketServer = (
|
||||
const serverId = url.searchParams.get("serverId");
|
||||
const { user, session } = await validateRequest(req);
|
||||
|
||||
if (!containerId) {
|
||||
ws.close(4000, "containerId no provided");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!containerId) {
|
||||
ws.close(4000, "containerId not provided");
|
||||
return;
|
||||
@@ -150,10 +145,9 @@ export const setupDockerContainerTerminalWebSocketServer = (
|
||||
ws.close();
|
||||
return;
|
||||
}
|
||||
const shell = getShell();
|
||||
const ptyProcess = spawn(
|
||||
shell,
|
||||
["-c", `docker exec -it -w / ${containerId} ${activeWay}`],
|
||||
"docker",
|
||||
["exec", "-it", "-w", "/", containerId, shell],
|
||||
{},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user