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

Function parseSSHLogMessage

agent/app/service/ssh.go:1459–1525  ·  view source on GitHub ↗
(message string)

Source from the content-addressed store, hash-verified

1457}
1458
1459func parseSSHLogMessage(message string) (dto.SSHHistory, bool) {
1460 if matches := re.GetRegex(re.SSHAcceptedPattern).FindStringSubmatch(message); len(matches) == 5 {
1461 return dto.SSHHistory{
1462 AuthMode: matches[1],
1463 User: matches[2],
1464 Address: matches[3],
1465 Port: matches[4],
1466 Status: constant.StatusSuccess,
1467 }, true
1468 }
1469 if matches := re.GetRegex(re.SSHFailedPattern).FindStringSubmatch(message); len(matches) == 6 {
1470 return dto.SSHHistory{
1471 AuthMode: matches[1],
1472 User: matches[3],
1473 Address: matches[4],
1474 Port: matches[5],
1475 Status: constant.StatusFailed,
1476 }, true
1477 }
1478 if matches := re.GetRegex(re.SSHInvalidUserPattern).FindStringSubmatch(message); len(matches) == 4 {
1479 return dto.SSHHistory{
1480 User: matches[1],
1481 Address: matches[2],
1482 Port: matches[3],
1483 Status: constant.StatusFailed,
1484 }, true
1485 }
1486 if matches := re.GetRegex(re.SSHClosedPattern).FindStringSubmatch(message); len(matches) == 4 {
1487 return dto.SSHHistory{
1488 User: matches[1],
1489 Address: matches[2],
1490 Port: matches[3],
1491 Status: constant.StatusFailed,
1492 }, true
1493 }
1494 if matches := re.GetRegex(re.SSHDisconnectedPattern).FindStringSubmatch(message); len(matches) == 4 {
1495 return dto.SSHHistory{
1496 User: matches[1],
1497 Address: matches[2],
1498 Port: matches[3],
1499 Status: constant.StatusFailed,
1500 }, true
1501 }
1502 if matches := re.GetRegex(re.SSHDisconnectPattern).FindStringSubmatch(message); len(matches) == 3 {
1503 return dto.SSHHistory{
1504 Address: matches[1],
1505 Port: matches[2],
1506 Status: constant.StatusFailed,
1507 }, true
1508 }
1509 if matches := re.GetRegex(re.SSHMaxAuthPattern).FindStringSubmatch(message); len(matches) == 4 {
1510 return dto.SSHHistory{
1511 User: matches[1],
1512 Address: matches[2],
1513 Port: matches[3],
1514 Status: constant.StatusFailed,
1515 }, true
1516 }

Callers 1

parseSSHLogLineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected