mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-11-10 19:50:53 +08:00
fix: 修改 ssh 登录日志排序规则 (#1264)
This commit is contained in:
parent
056c771d2e
commit
4fdb81642a
4 changed files with 35 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"os/user"
|
"os/user"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -222,6 +223,7 @@ func (u *SSHService) LoadLog(req dto.SearchSSHLog) (*dto.SSHLog, error) {
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
fileList = sortFileList(fileList)
|
||||||
|
|
||||||
command := ""
|
command := ""
|
||||||
if len(req.Info) != 0 {
|
if len(req.Info) != 0 {
|
||||||
|
|
@ -284,6 +286,26 @@ func (u *SSHService) LoadLog(req dto.SearchSSHLog) (*dto.SSHLog, error) {
|
||||||
return &data, nil
|
return &data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sortFileList(fileNames []string) []string {
|
||||||
|
if len(fileNames) < 2 {
|
||||||
|
return fileNames
|
||||||
|
}
|
||||||
|
var itemFile []string
|
||||||
|
if strings.Contains(fileNames[0], "secure") {
|
||||||
|
sort.Slice(fileNames, func(i, j int) bool {
|
||||||
|
return fileNames[i] < fileNames[j]
|
||||||
|
})
|
||||||
|
itemFile = append(itemFile, fileNames[1:]...)
|
||||||
|
itemFile = append(itemFile, fileNames[0])
|
||||||
|
return itemFile
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(fileNames, func(i, j int) bool {
|
||||||
|
return fileNames[i] > fileNames[j]
|
||||||
|
})
|
||||||
|
return fileNames
|
||||||
|
}
|
||||||
|
|
||||||
func updateSSHConf(oldFiles []string, param string, value interface{}) []string {
|
func updateSSHConf(oldFiles []string, param string, value interface{}) []string {
|
||||||
hasKey := false
|
hasKey := false
|
||||||
var newFiles []string
|
var newFiles []string
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,7 @@ const message = {
|
||||||
container: 'Container',
|
container: 'Container',
|
||||||
cronjob: 'Cronjob',
|
cronjob: 'Cronjob',
|
||||||
host: 'Host',
|
host: 'Host',
|
||||||
|
ssh: 'SSH Setting',
|
||||||
security: 'Security',
|
security: 'Security',
|
||||||
files: 'File',
|
files: 'File',
|
||||||
monitor: 'Monitor',
|
monitor: 'Monitor',
|
||||||
|
|
@ -869,6 +870,8 @@ const message = {
|
||||||
fileUploadStart: 'Uploading [{0}]....',
|
fileUploadStart: 'Uploading [{0}]....',
|
||||||
},
|
},
|
||||||
ssh: {
|
ssh: {
|
||||||
|
sshAlert:
|
||||||
|
'The list data is sorted based on login time, but please note that changing time zones or other operations may cause deviations in the time of login logs.',
|
||||||
sshOperate: 'Operation [{0}] on the SSH service is performed. Do you want to continue?',
|
sshOperate: 'Operation [{0}] on the SSH service is performed. Do you want to continue?',
|
||||||
sshChange: 'SSH Setting',
|
sshChange: 'SSH Setting',
|
||||||
sshChangeHelper: 'This action changed {0} to [{1}]. Do you want to continue?',
|
sshChangeHelper: 'This action changed {0} to [{1}]. Do you want to continue?',
|
||||||
|
|
|
||||||
|
|
@ -863,6 +863,7 @@ const message = {
|
||||||
fileUploadStart: '正在上传[{0}]....',
|
fileUploadStart: '正在上传[{0}]....',
|
||||||
},
|
},
|
||||||
ssh: {
|
ssh: {
|
||||||
|
sshAlert: '列表数据根据登录时间排序,但请注意,切换时区或其他操作可能导致登录日志的时间出现偏差。',
|
||||||
sshOperate: '对 SSH 服务进行 [{0}] 操作,是否继续?',
|
sshOperate: '对 SSH 服务进行 [{0}] 操作,是否继续?',
|
||||||
sshChange: 'SSH 配置修改',
|
sshChange: 'SSH 配置修改',
|
||||||
sshChangeHelper: '此操作将 {0} 修改为 [{1}] ,是否继续?',
|
sshChangeHelper: '此操作将 {0} 修改为 [{1}] ,是否继续?',
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<LayoutContent v-loading="loading" :title="$t('ssh.loginLogs')">
|
<LayoutContent v-loading="loading" :title="$t('ssh.loginLogs')">
|
||||||
|
<template #prompt>
|
||||||
|
<el-alert type="info" :closable="false">
|
||||||
|
<template #default>
|
||||||
|
<span>
|
||||||
|
{{ $t('ssh.sshAlert') }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-alert>
|
||||||
|
</template>
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :xs="24" :sm="16" :md="16" :lg="16" :xl="16">
|
<el-col :xs="24" :sm="16" :md="16" :lg="16" :xl="16">
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue