mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
GH-1119: add base/protcols/conn/removal-hooks.zeek
This adds two new functions: `Conn::register_removal_hook()` and `Conn::unregister_removal_hook()` for registering a hook function to be called back during `connection_state_remove`. The benefit of using hook callback approach is better scalability: the overhead of unrelated protocols having to dispatch no-op `connection_state_remove` handlers is avoided.
This commit is contained in:
parent
49e2047da0
commit
05cf511f18
31 changed files with 659 additions and 386 deletions
|
@ -19,13 +19,7 @@ redef record connection += {
|
|||
redef dpd_match_only_beginning = F;
|
||||
redef dpd_late_match_stop = T;
|
||||
|
||||
event protocol_late_match(c: connection, atype: Analyzer::Tag)
|
||||
{
|
||||
local analyzer = Analyzer::name(atype);
|
||||
add c$speculative_service[analyzer];
|
||||
}
|
||||
|
||||
event connection_state_remove(c: connection)
|
||||
hook finalize_speculative_service(c: connection)
|
||||
{
|
||||
local sp_service = "";
|
||||
for ( s in c$speculative_service )
|
||||
|
@ -34,3 +28,10 @@ event connection_state_remove(c: connection)
|
|||
if ( sp_service != "" )
|
||||
c$conn$speculative_service = to_lower(sp_service);
|
||||
}
|
||||
|
||||
event protocol_late_match(c: connection, atype: Analyzer::Tag)
|
||||
{
|
||||
local analyzer = Analyzer::name(atype);
|
||||
add c$speculative_service[analyzer];
|
||||
Conn::register_removal_hook(c, finalize_speculative_service);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue