2022-05-09 23:16:59 +02:00
|
|
|
package tracer
|
|
|
|
|
|
|
|
import (
|
|
|
|
log "github.com/sirupsen/logrus"
|
2022-05-10 22:50:29 +02:00
|
|
|
"net/http"
|
2022-05-09 23:16:59 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Tracer struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func Init() *Tracer {
|
|
|
|
return &Tracer{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (tracer *Tracer) TraceEvent(event Event) {
|
|
|
|
log.WithFields(log.Fields{
|
|
|
|
"status": event.Status.String(),
|
|
|
|
"event": event,
|
|
|
|
}).Info("New Event")
|
|
|
|
}
|
|
|
|
|
|
|
|
type Event struct {
|
2022-05-10 22:50:29 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-05-10 22:50:29 +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]
|
|
|
|
}
|