Add WebSocket support for exchanging events with external clients.

This exposes Broker's new WebSocket support in Zeek. To enable it,
call `Broker::listen_websocket()`. Zeek will then start listening on
port 9997 for incoming WebSocket connections.

See the Broker documentation for a description of the message format
expected over these WebSocket connections.
This commit is contained in:
Robin Sommer 2022-05-19 07:45:02 +02:00
parent 4b0e1063ed
commit d99f041ac5
No known key found for this signature in database
GPG key ID: 6BEDA4DA6B8B23E3
25 changed files with 248 additions and 26 deletions

View file

@ -527,12 +527,21 @@ void Manager::ClearStores()
handle->store.clear();
}
uint16_t Manager::Listen(const string& addr, uint16_t port)
uint16_t Manager::Listen(const string& addr, uint16_t port, BrokerProtocol type)
{
if ( bstate->endpoint.is_shutdown() )
return 0;
bound_port = bstate->endpoint.listen(addr, port);
switch ( type )
{
case BrokerProtocol::Native:
bound_port = bstate->endpoint.listen(addr, port);
break;
case BrokerProtocol::WebSocket:
bound_port = bstate->endpoint.web_socket_listen(addr, port);
break;
}
if ( bound_port == 0 )
Error("Failed to listen on %s:%" PRIu16, addr.empty() ? "INADDR_ANY" : addr.c_str(), port);