apiary/honeypot/ssh/store/store.go

50 lines
1.1 KiB
Go

package store
import (
"errors"
"git.t-juice.club/torjus/apiary/models"
)
var ErrStoreUnhealthy = errors.New("store is unhealthy")
type LoginStats string
const (
LoginStatsUndefined LoginStats = ""
LoginStatsPasswords LoginStats = "password"
LoginStatsCountry LoginStats = "country"
LoginStatsIP LoginStats = "ip"
LoginStatsUsername LoginStats = "username"
LoginStatsTotals LoginStats = "total"
)
type AttemptQueryType string
const (
AttemptQueryTypeUsername AttemptQueryType = "username"
AttemptQueryTypePassword AttemptQueryType = "password"
AttemptQueryTypeIP AttemptQueryType = "ip"
)
type StatsResult struct {
Name string `json:"name"`
Count int `json:"count"`
}
type AttemptQuery struct {
QueryType AttemptQueryType
Query string
}
type LoginAttemptStore interface {
AddAttempt(l *models.LoginAttempt) error
All() (<-chan models.LoginAttempt, error)
Stats(statType LoginStats, limit int) ([]StatsResult, error)
Query(query AttemptQuery) ([]models.LoginAttempt, error)
HealthCheker
}
type HealthCheker interface {
IsHealthy() error
}