mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +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
|
@ -1,3 +1,5 @@
|
|||
@load base/protocols/conn/removal-hooks
|
||||
|
||||
module RFB;
|
||||
|
||||
export {
|
||||
|
@ -41,6 +43,9 @@ export {
|
|||
};
|
||||
|
||||
global log_rfb: event(rec: Info);
|
||||
|
||||
## RFB finalization hook. Remaining RFB info may get logged when it's called.
|
||||
global finalize_rfb: Conn::RemovalHook;
|
||||
}
|
||||
|
||||
function friendly_auth_name(auth: count): string
|
||||
|
@ -103,6 +108,7 @@ function set_session(c: connection)
|
|||
info$id = c$id;
|
||||
|
||||
c$rfb = info;
|
||||
Conn::register_removal_hook(c, finalize_rfb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +157,7 @@ event rfb_share_flag(c: connection, flag: bool) &priority=5
|
|||
c$rfb$share_flag = flag;
|
||||
}
|
||||
|
||||
event connection_state_remove(c: connection) &priority=-5
|
||||
hook finalize_rfb(c: connection)
|
||||
{
|
||||
if ( c?$rfb )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue