GH-1991: Add option to limit the number of tunnel_changed events

This commit is contained in:
Tim Wojtulewicz 2022-06-15 13:22:29 -07:00
parent 4deacefa4c
commit a9fd4a60e0
5 changed files with 21 additions and 1 deletions

View file

@ -96,8 +96,13 @@ void Connection::CheckEncapsulation(const std::shared_ptr<EncapsulationStack>& a
{
if ( *encapsulation != *arg_encap )
{
if ( tunnel_changed )
if ( tunnel_changed &&
(zeek::detail::tunnel_max_changes_per_connection == 0 ||
tunnel_changes < zeek::detail::tunnel_max_changes_per_connection) )
{
tunnel_changes++;
EnqueueEvent(tunnel_changed, nullptr, GetVal(), arg_encap->ToVal());
}
encapsulation = std::make_shared<EncapsulationStack>(*arg_encap);
}