split update_zones_regex into two functions

This commit is contained in:
Yacin Nadji 2022-08-08 11:40:18 +02:00
parent 4a04b563f5
commit dc1102e9dd

View file

@ -242,25 +242,28 @@ function update_local_nets_table(id: string, new_value: set[subnet]): set[subnet
return new_value;
}
function update_zones_regex(id: string, new_value: set[string]): set[string]
function update_local_zones_regex(id: string, new_value: set[string]): set[string]
{
# Double backslashes are needed due to string parsing.
if ( id == "Site::local_zones" )
local_dns_suffix_regex = set_to_regex(new_value, "(^\\.?|\\.)(~~)$");
else if ( id == "Site::neighbor_zones" )
local_dns_neighbor_suffix_regex = set_to_regex(new_value, "(^\\.?|\\.)(~~)$");
local_dns_suffix_regex = set_to_regex(new_value, "(^\\.?|\\.)(~~)$");
return new_value;
}
function update_neighbor_zones_regex(id: string, new_value: set[string]): set[string]
{
local_dns_neighbor_suffix_regex = set_to_regex(new_value, "(^\\.?|\\.)(~~)$");
return new_value;
}
event zeek_init() &priority=10
{
Option::set_change_handler("Site::local_nets", update_local_nets_table);
Option::set_change_handler("Site::local_zones", update_zones_regex);
Option::set_change_handler("Site::neighbor_zones", update_zones_regex);
Option::set_change_handler("Site::local_zones", update_local_zones_regex);
Option::set_change_handler("Site::neighbor_zones", update_neighbor_zones_regex);
# Use change handler to initialize local_nets mapping table and zones
# regexes.
update_local_nets_table("Site::local_nets", Site::local_nets);
update_zones_regex("Site::local_zones", Site::local_zones);
update_zones_regex("Site::neighbor_zones", Site::neighbor_zones);
update_local_zones_regex("Site::local_zones", Site::local_zones);
update_neighbor_zones_regex("Site::neighbor_zones", Site::neighbor_zones);
}