mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Expand Broker APIs to allow tracking directionality of peering establishment
This provides ways to figure out for a given peer, or a given address/port pair, whether the local node originally established the peering.
This commit is contained in:
parent
d59f6014b8
commit
b430d5235c
9 changed files with 123 additions and 1 deletions
|
@ -233,6 +233,7 @@ public:
|
|||
LoggerQueuePtr loggerQueue;
|
||||
SeverityLevel logSeverity = SeverityLevel::critical;
|
||||
SeverityLevel stderrSeverity = SeverityLevel::critical;
|
||||
std::unordered_set<broker::network_info> outbound_peerings;
|
||||
};
|
||||
|
||||
const broker::endpoint_info Manager::NoPeer{{}, {}};
|
||||
|
@ -582,6 +583,7 @@ void Manager::Peer(const string& addr, uint16_t port, double retry) {
|
|||
|
||||
auto secs = broker::timeout::seconds(static_cast<uint64_t>(retry));
|
||||
bstate->endpoint.peer_nosync(addr, port, secs);
|
||||
bstate->outbound_peerings.emplace(broker::network_info(addr, port));
|
||||
|
||||
auto counts_as_iosource = get_option("Broker::peer_counts_as_iosource")->AsBool();
|
||||
|
||||
|
@ -613,6 +615,15 @@ void Manager::Unpeer(const string& addr, uint16_t port) {
|
|||
|
||||
FlushLogBuffers();
|
||||
bstate->endpoint.unpeer_nosync(addr, port);
|
||||
bstate->outbound_peerings.erase(broker::network_info(addr, port));
|
||||
}
|
||||
|
||||
bool Manager::IsOutboundPeering(const string& addr, uint16_t port) const {
|
||||
return bstate->outbound_peerings.find(broker::network_info(addr, port)) != bstate->outbound_peerings.end();
|
||||
}
|
||||
|
||||
bool Manager::IsOutboundPeering(const broker::network_info& ni) const {
|
||||
return bstate->outbound_peerings.find(ni) != bstate->outbound_peerings.end();
|
||||
}
|
||||
|
||||
std::vector<broker::peer_info> Manager::Peers() const {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue