mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-09-07 23:25:30 +08:00
fix: Add non-standard log filtering for SSH (#9865)
This commit is contained in:
parent
a30066989b
commit
39bb7acdba
1 changed files with 12 additions and 4 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"os/user"
|
||||
"path"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -541,7 +542,7 @@ func loadSSHData(ctx *gin.Context, command string, showCountFrom, showCountTo, c
|
|||
switch {
|
||||
case strings.Contains(lines[i], "Failed password for"):
|
||||
itemData = loadFailedSecureDatas(lines[i])
|
||||
if len(itemData.Address) != 0 {
|
||||
if checkIsStandard(itemData) {
|
||||
if successCount+failedCount >= showCountFrom && successCount+failedCount < showCountTo {
|
||||
itemData.Area, _ = geo.GetIPLocation(getLoc, itemData.Address, common.GetLang(ctx))
|
||||
itemData.Date = loadDate(currentYear, itemData.DateStr, nyc)
|
||||
|
@ -551,7 +552,7 @@ func loadSSHData(ctx *gin.Context, command string, showCountFrom, showCountTo, c
|
|||
}
|
||||
case strings.Contains(lines[i], "Connection closed by authenticating user"):
|
||||
itemData = loadFailedAuthDatas(lines[i])
|
||||
if len(itemData.Address) != 0 {
|
||||
if checkIsStandard(itemData) {
|
||||
if successCount+failedCount >= showCountFrom && successCount+failedCount < showCountTo {
|
||||
itemData.Area, _ = geo.GetIPLocation(getLoc, itemData.Address, common.GetLang(ctx))
|
||||
itemData.Date = loadDate(currentYear, itemData.DateStr, nyc)
|
||||
|
@ -561,7 +562,7 @@ func loadSSHData(ctx *gin.Context, command string, showCountFrom, showCountTo, c
|
|||
}
|
||||
case strings.Contains(lines[i], "Accepted "):
|
||||
itemData = loadSuccessDatas(lines[i])
|
||||
if len(itemData.Address) != 0 {
|
||||
if checkIsStandard(itemData) {
|
||||
if successCount+failedCount >= showCountFrom && successCount+failedCount < showCountTo {
|
||||
itemData.Area, _ = geo.GetIPLocation(getLoc, itemData.Address, common.GetLang(ctx))
|
||||
itemData.Date = loadDate(currentYear, itemData.DateStr, nyc)
|
||||
|
@ -589,7 +590,6 @@ func loadSuccessDatas(line string) dto.SSHHistory {
|
|||
data.Status = constant.StatusSuccess
|
||||
return data
|
||||
}
|
||||
|
||||
func loadFailedAuthDatas(line string) dto.SSHHistory {
|
||||
var data dto.SSHHistory
|
||||
parts := strings.Fields(line)
|
||||
|
@ -639,6 +639,14 @@ func loadFailedSecureDatas(line string) dto.SSHHistory {
|
|||
return data
|
||||
}
|
||||
|
||||
func checkIsStandard(item dto.SSHHistory) bool {
|
||||
if len(item.Address) == 0 {
|
||||
return false
|
||||
}
|
||||
portItem, _ := strconv.Atoi(item.Port)
|
||||
return portItem != 0
|
||||
}
|
||||
|
||||
func handleGunzip(path string) error {
|
||||
if _, err := cmd.RunDefaultWithStdoutBashCf("gunzip %s", path); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Reference in a new issue