mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00

While we support initializing records via coercion from an expression list, e.g., local x: X = [$x1=1, $x2=2]; this can sometimes obscure the code to readers, e.g., when assigning to value declared and typed elsewhere. The language runtime has a similar overhead since instead of just constructing a known type it needs to check at runtime that the coercion from the expression list is valid; this can be slower than just writing the readible code in the first place, see #4559. With this patch we use explicit construction, e.g., local x = X($x1=1, $x2=2);
49 lines
1.1 KiB
Text
49 lines
1.1 KiB
Text
@load ./dcc-send
|
|
@load base/utils/conn-ids
|
|
@load base/frameworks/files
|
|
|
|
module IRC;
|
|
|
|
export {
|
|
redef record Info += {
|
|
## File unique ID.
|
|
fuid: string &log &optional;
|
|
};
|
|
|
|
## Default file handle provider for IRC.
|
|
global get_file_handle: function(c: connection, is_orig: bool): string;
|
|
|
|
redef record fa_file += {
|
|
irc: IRC::Info &optional;
|
|
};
|
|
}
|
|
|
|
function get_file_handle(c: connection, is_orig: bool): string
|
|
{
|
|
return cat(Analyzer::ANALYZER_IRC_DATA, c$start_time, c$id, is_orig);
|
|
}
|
|
|
|
event zeek_init() &priority=5
|
|
{
|
|
Files::register_protocol(Analyzer::ANALYZER_IRC_DATA,
|
|
Files::ProtoRegistration($get_file_handle = IRC::get_file_handle));
|
|
}
|
|
|
|
event file_over_new_connection(f: fa_file, c: connection, is_orig: bool) &priority=5
|
|
{
|
|
if ( [c$id$resp_h, c$id$resp_p] !in dcc_expected_transfers )
|
|
return;
|
|
|
|
local irc = dcc_expected_transfers[c$id$resp_h, c$id$resp_p];
|
|
irc$fuid = f$id;
|
|
if ( irc?$dcc_file_name )
|
|
f$info$filename = irc$dcc_file_name;
|
|
|
|
f$irc = irc;
|
|
}
|
|
|
|
event file_sniff(f: fa_file, meta: fa_metadata) &priority=5
|
|
{
|
|
if ( f?$irc && meta?$mime_type )
|
|
f$irc$dcc_mime_type = meta$mime_type;
|
|
}
|