Documentation
¶
Overview ¶
detector.go
handlers.go
interface.go
logstream.go
types.go
Index ¶
- func AddHandler(detector *Detector, eventType EventType, handler Handler)
- func DefaultHandlers() map[EventType]Handler
- func GetPlayers(detector *Detector) map[string]string
- func HandleCustomDetection(w http.ResponseWriter, r *http.Request)
- func HandleDeleteCustomDetection(w http.ResponseWriter, r *http.Request)
- func InitCustomDetectionsManager(detector *Detector)
- func ProcessLog(detector *Detector, logMessage string)
- func RegisterDefaultHandlers(detector *Detector)
- func StreamLogs(detector *Detector)
- type BackupInfo
- type CustomDetection
- type CustomDetectionsManager
- type CustomPattern
- type Detector
- type Event
- type EventType
- type ExceptionInfo
- type Handler
- type PlayerInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHandler ¶
AddHandler is a convenient method to register a handler for an event type
func DefaultHandlers ¶
DefaultHandlers returns a map of event types to default handlers
func GetPlayers ¶
GetPlayers returns the currently connected players
func HandleCustomDetection ¶
func HandleCustomDetection(w http.ResponseWriter, r *http.Request)
HandleCustomDetections handles GET and POST requests for custom detections
func HandleDeleteCustomDetection ¶
func HandleDeleteCustomDetection(w http.ResponseWriter, r *http.Request)
HandleCustomDetectionsWithID handles DELETE requests for a specific custom detection
func InitCustomDetectionsManager ¶
func InitCustomDetectionsManager(detector *Detector)
InitCustomDetectionsManager initializes the custom detections manager
func ProcessLog ¶
ProcessLog is a convenient method to process a log message
func RegisterDefaultHandlers ¶
func RegisterDefaultHandlers(detector *Detector)
RegisterDefaultHandlers registers all default handlers with a detector
func StreamLogs ¶
func StreamLogs(detector *Detector)
StartLogStream starts processing logs directly from the internal SSE manager
Types ¶
type BackupInfo ¶
type BackupInfo struct {
BackupIndex string
}
BackupInfo contains information about a world save/backup
type CustomDetection ¶
type CustomDetection struct {
ID string `json:"id"`
Type string `json:"type"` // "regex" or "keyword"
Pattern string `json:"pattern"`
EventType string `json:"eventType"`
Message string `json:"message"`
}
CustomDetection defines a user-defined detection pattern
type CustomDetectionsManager ¶
type CustomDetectionsManager struct {
Detections []CustomDetection
// contains filtered or unexported fields
}
CustomDetectionsManager handles loading, saving and managing custom detections
func NewCustomDetectionsManager ¶
func NewCustomDetectionsManager(detector *Detector) *CustomDetectionsManager
NewCustomDetectionsManager creates a new manager and loads existing detections
func (*CustomDetectionsManager) AddDetection ¶
func (m *CustomDetectionsManager) AddDetection(detection CustomDetection) error
AddDetection adds a new custom detection
func (*CustomDetectionsManager) DeleteDetection ¶
func (m *CustomDetectionsManager) DeleteDetection(id string) error
DeleteDetection removes a custom detection by ID
func (*CustomDetectionsManager) GetDetections ¶
func (m *CustomDetectionsManager) GetDetections() []CustomDetection
GetDetections returns all custom detections
func (*CustomDetectionsManager) LoadDetections ¶
func (m *CustomDetectionsManager) LoadDetections() error
LoadDetections loads custom detections from file
type CustomPattern ¶
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
func (*Detector) GetConnectedPlayers ¶
GetConnectedPlayers returns a copy of the connected players map
func (*Detector) ProcessLogMessage ¶
ProcessLogMessage analyzes a log message and triggers appropriate handlers
func (*Detector) RegisterHandler ¶
RegisterHandler registers a handler for a specific event type
func (*Detector) SetCustomPatterns ¶
func (d *Detector) SetCustomPatterns(patterns []CustomPattern)
type Event ¶
type Event struct {
Type EventType
Message string
RawLog string
Timestamp string
PlayerInfo *PlayerInfo
BackupInfo *BackupInfo
ExceptionInfo *ExceptionInfo
}
Event represents a detected event from server logs
type EventType ¶
type EventType string
EventType defines the type of event detected
const ( EventServerReady EventType = "SERVER_READY" EventServerStarting EventType = "SERVER_STARTING" EventServerError EventType = "SERVER_ERROR" EventPlayerConnecting EventType = "PLAYER_CONNECTING" EventPlayerReady EventType = "PLAYER_READY" EventPlayerDisconnect EventType = "PLAYER_DISCONNECT" EventWorldSaved EventType = "WORLD_SAVED" EventException EventType = "EXCEPTION" EventSettingsChanged EventType = "SETTINGS_CHANGED" EventServerHosted EventType = "SERVER_HOSTED" EventNewGameStarted EventType = "NEW_GAME_STARTED" EventServerRunning EventType = "SERVER_RUNNING" EventCustomDetection EventType = "CUSTOM_DETECTION" )
type ExceptionInfo ¶
type ExceptionInfo struct {
StackTrace string
}
ExceptionInfo contains information about a server exception
type PlayerInfo ¶
PlayerInfo contains information about a player