Switched to UTF-8 fixing non-english character bugs, revamped console logging system, fixed misc console errors, and fixed copy/paste. Warning: the terminal sizing in this version is very buggy so be warned.
This commit is contained in:
@@ -22,7 +22,7 @@ io.on("connection", (socket) => {
|
||||
console.error("Invalid hostConfig received:", hostConfig);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Redact only sensitive info for logging
|
||||
const safeHostConfig = {
|
||||
ip: hostConfig.ip,
|
||||
@@ -31,7 +31,7 @@ io.on("connection", (socket) => {
|
||||
password: hostConfig.password ? '***REDACTED***' : undefined,
|
||||
rsaKey: hostConfig.rsaKey ? '***REDACTED***' : undefined,
|
||||
};
|
||||
|
||||
|
||||
console.log("Received hostConfig:", safeHostConfig);
|
||||
const { ip, port, user, password, rsaKey } = hostConfig;
|
||||
|
||||
@@ -39,25 +39,22 @@ io.on("connection", (socket) => {
|
||||
conn
|
||||
.on("ready", function () {
|
||||
console.log("SSH connection established");
|
||||
socket.emit("data", "\r\n*** SSH CONNECTION ESTABLISHED ***\r\n");
|
||||
|
||||
conn.shell({ term: "xterm-256color" }, function (err, newStream) {
|
||||
if (err) {
|
||||
console.error("Error opening SSH shell:", err);
|
||||
return socket.emit(
|
||||
"data",
|
||||
"\r\n*** SSH SHELL ERROR: " + err.message + " ***\r\n"
|
||||
);
|
||||
console.error("Error:", err.message);
|
||||
socket.emit("error", err.message);
|
||||
return;
|
||||
}
|
||||
stream = newStream;
|
||||
|
||||
stream = newStream;
|
||||
// Set initial terminal size
|
||||
stream.setWindow(rows, cols, rows * 100, cols * 100);
|
||||
console.log(`Initial terminal size: cols=${cols}, rows=${rows}`);
|
||||
|
||||
// Pipe SSH output to client
|
||||
stream.on("data", function (data) {
|
||||
socket.emit("data", data.toString("binary"));
|
||||
socket.emit("data", data);
|
||||
});
|
||||
|
||||
stream.on("close", function () {
|
||||
@@ -84,14 +81,11 @@ io.on("connection", (socket) => {
|
||||
})
|
||||
.on("close", function () {
|
||||
console.log("SSH connection closed");
|
||||
socket.emit("data", "\r\n*** SSH CONNECTION CLOSED ***\r\n");
|
||||
socket.emit("error", "SSH connection closed");
|
||||
})
|
||||
.on("error", function (err) {
|
||||
console.error("SSH connection error:", err);
|
||||
socket.emit(
|
||||
"data",
|
||||
"\r\n*** SSH CONNECTION ERROR: " + err.message + " ***\r\n"
|
||||
);
|
||||
console.error("Error:", err.message);
|
||||
socket.emit("error", err.message);
|
||||
})
|
||||
.connect({
|
||||
host: ip,
|
||||
@@ -109,4 +103,4 @@ io.on("connection", (socket) => {
|
||||
|
||||
server.listen(8081, '0.0.0.0', () => {
|
||||
console.log("Server is running on port 8081");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user