mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 16:29:17 +08:00
fix: 解决部分 ssh 登录日志解析失败的问题 (#5081)
This commit is contained in:
parent
d9f9f9a629
commit
6131a99db0
@ -479,9 +479,12 @@ func loadFailedAuthDatas(line string) dto.SSHHistory {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
data.DateStr = dataStr
|
data.DateStr = dataStr
|
||||||
if index == 2 {
|
switch index {
|
||||||
|
case 1:
|
||||||
|
data.User = parts[9]
|
||||||
|
case 2:
|
||||||
data.User = parts[10]
|
data.User = parts[10]
|
||||||
} else {
|
default:
|
||||||
data.User = parts[7]
|
data.User = parts[7]
|
||||||
}
|
}
|
||||||
data.AuthMode = parts[6+index]
|
data.AuthMode = parts[6+index]
|
||||||
@ -543,14 +546,22 @@ func loadDate(currentYear int, DateStr string, nyc *time.Location) time.Time {
|
|||||||
|
|
||||||
func analyzeDateStr(parts []string) (int, string) {
|
func analyzeDateStr(parts []string) (int, string) {
|
||||||
t, err := time.Parse("2006-01-02T15:04:05.999999-07:00", parts[0])
|
t, err := time.Parse("2006-01-02T15:04:05.999999-07:00", parts[0])
|
||||||
if err != nil {
|
if err == nil {
|
||||||
|
if len(parts) < 12 {
|
||||||
|
return 0, ""
|
||||||
|
}
|
||||||
|
return 0, t.Format("2006 Jan 2 15:04:05")
|
||||||
|
}
|
||||||
|
t, err = time.Parse("2006-01-02 15:04:05", fmt.Sprintf("%s %s", parts[0], parts[1]))
|
||||||
|
if err == nil {
|
||||||
if len(parts) < 14 {
|
if len(parts) < 14 {
|
||||||
return 0, ""
|
return 0, ""
|
||||||
}
|
}
|
||||||
return 2, fmt.Sprintf("%s %s %s", parts[0], parts[1], parts[2])
|
return 1, t.Format("2006 Jan 2 15:04:05")
|
||||||
}
|
}
|
||||||
if len(parts) < 12 {
|
|
||||||
|
if len(parts) < 14 {
|
||||||
return 0, ""
|
return 0, ""
|
||||||
}
|
}
|
||||||
return 0, t.Format("2006 Jan 2 15:04:05")
|
return 2, fmt.Sprintf("%s %s %s", parts[0], parts[1], parts[2])
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user