Documentation
¶
Overview ¶
Package websocket provides WebSocket handling for the crawler.
Index ¶
- type EndpointInfo
- type Handler
- func (h *Handler) Clear()
- func (h *Handler) Connect(ctx context.Context, wsURL, sourceURL string) error
- func (h *Handler) Count() int
- func (h *Handler) Disable()
- func (h *Handler) Enable()
- func (h *Handler) GetEndpoints() []WebSocketEndpoint
- func (h *Handler) HasEndpoint(wsURL string) bool
- func (h *Handler) SendMessage(ctx context.Context, wsURL string, msgType int, data []byte) error
- func (h *Handler) SetCookies(cookies []*http.Cookie)
- func (h *Handler) SetHeaders(headers map[string]string)
- func (h *Handler) SetMaxMessages(max int)
- func (h *Handler) SetMessageTimeout(timeout time.Duration)
- type Message
- type PatternAnalysis
- type RecordedMessage
- type RecordedSession
- type Recorder
- func (r *Recorder) AnalyzePatterns(url string) *PatternAnalysis
- func (r *Recorder) Clear()
- func (r *Recorder) EndSession(url string)
- func (r *Recorder) ExportJSON() ([]byte, error)
- func (r *Recorder) GetActiveSessions() []*RecordedSession
- func (r *Recorder) GetAllSessions() []*RecordedSession
- func (r *Recorder) GetSession(url string) *RecordedSession
- func (r *Recorder) RecordMessage(url string, direction, msgType string, data []byte)
- func (r *Recorder) StartSession(url string)
- func (r *Recorder) Stats() RecorderStats
- type RecorderStats
- type WebSocketEndpoint
- type WebSocketMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EndpointInfo ¶
type EndpointInfo struct {
URL string
DiscoveredFrom string
Protocols []string
Messages []Message
Connected bool
ConnectTime time.Time
Error error
}
EndpointInfo contains information about a WebSocket endpoint.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler manages WebSocket connections and message recording.
func (*Handler) GetEndpoints ¶
func (h *Handler) GetEndpoints() []WebSocketEndpoint
GetEndpoints returns all discovered WebSocket endpoints.
func (*Handler) HasEndpoint ¶
HasEndpoint checks if an endpoint has been discovered.
func (*Handler) SendMessage ¶
SendMessage sends a message and records the response.
func (*Handler) SetCookies ¶
SetCookies sets cookies for WebSocket connections.
func (*Handler) SetHeaders ¶
SetHeaders sets custom headers for WebSocket connections.
func (*Handler) SetMaxMessages ¶
SetMaxMessages sets the maximum number of messages to record per endpoint.
func (*Handler) SetMessageTimeout ¶
SetMessageTimeout sets the timeout for receiving messages.
type Message ¶
type Message struct {
Direction string // "sent" or "received"
Type int // websocket.TextMessage, websocket.BinaryMessage, etc.
Data []byte
Timestamp time.Time
}
Message represents a WebSocket message.
type PatternAnalysis ¶
type PatternAnalysis struct {
URL string `json:"url"`
MessageCount int `json:"message_count"`
SentCount int `json:"sent_count"`
ReceivedCount int `json:"received_count"`
MessageTypes map[string]int `json:"message_types"`
AverageSize int `json:"average_size"`
MaxSize int `json:"max_size"`
MinSize int `json:"min_size"`
HasJSON bool `json:"has_json"`
}
PatternAnalysis contains analysis of message patterns.
type RecordedMessage ¶
type RecordedMessage struct {
Timestamp time.Time `json:"timestamp"`
Direction string `json:"direction"` // "sent" or "received"
Type string `json:"type"` // "text", "binary", "ping", "pong"
Data []byte `json:"data"`
Size int `json:"size"`
}
RecordedMessage represents a recorded WebSocket message.
type RecordedSession ¶
type RecordedSession struct {
URL string `json:"url"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time,omitempty"`
Messages []RecordedMessage `json:"messages"`
TotalSent int `json:"total_sent"`
TotalReceived int `json:"total_received"`
Active bool `json:"active"`
}
RecordedSession contains recorded messages for a WebSocket session.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder records WebSocket messages for analysis.
func NewRecorder ¶
NewRecorder creates a new WebSocket recorder.
func (*Recorder) AnalyzePatterns ¶
func (r *Recorder) AnalyzePatterns(url string) *PatternAnalysis
AnalyzePatterns analyzes message patterns in sessions.
func (*Recorder) EndSession ¶
EndSession ends a WebSocket session.
func (*Recorder) ExportJSON ¶
ExportJSON exports all sessions as JSON.
func (*Recorder) GetActiveSessions ¶
func (r *Recorder) GetActiveSessions() []*RecordedSession
GetActiveSessions returns all active sessions.
func (*Recorder) GetAllSessions ¶
func (r *Recorder) GetAllSessions() []*RecordedSession
GetAllSessions returns all recorded sessions.
func (*Recorder) GetSession ¶
func (r *Recorder) GetSession(url string) *RecordedSession
GetSession returns a recorded session.
func (*Recorder) RecordMessage ¶
RecordMessage records a WebSocket message.
func (*Recorder) StartSession ¶
StartSession starts recording a new WebSocket session.
func (*Recorder) Stats ¶
func (r *Recorder) Stats() RecorderStats
Stats returns recorder statistics.
type RecorderStats ¶
type RecorderStats struct {
TotalSessions int `json:"total_sessions"`
ActiveSessions int `json:"active_sessions"`
TotalMessages int `json:"total_messages"`
}
RecorderStats contains recorder statistics.
type WebSocketEndpoint ¶
type WebSocketEndpoint struct {
URL string
DiscoveredFrom string
SampleMessages []WebSocketMsg
Protocols []string
Timestamp time.Time
}
WebSocketEndpoint represents a discovered WebSocket endpoint.