fix: 解决 SSH 会话在多个连接下显示错误的问题 (#1525)

This commit is contained in:
zhengkunwang223 2023-07-04 11:36:10 +08:00 committed by GitHub
parent 72dcdbad1e
commit e507611cad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View File

@ -789,6 +789,9 @@ func handleInstalled(appInstallList []model.AppInstall, updated bool) ([]respons
versions = append(versions, detail.Version)
}
versions = common.GetSortedVersions(versions)
if len(versions) == 0 {
continue
}
lastVersion := versions[0]
if common.IsCrossVersion(installed.Version, lastVersion) {
installDTO.CanUpdate = app.CrossVersionUpdate

View File

@ -275,15 +275,19 @@ func getSSHSessions(config SSHSessionConfig) (res []byte, err error) {
if config.LoginIP != "" && !strings.Contains(user.Host, config.LoginIP) {
continue
}
session := sshSession{
Username: user.User,
Host: user.Host,
Terminal: user.Terminal,
PID: proc.Pid,
if terminal, err := proc.Cmdline(); err == nil {
if strings.Contains(terminal, user.Terminal) {
session := sshSession{
Username: user.User,
Host: user.Host,
Terminal: user.Terminal,
PID: proc.Pid,
}
t := time.Unix(int64(user.Started), 0)
session.LoginTime = t.Format("2006-1-2 15:04:05")
result = append(result, session)
}
}
t := time.Unix(int64(user.Started), 0)
session.LoginTime = t.Format("2006-1-2 15:04:05")
result = append(result, session)
}
}
}