mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
cluster/websocket: Support configurable ping interval
Primarily for testing purposes and maybe the hard-coded 5 seconds is too aggressive for some deployments, so makes sense for it to be configurable.
This commit is contained in:
parent
2041306772
commit
aaddeb19ad
4 changed files with 19 additions and 5 deletions
|
@ -85,6 +85,9 @@ export {
|
||||||
## is incremented when the maximum queue size is reached.
|
## is incremented when the maximum queue size is reached.
|
||||||
const default_websocket_max_event_queue_size = 32 &redef;
|
const default_websocket_max_event_queue_size = 32 &redef;
|
||||||
|
|
||||||
|
## The default ping interval for WebSocket clients.
|
||||||
|
const default_websocket_ping_interval = 5 sec &redef;
|
||||||
|
|
||||||
## Setting a default dir will, for persistent backends that have not
|
## Setting a default dir will, for persistent backends that have not
|
||||||
## been given an explicit file path via :zeek:see:`Cluster::stores`,
|
## been given an explicit file path via :zeek:see:`Cluster::stores`,
|
||||||
## automatically create a path within this dir that is based on the name of
|
## automatically create a path within this dir that is based on the name of
|
||||||
|
@ -365,6 +368,10 @@ export {
|
||||||
listen_port: port;
|
listen_port: port;
|
||||||
## The maximum event queue size for this server.
|
## The maximum event queue size for this server.
|
||||||
max_event_queue_size: count &default=default_websocket_max_event_queue_size;
|
max_event_queue_size: count &default=default_websocket_max_event_queue_size;
|
||||||
|
## Ping interval to use. A WebSocket client not responding to
|
||||||
|
## the pings will be disconnected. Set to a negative value to
|
||||||
|
## disable pings. Subsecond intervals are currently not supported.
|
||||||
|
ping_interval: interval &default=default_websocket_ping_interval;
|
||||||
## The TLS options used for this WebSocket server. By default,
|
## The TLS options used for this WebSocket server. By default,
|
||||||
## TLS is disabled. See also :zeek:see:`Cluster::WebSocketTLSOptions`.
|
## TLS is disabled. See also :zeek:see:`Cluster::WebSocketTLSOptions`.
|
||||||
tls_options: WebSocketTLSOptions &default=WebSocketTLSOptions();
|
tls_options: WebSocketTLSOptions &default=WebSocketTLSOptions();
|
||||||
|
|
|
@ -198,6 +198,13 @@ function Cluster::__listen_websocket%(options: WebSocketServerOptions%): bool
|
||||||
};
|
};
|
||||||
|
|
||||||
server_options.max_event_queue_size = options_rec->GetField<zeek::CountVal>("max_event_queue_size")->Get();
|
server_options.max_event_queue_size = options_rec->GetField<zeek::CountVal>("max_event_queue_size")->Get();
|
||||||
|
|
||||||
|
double ping_interval = options_rec->GetField<zeek::IntervalVal>("ping_interval")->Get();
|
||||||
|
if ( ping_interval < 0.0 )
|
||||||
|
server_options.ping_interval_seconds = -1;
|
||||||
|
else
|
||||||
|
server_options.ping_interval_seconds = static_cast<int>(ping_interval);
|
||||||
|
|
||||||
server_options.tls_options = std::move(tls_options);
|
server_options.tls_options = std::move(tls_options);
|
||||||
|
|
||||||
auto result = zeek::cluster::manager->ListenWebSocket(server_options);
|
auto result = zeek::cluster::manager->ListenWebSocket(server_options);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
error in <...>/main.zeek, line 666: Already listening on 127.0.0.1:<port> (Cluster::__listen_websocket(ws_opts_x))
|
error in <...>/main.zeek, line 673: Already listening on 127.0.0.1:<port> (Cluster::__listen_websocket(ws_opts_x))
|
||||||
error in <...>/main.zeek, line 666: Already listening on 127.0.0.1:<port> (Cluster::__listen_websocket(ws_opts_wss_port))
|
error in <...>/main.zeek, line 673: Already listening on 127.0.0.1:<port> (Cluster::__listen_websocket(ws_opts_wss_port))
|
||||||
error in <...>/main.zeek, line 666: Already listening on 127.0.0.1:<port> (Cluster::__listen_websocket(ws_opts_qs))
|
error in <...>/main.zeek, line 673: Already listening on 127.0.0.1:<port> (Cluster::__listen_websocket(ws_opts_qs))
|
||||||
received termination signal
|
received termination signal
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
error in <...>/main.zeek, line 666: Invalid tls_options: No key_file field (Cluster::__listen_websocket(Cluster::options.0))
|
error in <...>/main.zeek, line 673: Invalid tls_options: No key_file field (Cluster::__listen_websocket(Cluster::options.0))
|
||||||
error in <...>/main.zeek, line 666: Invalid tls_options: No cert_file field (Cluster::__listen_websocket(Cluster::options.3))
|
error in <...>/main.zeek, line 673: Invalid tls_options: No cert_file field (Cluster::__listen_websocket(Cluster::options.3))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue