- 新增 pkg/wshub/manager.go 统一 WebSocket 连接管理器 (WSManager) - 6 个 WebSocket handler 全部迁移: WebShell/kubectl/PodExec/Audit/Metrics/Pipeline - 心跳机制: ping(30s) + pong handler + read deadline(60s) 自动检测死连接 - 连接注册表: 元数据(类型/用户/远程地址/连接时间/最后活跃) - 每用户连接限制 MaxConnsPerUser=15 防资源耗尽 - 监控端点: GET /api/v1/ws/stats + GET /api/v1/ws/connections - 优雅关闭: CloseAll() 发送 CloseGoingAway 帧并关闭所有连接 - 消除 3 个重复 websocket.Upgrader 变量统一为 WSManager 内部 upgrader - 6/6 A3 测试通过, 17/17 回归测试通过
7 lines
188 B
Go
7 lines
188 B
Go
package wshub
|
|
|
|
import "errors"
|
|
|
|
// ErrTooManyConnections is returned when a user exceeds MaxConnsPerUser.
|
|
var ErrTooManyConnections = errors.New("too many websocket connections for user")
|