Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit da14b39

Browse files
committed
Feat: add ctrl+c func
1 parent 8caafc1 commit da14b39

File tree

4 files changed

+3
-17
lines changed

4 files changed

+3
-17
lines changed

src/entity/commands/pty/pty_stop.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export default class PtyStopCommand extends InstanceCommand {
1111
}
1212

1313
async exec(instance: Instance) {
14-
const stopCommand = instance.config.stopCommand;
15-
if (stopCommand.toLocaleLowerCase() == "^c") return instance.failure(new Error($t("pty_stop.ctrlC")));
14+
let stopCommand = instance.config.stopCommand;
15+
if (stopCommand.toLocaleLowerCase() == "^c") stopCommand = "\x03";
1616

1717
if (instance.status() === Instance.STATUS_STOP || !instance.process) return instance.failure(new Error($t("pty_stop.notRunning")));
1818
instance.status(Instance.STATUS_STOPPING);

src/i18n/language/zh_cn.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ export default {
144144
},
145145
// src\entity\commands\pty\pty_stop.ts
146146
pty_stop: {
147-
ctrlC: "仿真终端无法使用Ctrl+C命令关闭进程,请重新设置关服命令",
148147
notRunning: "实例未处于运行中状态,无法进行停止.",
149148
execCmd: "已执行预设的关闭命令:{{stopCommand}}\n如果无法关闭实例请前往实例设置更改关闭实例的正确命令,比如 exit,stop,end 等",
150149
stopErr:

src/routers/Instance_router.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -301,17 +301,6 @@ routerApp.on("instance/stop_asynchronous", (ctx, data) => {
301301
protocol.msg(ctx, "instance/stop_asynchronous", true);
302302
});
303303

304-
// send data stream to application instance
305-
routerApp.on("instance/stdin", (ctx, data) => {
306-
// This route uses a low-compatibility and direct and original way to write data
307-
// because this route will receive every character
308-
const instance = InstanceSubsystem.getInstance(data.instanceUuid);
309-
try {
310-
if (data.ch == "\r") return instance.process.write("\n");
311-
instance.process.write(data.ch);
312-
} catch (err) {}
313-
});
314-
315304
routerApp.on("instance/process_config/list", (ctx, data) => {
316305
const instanceUuid = data.instanceUuid;
317306
const files = data.files;

src/routers/stream_router.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ routerApp.on("stream/auth", (ctx, data) => {
5353
// Cancel forwarding events when registration is disconnected
5454
ctx.socket.on("disconnect", () => {
5555
InstanceSubsystem.stopForward(instance.instanceUuid, ctx.socket);
56-
logger.info(
57-
$t("stream_router.disconnect", { id: ctx.socket.id, address: ctx.socket.handshake.address, uuid: instance.instanceUuid })
58-
);
56+
logger.info($t("stream_router.disconnect", { id: ctx.socket.id, address: ctx.socket.handshake.address, uuid: instance.instanceUuid }));
5957
});
6058
protocol.response(ctx, true);
6159
} catch (error) {

0 commit comments

Comments
 (0)