Add support for making the supervisor listen for requests

The supervisor now starts listening on the configured Broker default address and
port when the new boolean SupervisorControl::enable_listen is T. Listening
remains disabled by default. Listening allows nodes to communicate with the
supervisor via the events laid out in control.zeek, to conduct further node
management.
This commit is contained in:
Christian Kreibich 2021-07-06 18:01:05 -07:00
parent 36051dc9a1
commit efaa9ec3be
2 changed files with 12 additions and 1 deletions

View file

@ -4,6 +4,7 @@
##! That is, it may change in various incompatible ways without warning or
##! deprecation until the stable 4.0.0 release.
@load base/frameworks/broker
@load ./api
module SupervisorControl;
@ -15,6 +16,10 @@ export {
## for their topic names.
const topic_prefix = "zeek/supervisor" &redef;
## When enabled, the Supervisor will listen on the configured Broker
## :zeek:see:`Broker::default_listen_address`.
const enable_listen = F &redef;
## Send a request to a remote Supervisor process to create a node.
##
## reqid: an arbitrary string that will be directly echoed in the response

View file

@ -3,7 +3,6 @@
@load ./api
@load ./control
@load base/frameworks/broker
function Supervisor::status(node: string): Supervisor::Status
{
@ -42,6 +41,13 @@ function Supervisor::node(): Supervisor::NodeConfig
event zeek_init() &priority=10
{
if ( Supervisor::is_supervisor() && SupervisorControl::enable_listen )
{
Broker::listen(Broker::default_listen_address,
Broker::default_port,
Broker::default_listen_retry);
}
Broker::subscribe(SupervisorControl::topic_prefix);
}