mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00

This adds a helper script to start the XPUB/XSUB proxy using the XPUB_PORT and XSUB_PORT environment variables. The crux here is that WebSocket clients go through the central XPUB/XSUB proxy. This is different from Broker where WebSocket clients attach via local hubs to the endpoint which doesn't require additional configuration.
24 lines
1.1 KiB
Text
24 lines
1.1 KiB
Text
# Helper script expecting XPUB_PORT / XSUB_PORT environments
|
|
# and redefining the ZeroMQ options accordingly and starting
|
|
# the zmq_proxy_thread.
|
|
#
|
|
# This is primarily useful for testing of WebSocket functionality
|
|
# while the ZeroMQ backend is enabled.
|
|
@load base/utils/numbers
|
|
|
|
@load frameworks/cluster/backend/zeromq
|
|
|
|
const local_addr_str = "127.0.0.1" &redef;
|
|
redef Cluster::Backend::ZeroMQ::listen_xpub_endpoint = fmt("tcp://%s:%s", local_addr_str, port_to_count(to_port(getenv("XPUB_PORT"))));
|
|
redef Cluster::Backend::ZeroMQ::listen_xsub_endpoint = fmt("tcp://%s:%s", local_addr_str, port_to_count(to_port(getenv("XSUB_PORT"))));
|
|
redef Cluster::Backend::ZeroMQ::connect_xpub_endpoint = fmt("tcp://%s:%s", local_addr_str, port_to_count(to_port(getenv("XSUB_PORT"))));
|
|
redef Cluster::Backend::ZeroMQ::connect_xsub_endpoint = fmt("tcp://%s:%s", local_addr_str, port_to_count(to_port(getenv("XPUB_PORT"))));
|
|
|
|
event zeek_init() &priority=100
|
|
{
|
|
if ( ! Cluster::Backend::ZeroMQ::spawn_zmq_proxy_thread() )
|
|
Reporter::fatal("Failed to spawn ZeroMQ proxy thread");
|
|
|
|
if ( ! Cluster::init() )
|
|
Reporter::fatal("Failed to initialize ZeroMQ backend");
|
|
}
|