1. Overview
Statistics implementation. Records verdicts, rule hit/miss counters, DNS responses and grouped metrics by protocol, address, host, port, UID and executable under a mutex.
The original source path is:
src/stats/Statistics.cpp
2. Role in the Daemon
This file participates in the privileged BastionGuard Secure Connection daemon. It uses the shared bsc models and follows the daemon-wide fallback strategy: optional high-fidelity backends are used when available, while portable polling or stub behavior preserves service startup.
3. Namespaces
bsc::stats
4. Dependencies and Included Interfaces
bsc/stats/Statistics.hppchronoctimeiomanipsstream
5. API and Functions
The file declares or implements the following callable entry points:
now_string()Statistics::Statistics(std::size_t max_events) : max_events_(max_events)Statistics::record(const bsc::model::Connection& conn, const std::string& action, const std::string& rule_name)Statistics::connections()Statistics::accepted()Statistics::dropped()Statistics::ignored()Statistics::rules()Statistics::note_dns_response()Statistics::dns_responses()Statistics::rule_hits()Statistics::rule_misses()Statistics::by_proto()Statistics::by_address()Statistics::by_host()Statistics::by_port()Statistics::by_uid()Statistics::by_executable()Statistics::events()
6. External Resources and Protocol Values
Relevant paths, endpoints, command names or policy values referenced by this file include:
bsc/stats/Statistics.hppallow
7. Implementation Considerations
- Shared state is protected by mutexes; callers should avoid holding external locks while invoking callbacks.
8. Source Metrics
| Metric | Value |
|---|---|
| File size | 3089 bytes |
| Lines | 56 |
| Detected API entries | 19 |
| Detected types | 0 |
