MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / loadSSHData

Function loadSSHData

agent/app/service/ssh.go:1226–1267  ·  view source on GitHub ↗
(
	ctx *gin.Context,
	filePath, status, filter string,
	startTime, endTime time.Time,
	showCountFrom, showCountTo, currentYear int,
	nyc *time.Location,
)

Source from the content-addressed store, hash-verified

1224}
1225
1226func loadSSHData(
1227 ctx *gin.Context,
1228 filePath, status, filter string,
1229 startTime, endTime time.Time,
1230 showCountFrom, showCountTo, currentYear int,
1231 nyc *time.Location,
1232) ([]dto.SSHHistory, int, int) {
1233 var (
1234 datas []dto.SSHHistory
1235 successCount int
1236 failedCount int
1237 )
1238 getLoc, err := geo.NewGeo()
1239 if err != nil {
1240 return datas, 0, 0
1241 }
1242 lines, err := loadSSHLogLines(filePath)
1243 if err != nil {
1244 return datas, 0, 0
1245 }
1246 items := collectSSHLogItems(lines, filter, status)
1247 for i := len(items) - 1; i >= 0; i-- {
1248 itemData := items[i].History
1249 if !matchSSHLogStatus(status, itemData.Status) || !checkIsStandard(itemData) {
1250 continue
1251 }
1252 itemData.Date = loadDate(currentYear, itemData.DateStr, nyc)
1253 if !isSSHLogWithinTimeRange(itemData.Date, startTime, endTime) {
1254 continue
1255 }
1256 if successCount+failedCount >= showCountFrom && (showCountTo == -1 || successCount+failedCount < showCountTo) {
1257 itemData.Area, _ = geo.GetIPLocation(getLoc, itemData.Address, common.GetLang(ctx))
1258 datas = append(datas, itemData)
1259 }
1260 if itemData.Status == constant.StatusSuccess {
1261 successCount++
1262 } else {
1263 failedCount++
1264 }
1265 }
1266 return datas, successCount, failedCount
1267}
1268
1269func isSSHLogWithinTimeRange(itemTime, startTime, endTime time.Time) bool {
1270 if startTime.IsZero() || endTime.IsZero() {

Callers 1

LoadLogMethod · 0.85

Calls 6

loadSSHLogLinesFunction · 0.85
collectSSHLogItemsFunction · 0.85
matchSSHLogStatusFunction · 0.85
checkIsStandardFunction · 0.85
loadDateFunction · 0.85
isSSHLogWithinTimeRangeFunction · 0.85

Tested by

no test coverage detected