diff --git a/scripts/base/frameworks/cluster/main.zeek b/scripts/base/frameworks/cluster/main.zeek index d610969cff..0427d6adcd 100644 --- a/scripts/base/frameworks/cluster/main.zeek +++ b/scripts/base/frameworks/cluster/main.zeek @@ -281,6 +281,15 @@ export { ## a given cluster node. global nodeid_topic: function(id: string): string; + ## Retrieve the cluster-level naming of a node based on its node ID, + ## a backend-specific identifier. + ## + ## id: the node ID of a peer. + ## + ## Returns: the :zeek:see:`Cluster::NamedNode` for the requested node, if + ## known, otherwise a "null" instance with an empty name field. + global nodeid_to_node: function(id: string): NamedNode; + ## Initialize the cluster backend. ## ## Cluster backends usually invoke this from a :zeek:see:`zeek_init` handler. @@ -394,6 +403,17 @@ function nodeid_topic(id: string): string return nodeid_topic_prefix + id + "/"; } +function nodeid_to_node(id: string): NamedNode + { + for ( name, n in nodes ) + { + if ( n?$id && n$id == id ) + return NamedNode($name=name, $node=n); + } + + return NamedNode($name="", $node=[$node_type=NONE, $ip=0.0.0.0]); + } + event Cluster::hello(name: string, id: string) &priority=10 { if ( name !in nodes )