From cf8671d07885984156809eabb7d5bc9fa26b1e86 Mon Sep 17 00:00:00 2001 From: Seth Hall Date: Mon, 12 Oct 2020 10:46:28 -0400 Subject: [PATCH 1/3] Make defining a port number for hosts in a cluster that only connect outbound optional --- scripts/base/frameworks/cluster/main.zeek | 4 ++-- .../base/frameworks/cluster/setup-connections.zeek | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/base/frameworks/cluster/main.zeek b/scripts/base/frameworks/cluster/main.zeek index 02c63562b6..f0ece62741 100644 --- a/scripts/base/frameworks/cluster/main.zeek +++ b/scripts/base/frameworks/cluster/main.zeek @@ -1,4 +1,4 @@ -##! A framework for establishing and controlling a cluster of Zeek instances. +#hh#! A framework for establishing and controlling a cluster of Zeek instances. ##! In order to use the cluster framework, a script named ##! ``cluster-layout.zeek`` must exist somewhere in Zeek's script search path ##! which has a cluster definition of the :zeek:id:`Cluster::nodes` variable. @@ -162,7 +162,7 @@ export { ## can specify a particular :rfc:`4007` ``zone_id``. zone_id: string &default=""; ## The port that this node will listen on for peer connections. - p: port; + p: port &optional; ## Identifier for the interface a worker is sniffing. interface: string &optional; ## Name of the manager node this node uses. For workers and proxies. diff --git a/scripts/base/frameworks/cluster/setup-connections.zeek b/scripts/base/frameworks/cluster/setup-connections.zeek index 2abd57b142..7e470037a6 100644 --- a/scripts/base/frameworks/cluster/setup-connections.zeek +++ b/scripts/base/frameworks/cluster/setup-connections.zeek @@ -89,11 +89,15 @@ event zeek_init() &priority=-10 Broker::subscribe(nodeid_topic(Broker::node_id())); Broker::subscribe(node_topic(node)); - Broker::listen(Broker::default_listen_address, - self$p, - Broker::default_listen_retry); + if ( self?$p ) + { + Broker::listen(Broker::default_listen_address, + self$p, + Broker::default_listen_retry); + + Cluster::log(fmt("listening on %s:%s", Broker::default_listen_address, self$p)); + } - Cluster::log(fmt("listening on %s:%s", Broker::default_listen_address, self$p)); switch ( self$node_type ) { case MANAGER: From e78386d6e5921e1beaa0ec6b92ff82c378a8910d Mon Sep 17 00:00:00 2001 From: Seth Hall Date: Tue, 13 Oct 2020 16:46:26 -0400 Subject: [PATCH 2/3] Update scripts/base/frameworks/cluster/main.zeek Co-authored-by: Jon Siwek --- scripts/base/frameworks/cluster/main.zeek | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/base/frameworks/cluster/main.zeek b/scripts/base/frameworks/cluster/main.zeek index f0ece62741..85e1f3a4f9 100644 --- a/scripts/base/frameworks/cluster/main.zeek +++ b/scripts/base/frameworks/cluster/main.zeek @@ -1,4 +1,4 @@ -#hh#! A framework for establishing and controlling a cluster of Zeek instances. +##! A framework for establishing and controlling a cluster of Zeek instances. ##! In order to use the cluster framework, a script named ##! ``cluster-layout.zeek`` must exist somewhere in Zeek's script search path ##! which has a cluster definition of the :zeek:id:`Cluster::nodes` variable. From cd330c801d461d35be9fb3acde6582bac9f733be Mon Sep 17 00:00:00 2001 From: Seth Hall Date: Tue, 13 Oct 2020 16:48:15 -0400 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Jon Siwek --- scripts/base/frameworks/cluster/main.zeek | 3 ++- scripts/base/frameworks/cluster/setup-connections.zeek | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/base/frameworks/cluster/main.zeek b/scripts/base/frameworks/cluster/main.zeek index 85e1f3a4f9..110f4ad3af 100644 --- a/scripts/base/frameworks/cluster/main.zeek +++ b/scripts/base/frameworks/cluster/main.zeek @@ -162,7 +162,8 @@ export { ## can specify a particular :rfc:`4007` ``zone_id``. zone_id: string &default=""; ## The port that this node will listen on for peer connections. - p: port &optional; + ## A value of ``0/unknown`` means the node is not pre-configured to listen. + p: port &default=0/unknown; ## Identifier for the interface a worker is sniffing. interface: string &optional; ## Name of the manager node this node uses. For workers and proxies. diff --git a/scripts/base/frameworks/cluster/setup-connections.zeek b/scripts/base/frameworks/cluster/setup-connections.zeek index 7e470037a6..55ab8a460a 100644 --- a/scripts/base/frameworks/cluster/setup-connections.zeek +++ b/scripts/base/frameworks/cluster/setup-connections.zeek @@ -89,7 +89,7 @@ event zeek_init() &priority=-10 Broker::subscribe(nodeid_topic(Broker::node_id())); Broker::subscribe(node_topic(node)); - if ( self?$p ) + if ( self$p != 0/unknown ) { Broker::listen(Broker::default_listen_address, self$p,