Files
beelzebub/tracer/tracer.go

62 lines
969 B
Go
Raw Normal View History

2022-05-09 23:16:59 +02:00
package tracer
import (
"net/http"
2022-05-09 23:16:59 +02:00
)
type Strategy func(event Event)
2022-05-09 23:16:59 +02:00
type Tracer struct {
strategy Strategy
2022-05-09 23:16:59 +02:00
}
func Init(strategy Strategy) *Tracer {
return &Tracer{
strategy: strategy,
}
2022-05-09 23:16:59 +02:00
}
func (tracer *Tracer) TraceEvent(event Event) {
tracer.strategy(event)
2022-05-09 23:16:59 +02:00
}
type Event struct {
RemoteAddr string
Protocol Protocol
Command string
Status Status
Msg string
ID string
Environ string
User string
Password string
Client string
Headers http.Header
Cookies []*http.Cookie
UserAgent string
HostHTTPRequest string
Body string
HTTPMethod string
RequestURI string
2022-05-09 23:16:59 +02:00
}
type Protocol int
const (
HTTP Protocol = iota
SSH
)
2022-05-09 23:16:59 +02:00
type Status int
const (
Start Status = iota
End
Stateless
Interaction
)
func (status Status) String() string {
return [...]string{"Start", "End", "Stateless", "Interaction"}[status]
}