Documentation
¶
Index ¶
- func GetUpgrader() *gws.Upgrader
- type BaseHandler
- type FingerprintRecord
- type Handler
- type PendingRequest
- type RequestID
- type RequestManager
- type ResponseHandler
- type WsConn
- func (ws *WsConn) AgentVersion() semver.Version
- func (ws *WsConn) Close(msg []byte)
- func (ws *WsConn) GetFingerprint(ctx context.Context, token string, signer ssh.Signer, needSysInfo bool) (common.FingerprintResponse, error)
- func (ws *WsConn) IsConnected() bool
- func (ws *WsConn) Ping() error
- func (ws *WsConn) SendRequest(ctx context.Context, action common.WebSocketAction, data any) (*PendingRequest, error)
- func (ws *WsConn) TimeSinceLastMessage() time.Duration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetUpgrader ¶
GetUpgrader returns a singleton WebSocket upgrader instance.
Types ¶
type BaseHandler ¶ added in v0.14.0
type BaseHandler struct{}
BaseHandler provides a default implementation that can be embedded to make HandleLegacy optional
func (*BaseHandler) HandleLegacy ¶ added in v0.14.0
func (h *BaseHandler) HandleLegacy(rawData []byte) error
type FingerprintRecord ¶
type FingerprintRecord struct {
Id string `db:"id"`
SystemId string `db:"system"`
Fingerprint string `db:"fingerprint"`
Token string `db:"token"`
}
FingerprintRecord is fingerprints collection record data in the hub
type Handler ¶
type Handler struct {
gws.BuiltinEventHandler
}
Handler implements the WebSocket event handler for agent connections.
func (*Handler) OnClose ¶
OnClose handles WebSocket connection closures and triggers system down status after delay.
type PendingRequest ¶ added in v0.13.0
type PendingRequest struct {
ID RequestID
ResponseCh chan *gws.Message
Context context.Context
Cancel context.CancelFunc
CreatedAt time.Time
}
PendingRequest tracks an in-flight request
type RequestManager ¶ added in v0.13.0
RequestManager handles concurrent requests to an agent
func NewRequestManager ¶ added in v0.13.0
func NewRequestManager(conn *gws.Conn) *RequestManager
NewRequestManager creates a new request manager for a WebSocket connection
func (*RequestManager) Close ¶ added in v0.13.0
func (rm *RequestManager) Close()
Close shuts down the request manager
func (*RequestManager) SendRequest ¶ added in v0.13.0
func (rm *RequestManager) SendRequest(ctx context.Context, action common.WebSocketAction, data any) (*PendingRequest, error)
SendRequest sends a request and returns a channel for the response
type ResponseHandler ¶ added in v0.13.0
type ResponseHandler interface {
Handle(agentResponse common.AgentResponse) error
HandleLegacy(rawData []byte) error
}
ResponseHandler defines interface for handling agent responses. This is used by handleAgentRequest for legacy response handling.
type WsConn ¶
type WsConn struct {
DownChan chan struct{}
// contains filtered or unexported fields
}
WsConn represents a WebSocket connection to an agent.
func NewWsConnection ¶
NewWsConnection creates a new WebSocket connection wrapper with agent version.
func (*WsConn) AgentVersion ¶ added in v0.18.0
AgentVersion returns the connected agent's version (as reported during handshake).
func (*WsConn) GetFingerprint ¶
func (ws *WsConn) GetFingerprint(ctx context.Context, token string, signer ssh.Signer, needSysInfo bool) (common.FingerprintResponse, error)
GetFingerprint authenticates with the agent using SSH signature and returns the agent's fingerprint.
func (*WsConn) IsConnected ¶
IsConnected returns true if the WebSocket connection is active.
func (*WsConn) SendRequest ¶ added in v0.18.0
func (ws *WsConn) SendRequest(ctx context.Context, action common.WebSocketAction, data any) (*PendingRequest, error)
SendRequest sends a request to the agent and returns a pending request handle. This is used by the transport layer to send requests.
func (*WsConn) TimeSinceLastMessage ¶ added in v0.21.1
TimeSinceLastMessage returns how long it has been since the agent last sent a message.