Fix backend SSH issues
This commit is contained in:
@@ -62,16 +62,6 @@ function createWindow() {
|
|||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => {
|
|
||||||
callback({ requestHeaders: details.requestHeaders });
|
|
||||||
});
|
|
||||||
|
|
||||||
mainWindow.webContents.session.cookies.onChanged((event, cookie, cause, removed) => {
|
|
||||||
if (!removed) {
|
|
||||||
console.log('Cookie set:', cookie.name, 'for domain:', cookie.domain);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mainWindow.webContents.on(
|
mainWindow.webContents.on(
|
||||||
"did-fail-load",
|
"did-fail-load",
|
||||||
(event, errorCode, errorDescription, validatedURL) => {
|
(event, errorCode, errorDescription, validatedURL) => {
|
||||||
|
|||||||
@@ -275,7 +275,9 @@ app.post("/ssh/file_manager/ssh/connect", async (req, res) => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (resolvedCredentials.sshKey && resolvedCredentials.sshKey.trim()) {
|
if (resolvedCredentials.authType === "password" && resolvedCredentials.password && resolvedCredentials.password.trim()) {
|
||||||
|
config.password = resolvedCredentials.password;
|
||||||
|
} else if (resolvedCredentials.authType === "key" && resolvedCredentials.sshKey && resolvedCredentials.sshKey.trim()) {
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
!resolvedCredentials.sshKey.includes("-----BEGIN") ||
|
!resolvedCredentials.sshKey.includes("-----BEGIN") ||
|
||||||
@@ -302,16 +304,14 @@ app.post("/ssh/file_manager/ssh/connect", async (req, res) => {
|
|||||||
});
|
});
|
||||||
return res.status(400).json({ error: "Invalid SSH key format" });
|
return res.status(400).json({ error: "Invalid SSH key format" });
|
||||||
}
|
}
|
||||||
} else if (
|
|
||||||
resolvedCredentials.password &&
|
|
||||||
resolvedCredentials.password.trim()
|
|
||||||
) {
|
|
||||||
config.password = resolvedCredentials.password;
|
|
||||||
} else {
|
} else {
|
||||||
fileLogger.warn("No authentication method provided for file manager", {
|
fileLogger.warn("No valid authentication method provided for file manager", {
|
||||||
operation: "file_connect",
|
operation: "file_connect",
|
||||||
sessionId,
|
sessionId,
|
||||||
hostId,
|
hostId,
|
||||||
|
authType: resolvedCredentials.authType,
|
||||||
|
hasPassword: !!resolvedCredentials.password,
|
||||||
|
hasKey: !!resolvedCredentials.sshKey,
|
||||||
});
|
});
|
||||||
return res
|
return res
|
||||||
.status(400)
|
.status(400)
|
||||||
|
|||||||
@@ -588,7 +588,9 @@ wss.on("connection", async (ws: WebSocket, req) => {
|
|||||||
compress: ["none", "zlib@openssh.com", "zlib"],
|
compress: ["none", "zlib@openssh.com", "zlib"],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if (resolvedCredentials.authType === "key" && resolvedCredentials.key) {
|
if (resolvedCredentials.authType === "password" && resolvedCredentials.password) {
|
||||||
|
connectConfig.password = resolvedCredentials.password;
|
||||||
|
} else if (resolvedCredentials.authType === "key" && resolvedCredentials.key) {
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
!resolvedCredentials.key.includes("-----BEGIN") ||
|
!resolvedCredentials.key.includes("-----BEGIN") ||
|
||||||
@@ -634,7 +636,14 @@ wss.on("connection", async (ws: WebSocket, req) => {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
connectConfig.password = resolvedCredentials.password;
|
sshLogger.error("No valid authentication method provided");
|
||||||
|
ws.send(
|
||||||
|
JSON.stringify({
|
||||||
|
type: "error",
|
||||||
|
message: "No valid authentication method provided",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sshConn.connect(connectConfig);
|
sshConn.connect(connectConfig);
|
||||||
|
|||||||
@@ -914,9 +914,6 @@ export function CredentialsManager({
|
|||||||
setDropdownOpen(false);
|
setDropdownOpen(false);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onFocus={() => {
|
|
||||||
setDropdownOpen(true);
|
|
||||||
}}
|
|
||||||
className="w-full"
|
className="w-full"
|
||||||
autoFocus={false}
|
autoFocus={false}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -598,6 +598,7 @@ export const Terminal = forwardRef<any, SSHTerminalProps>(function SSHTerminal(
|
|||||||
resizeObserver.observe(xtermRef.current);
|
resizeObserver.observe(xtermRef.current);
|
||||||
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
setIsConnecting(true); // Show connecting state immediately
|
||||||
|
|
||||||
const readyFonts =
|
const readyFonts =
|
||||||
(document as any).fonts?.ready instanceof Promise
|
(document as any).fonts?.ready instanceof Promise
|
||||||
|
|||||||
Reference in New Issue
Block a user