🐛 修复非凭据登录终端处理逻辑bug

This commit is contained in:
chaoszhu 2024-07-23 11:27:00 +08:00
parent 660ca88dac
commit 66f4153981
4 changed files with 10 additions and 7 deletions

View File

@ -8,9 +8,9 @@ module.exports = {
uploadDir: path.join(process.cwd(),'app/db'),
staticDir: path.join(process.cwd(),'app/static'),
sftpCacheDir: path.join(process.cwd(),'app/socket/sftp-cache'),
sshRecordDBPath: path.join(process.cwd(),'app/db/ssh-record.db'),
credentialsDBPath: path.join(process.cwd(),'app/db/credentials.db'),
keyDBPath: path.join(process.cwd(),'app/db/key.db'),
hostListDBPath: path.join(process.cwd(),'app/db/host-list.db'),
hostListDBPath: path.join(process.cwd(),'app/db/host.db'),
notifyConfDBPath: path.join(process.cwd(),'app/db/notify.db'),
groupConfDBPath: path.join(process.cwd(),'app/db/group.db'),
emailNotifyDBPath: path.join(process.cwd(),'app/db/email.db'),

View File

@ -226,6 +226,8 @@ module.exports = (httpServer) => {
const sshRecord = sshRecordList.find(item => item._id === credentialId)
authInfo.authType = sshRecord.authType
authInfo[authInfo.authType] = await AESDecryptSync(sshRecord[authInfo.authType])
} else {
authInfo[authType] = await AESDecryptSync(targetHostInfo[authType])
}
consola.info('准备连接Sftp面板', host)
targetHostInfo[targetHostInfo.authType] = await AESDecryptSync(targetHostInfo[targetHostInfo.authType])

View File

@ -63,15 +63,16 @@ module.exports = (httpServer) => {
const sshRecord = sshRecordList.find(item => item._id === credentialId)
authInfo.authType = sshRecord.authType
authInfo[authInfo.authType] = await AESDecryptSync(sshRecord[authInfo.authType])
} else {
authInfo[authType] = await AESDecryptSync(targetHostInfo[authType])
}
consola.info('准备连接终端:', host)
targetHostInfo[targetHostInfo.authType] = await AESDecryptSync(targetHostInfo[targetHostInfo.authType])
// :TODO: 初始化后连接失败...
// console.log('targetHostInfo:', targetHostInfo)
console.log('authInfo:', authInfo)
consola.log('连接信息', { username, port, authType })
sshClient
.on('ready', () => {
consola.success('连接终端:', host)
consola.success('连接终端成功', host)
socket.emit('connect_success', `已连接到终端:${ host }`)
createTerminal(socket, sshClient)
})

View File

@ -1,5 +1,5 @@
const Datastore = require('@seald-io/nedb')
const { sshRecordDBPath, hostListDBPath, keyDBPath, emailNotifyDBPath, notifyConfDBPath, groupConfDBPath } = require('../config')
const { credentialsDBPath, hostListDBPath, keyDBPath, emailNotifyDBPath, notifyConfDBPath, groupConfDBPath } = require('../config')
module.exports.KeyDB = class KeyDB {
constructor() {
@ -26,7 +26,7 @@ module.exports.HostListDB = class HostListDB {
module.exports.SshRecordDB = class SshRecordDB {
constructor() {
if (!SshRecordDB.instance) {
SshRecordDB.instance = new Datastore({ filename: sshRecordDBPath, autoload: true })
SshRecordDB.instance = new Datastore({ filename: credentialsDBPath, autoload: true })
}
}
getInstance() {