🐛 修复非凭据登录终端处理逻辑bug
This commit is contained in:
parent
660ca88dac
commit
66f4153981
@ -8,9 +8,9 @@ module.exports = {
|
|||||||
uploadDir: path.join(process.cwd(),'app/db'),
|
uploadDir: path.join(process.cwd(),'app/db'),
|
||||||
staticDir: path.join(process.cwd(),'app/static'),
|
staticDir: path.join(process.cwd(),'app/static'),
|
||||||
sftpCacheDir: path.join(process.cwd(),'app/socket/sftp-cache'),
|
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'),
|
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'),
|
notifyConfDBPath: path.join(process.cwd(),'app/db/notify.db'),
|
||||||
groupConfDBPath: path.join(process.cwd(),'app/db/group.db'),
|
groupConfDBPath: path.join(process.cwd(),'app/db/group.db'),
|
||||||
emailNotifyDBPath: path.join(process.cwd(),'app/db/email.db'),
|
emailNotifyDBPath: path.join(process.cwd(),'app/db/email.db'),
|
||||||
|
@ -226,6 +226,8 @@ module.exports = (httpServer) => {
|
|||||||
const sshRecord = sshRecordList.find(item => item._id === credentialId)
|
const sshRecord = sshRecordList.find(item => item._id === credentialId)
|
||||||
authInfo.authType = sshRecord.authType
|
authInfo.authType = sshRecord.authType
|
||||||
authInfo[authInfo.authType] = await AESDecryptSync(sshRecord[authInfo.authType])
|
authInfo[authInfo.authType] = await AESDecryptSync(sshRecord[authInfo.authType])
|
||||||
|
} else {
|
||||||
|
authInfo[authType] = await AESDecryptSync(targetHostInfo[authType])
|
||||||
}
|
}
|
||||||
consola.info('准备连接Sftp面板:', host)
|
consola.info('准备连接Sftp面板:', host)
|
||||||
targetHostInfo[targetHostInfo.authType] = await AESDecryptSync(targetHostInfo[targetHostInfo.authType])
|
targetHostInfo[targetHostInfo.authType] = await AESDecryptSync(targetHostInfo[targetHostInfo.authType])
|
||||||
|
@ -63,15 +63,16 @@ module.exports = (httpServer) => {
|
|||||||
const sshRecord = sshRecordList.find(item => item._id === credentialId)
|
const sshRecord = sshRecordList.find(item => item._id === credentialId)
|
||||||
authInfo.authType = sshRecord.authType
|
authInfo.authType = sshRecord.authType
|
||||||
authInfo[authInfo.authType] = await AESDecryptSync(sshRecord[authInfo.authType])
|
authInfo[authInfo.authType] = await AESDecryptSync(sshRecord[authInfo.authType])
|
||||||
|
} else {
|
||||||
|
authInfo[authType] = await AESDecryptSync(targetHostInfo[authType])
|
||||||
}
|
}
|
||||||
consola.info('准备连接终端:', host)
|
consola.info('准备连接终端:', host)
|
||||||
targetHostInfo[targetHostInfo.authType] = await AESDecryptSync(targetHostInfo[targetHostInfo.authType])
|
targetHostInfo[targetHostInfo.authType] = await AESDecryptSync(targetHostInfo[targetHostInfo.authType])
|
||||||
// :TODO: 初始化后连接失败...
|
console.log('authInfo:', authInfo)
|
||||||
// console.log('targetHostInfo:', targetHostInfo)
|
|
||||||
consola.log('连接信息', { username, port, authType })
|
consola.log('连接信息', { username, port, authType })
|
||||||
sshClient
|
sshClient
|
||||||
.on('ready', () => {
|
.on('ready', () => {
|
||||||
consola.success('已连接到终端:', host)
|
consola.success('连接终端成功:', host)
|
||||||
socket.emit('connect_success', `已连接到终端:${ host }`)
|
socket.emit('connect_success', `已连接到终端:${ host }`)
|
||||||
createTerminal(socket, sshClient)
|
createTerminal(socket, sshClient)
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const Datastore = require('@seald-io/nedb')
|
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 {
|
module.exports.KeyDB = class KeyDB {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -26,7 +26,7 @@ module.exports.HostListDB = class HostListDB {
|
|||||||
module.exports.SshRecordDB = class SshRecordDB {
|
module.exports.SshRecordDB = class SshRecordDB {
|
||||||
constructor() {
|
constructor() {
|
||||||
if (!SshRecordDB.instance) {
|
if (!SshRecordDB.instance) {
|
||||||
SshRecordDB.instance = new Datastore({ filename: sshRecordDBPath, autoload: true })
|
SshRecordDB.instance = new Datastore({ filename: credentialsDBPath, autoload: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getInstance() {
|
getInstance() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user