mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Remove "relay" family of Broker functions
Namely these are now removed: - Broker::relay - Broker::publish_and_relay - Cluster::relay_rr - Cluster::relay_hrw The idea being that Broker may eventually implement the necessary routing (plus load balancing) functionality. For now, code that used these should "manually" handle and re-publish events as needed.
This commit is contained in:
parent
e055f9b36b
commit
1a75ef2abd
17 changed files with 96 additions and 766 deletions
|
@ -24,32 +24,41 @@ export {
|
|||
## Sniffed mime type of the file.
|
||||
dcc_mime_type: string &log &optional;
|
||||
};
|
||||
|
||||
## The broker topic name to which expected DCC transfer updates are
|
||||
## relayed.
|
||||
const dcc_transfer_update_topic = "bro/irc/dcc_transfer_update" &redef;
|
||||
}
|
||||
|
||||
global dcc_expected_transfers: table[addr, port] of Info &read_expire=5mins;
|
||||
|
||||
function dcc_relay_topic(): string
|
||||
{
|
||||
local rval = Cluster::rr_topic(Cluster::proxy_pool, "dcc_transfer_rr_key");
|
||||
|
||||
if ( rval == "" )
|
||||
# No proxy is alive, so relay via manager instead.
|
||||
return Cluster::manager_topic;
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
event dcc_transfer_add(host: addr, p: port, info: Info)
|
||||
{
|
||||
@if ( Cluster::local_node_type() == Cluster::PROXY ||
|
||||
Cluster::local_node_type() == Cluster::MANAGER )
|
||||
Broker::publish(Cluster::worker_topic, dcc_transfer_add, host, p, info);
|
||||
@else
|
||||
dcc_expected_transfers[host, p] = info;
|
||||
Analyzer::schedule_analyzer(0.0.0.0, host, p,
|
||||
Analyzer::ANALYZER_IRC_DATA, 5 min);
|
||||
@endif
|
||||
}
|
||||
|
||||
event dcc_transfer_remove(host: addr, p: port)
|
||||
{
|
||||
@if ( Cluster::local_node_type() == Cluster::PROXY ||
|
||||
Cluster::local_node_type() == Cluster::MANAGER )
|
||||
Broker::publish(Cluster::worker_topic, dcc_transfer_remove, host, p);
|
||||
@else
|
||||
delete dcc_expected_transfers[host, p];
|
||||
}
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local lnt = Cluster::local_node_type();
|
||||
|
||||
if ( lnt == Cluster::WORKER )
|
||||
Broker::subscribe(dcc_transfer_update_topic);
|
||||
@endif
|
||||
}
|
||||
|
||||
function log_dcc(f: fa_file)
|
||||
|
@ -76,9 +85,11 @@ function log_dcc(f: fa_file)
|
|||
delete irc$dcc_mime_type;
|
||||
|
||||
delete dcc_expected_transfers[cid$resp_h, cid$resp_p];
|
||||
Cluster::relay_rr(Cluster::proxy_pool, dcc_transfer_update_topic,
|
||||
dcc_transfer_update_topic, dcc_transfer_remove,
|
||||
cid$resp_h, cid$resp_p);
|
||||
|
||||
@if ( Cluster::is_enabled() )
|
||||
Broker::publish(dcc_relay_topic(), dcc_transfer_remove,
|
||||
cid$resp_h, cid$resp_p);
|
||||
@endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +113,10 @@ event irc_dcc_message(c: connection, is_orig: bool,
|
|||
local p = count_to_port(dest_port, tcp);
|
||||
Analyzer::schedule_analyzer(0.0.0.0, address, p, Analyzer::ANALYZER_IRC_DATA, 5 min);
|
||||
dcc_expected_transfers[address, p] = c$irc;
|
||||
Cluster::relay_rr(Cluster::proxy_pool, dcc_transfer_update_topic,
|
||||
dcc_transfer_update_topic, dcc_transfer_add,
|
||||
address, p, c$irc);
|
||||
|
||||
@if ( Cluster::is_enabled() )
|
||||
Broker::publish(dcc_relay_topic(), dcc_transfer_add, address, p, c$irc);
|
||||
@endif
|
||||
}
|
||||
|
||||
event scheduled_analyzer_applied(c: connection, a: Analyzer::Tag) &priority=10
|
||||
|
@ -119,8 +131,10 @@ event connection_state_remove(c: connection) &priority=-5
|
|||
if ( [c$id$resp_h, c$id$resp_p] in dcc_expected_transfers )
|
||||
{
|
||||
delete dcc_expected_transfers[c$id$resp_h, c$id$resp_p];
|
||||
Cluster::relay_rr(Cluster::proxy_pool, dcc_transfer_update_topic,
|
||||
dcc_transfer_update_topic, dcc_transfer_remove,
|
||||
c$id$resp_h, c$id$resp_p);
|
||||
|
||||
@if ( Cluster::is_enabled() )
|
||||
Broker::publish(dcc_relay_topic(), dcc_transfer_remove,
|
||||
c$id$resp_h, c$id$resp_p);
|
||||
@endif
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue