websocket

package
v0.0.0-...-401cff9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WsError                         int64 = -1
	WsNotification                  int64 = 1
	WsAgentStatusRequest            int64 = 2
	WsAgentStatusResponse           int64 = 3
	WsAgentDisconnectedNotification int64 = 4
	WsAgentConnectedNotification    int64 = 5
	WsRuleDetectionAlert            int64 = 6
)

Message Types

Variables

This section is empty.

Functions

This section is empty.

Types

type APIWebSocketConnection

type APIWebSocketConnection struct {
	State bool //The state of the websocket connection (true for active, false for inactive)
	// contains filtered or unexported fields
}

func NewAPIWebSocketConnection

func NewAPIWebSocketConnection(logger logging.ILogger, apiWsURL string, configuration config.Configuration) *APIWebSocketConnection

func (*APIWebSocketConnection) Connect

func (awsc *APIWebSocketConnection) Connect() (bool, error)

Connects to the API websocket URL for the agent

func (*APIWebSocketConnection) SendNotification

func (awsc *APIWebSocketConnection) SendNotification(message string) error

Function to send a notification to the API

func (*APIWebSocketConnection) SendRuleDetectionAlert

func (awsc *APIWebSocketConnection) SendRuleDetectionAlert(alert RuleDetectionAlert) error

Function to send an alert when a high or critical payload is detected

func (*APIWebSocketConnection) Start

func (awsc *APIWebSocketConnection) Start()

type AgentStatusRequest

type AgentStatusRequest struct {
	AgentId string `json:"agentId"`
}

func (*AgentStatusRequest) FromJSON

func (asr *AgentStatusRequest) FromJSON(r io.Reader) error

type AgentStatusResponse

type AgentStatusResponse struct {
	AgentId string `json:"agentId"`
	Status  string `json:"status"`
}

func (*AgentStatusResponse) FromJSON

func (asr *AgentStatusResponse) FromJSON(r io.Reader) error

type Notification

type Notification struct {
	AgentId string `json:"agentId"`
	Message string `json:"message"`
}

Notification Websocket message

func (*Notification) FromJSON

func (not *Notification) FromJSON(r io.Reader) error

type RuleDetectionAlert

type RuleDetectionAlert struct {
	AgentId         string `json:"agentId"`
	RuleId          string `json:"ruleId"`
	RuleName        string `json:"ruleName"`
	RuleDescription string `json:"ruleDescription"`
	Classification  string `json:"classification"`
	Severity        string `json:"severity"`
	Timestamp       int64  `json:"timestamp"`
}

func (*RuleDetectionAlert) FromJSON

func (rda *RuleDetectionAlert) FromJSON(r io.Reader) error

type WebSocketMessage

type WebSocketMessage struct {
	Type int64       `json:"type"` //The type of the message
	Data interface{} `json:"data"` //The data of the message as interface (can be any struct)
}

WebSocket message format

func (*WebSocketMessage) FromJSON

func (wsm *WebSocketMessage) FromJSON(r io.Reader) error

func (*WebSocketMessage) ToJSON

func (wsm *WebSocketMessage) ToJSON(w io.Writer) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL