mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 14:08:20 +00:00
cluster/websocket: Propagate code and reason to websocket_client_lost()
This allows to get visibility into the reason why ixwebsocket or the client decided to disconnect. Closed #4440
This commit is contained in:
parent
aaddeb19ad
commit
a61aff010f
11 changed files with 131 additions and 6 deletions
|
@ -135,7 +135,8 @@ std::unique_ptr<WebSocketServer> StartServer(std::unique_ptr<WebSocketEventDispa
|
|||
dispatcher->QueueForProcessing(WebSocketMessage{id, msg->str});
|
||||
}
|
||||
else if ( msg->type == ix::WebSocketMessageType::Close ) {
|
||||
dispatcher->QueueForProcessing(WebSocketClose{id});
|
||||
auto& ci = msg->closeInfo;
|
||||
dispatcher->QueueForProcessing(WebSocketClose{id, ci.code, std::move(ci.reason)});
|
||||
}
|
||||
else if ( msg->type == ix::WebSocketMessageType::Error ) {
|
||||
dispatcher->QueueForProcessing(WebSocketClose{id});
|
||||
|
|
|
@ -356,7 +356,8 @@ void WebSocketEventDispatcher::Process(const WebSocketClose& close) {
|
|||
// should be the last event related to this WebSocket client.
|
||||
auto rec = zeek::cluster::detail::bif::make_endpoint_info(backend->NodeId(), wsc->getRemoteIp(),
|
||||
wsc->getRemotePort(), TRANSPORT_TCP);
|
||||
zeek::event_mgr.Enqueue(Cluster::websocket_client_lost, std::move(rec));
|
||||
zeek::event_mgr.Enqueue(Cluster::websocket_client_lost, std::move(rec), zeek::val_mgr->Count(close.code),
|
||||
zeek::make_intrusive<zeek::StringVal>(close.reason));
|
||||
}
|
||||
|
||||
clients.erase(it);
|
||||
|
|
|
@ -131,6 +131,8 @@ struct WebSocketOpen {
|
|||
// A WebSocket client disconnected.
|
||||
struct WebSocketClose {
|
||||
std::string id;
|
||||
uint16_t code;
|
||||
std::string reason;
|
||||
};
|
||||
|
||||
// A WebSocket client send a message.
|
||||
|
|
|
@ -10,4 +10,8 @@ event websocket_client_added%(endpoint: EndpointInfo, subscriptions: string_vec%
|
|||
## Generated when a WebSocket client was lost.
|
||||
##
|
||||
## endpoint: Various information about the WebSocket client.
|
||||
event websocket_client_lost%(endpoint: EndpointInfo%);
|
||||
## code: The code sent by the client in its CLOSE frame, or a code generated
|
||||
## internally if the server disconnected the client.
|
||||
## reason: The reason sent by the client in its CLOSE frame, or a reason generated
|
||||
## internally if the server disconnected the client.
|
||||
event websocket_client_lost%(endpoint: EndpointInfo, code: count, reason: string%);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue