From e507611cadcf0987f35a3d0e6a160b5736431ae3 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com> Date: Tue, 4 Jul 2023 11:36:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20SSH=20=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E5=9C=A8=E5=A4=9A=E4=B8=AA=E8=BF=9E=E6=8E=A5=E4=B8=8B?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#1525)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app_utils.go | 3 +++ backend/utils/websocket/process_data.go | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 9fe09a0d0..77b2b639c 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -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 diff --git a/backend/utils/websocket/process_data.go b/backend/utils/websocket/process_data.go index 83b63d6f5..4a8d130c6 100644 --- a/backend/utils/websocket/process_data.go +++ b/backend/utils/websocket/process_data.go @@ -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) } } }