websocket

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: Apache-2.0, BSD-3-Clause, MIT, + 2 more Imports: 11 Imported by: 0

Documentation

Overview

Package websocket 实现WebSocket服务器功能

Index

Constants

View Source
const (
	// WSMsgTypeLog 日志消息类型
	WSMsgTypeLog = "log"
	// WSMsgTypeScanResult 扫描结果消息类型
	WSMsgTypeScanResult = "result"
	// WSMsgTypeProcessInfo 进度消息类型
	WSMsgTypeProcessInfo = "processing"
	// WSMsgTypeReportInfo 报告消息类型
	WSMsgTypeReportInfo = "report"
	// WSMsgTypeScanRet 扫描状态返回
	WSMsgTypeScanRet = "scan_ret"
)
View Source
const (
	WSLogLevelInfo  = "info"
	WSLogLevelDebug = "debug"
	WSLogLevelError = "error"
)

Variables

This section is empty.

Functions

func RunWebServer

func RunWebServer(options *options.Options)

Types

type Log

type Log struct {
	Message string `json:"message"`
	Level   string `json:"level"`
}

Log 日志信息结构

type ReportInfo

type ReportInfo struct {
	SecScore   int `json:"sec_score"`
	HighRisk   int `json:"high_risk"`
	MiddleRisk int `json:"middle_risk"`
	LowRisk    int `json:"low_risk"`
}

ReportInfo 报告信息结构

type Response

type Response struct {
	Status  int         `json:"status"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

Response 基础响应结构

type ScanRequest

type ScanRequest struct {
	ScanType string            `json:"scan_type"`
	Target   []string          `json:"target,omitempty"`
	Headers  map[string]string `json:"headers,omitempty"`
	Lang     string            `json:"lang,omitempty"`
}

ScanRequest 扫描请求结构

type ScanRet

type ScanRet struct {
	Status int    `json:"status"`
	Msg    string `json:"msg"`
}

ScanRet 扫描状态返回

type WSMessage

type WSMessage struct {
	Type    string      `json:"type"`
	Content interface{} `json:"content"`
}

WSMessage WebSocket消息结构

type WSServer

type WSServer struct {
	// contains filtered or unexported fields
}

WSServer WebSocket服务器结构

func NewWSServer

func NewWSServer(options *options.Options) *WSServer

NewWSServer 创建新的WebSocket服务器

func (*WSServer) HandleWS

func (s *WSServer) HandleWS(w http.ResponseWriter, r *http.Request)

HandleWS 处理WebSocket连接

func (*WSServer) SendMessage

func (s *WSServer) SendMessage(conn *websocket.Conn, msgType string, content interface{}) error

SendMessage 发送消息给指定客户端

Jump to

Keyboard shortcuts

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