#include <SocketSnapshot.hpp>
Classes | |
| struct | SnapshotCache |
Public Member Functions | |
| std::vector< bsc::model::Connection > | list_connections () const |
| std::optional< bsc::model::Connection > | find_connection (const bsc::model::Connection &needle) const |
| bool | enrich_connection (bsc::model::Connection &conn) const |
| void | invalidate_cache () |
| void | discard_pending_events () const |
| bool | start_ebpf (const std::string &obj_path="/usr/lib/bastionguard-sc/bsc_ebpf.o") |
| void | stop_ebpf () |
Private Member Functions | |
| std::vector< bsc::model::Connection > | collect_connections () const |
| bool | cache_valid (std::chrono::steady_clock::time_point now) const |
Private Attributes | |
| std::mutex | cache_mutex_ |
| SnapshotCache | cache_ |
| bsc::ebpf::EBPFMon | ebpf_mon_ |
Definition at line 13 of file SocketSnapshot.hpp.
|
nodiscardprivate |
Definition at line 338 of file SocketSnapshot.cpp.
References cache_, bsc::net::SocketSnapshot::SnapshotCache::connections, and bsc::net::SocketSnapshot::SnapshotCache::updated_at.
Referenced by list_connections().
|
nodiscardprivate |
Definition at line 342 of file SocketSnapshot.cpp.
References bsc::ebpf::EBPFMon::drain(), and ebpf_mon_.
Referenced by list_connections().
| void bsc::net::SocketSnapshot::discard_pending_events | ( | ) | const |
Definition at line 406 of file SocketSnapshot.cpp.
References cache_, cache_mutex_, bsc::net::SocketSnapshot::SnapshotCache::connections, bsc::ebpf::EBPFMon::drain(), ebpf_mon_, and bsc::net::SocketSnapshot::SnapshotCache::updated_at.
| bool bsc::net::SocketSnapshot::enrich_connection | ( | bsc::model::Connection & | conn | ) | const |
Definition at line 423 of file SocketSnapshot.cpp.
References bsc::ebpf::EBPFMon::drain(), bsc::model::Connection::dst_ip, bsc::model::Connection::dst_port, ebpf_mon_, find_connection(), bsc::model::Connection::process_comm, bsc::model::Connection::process_id, bsc::model::Connection::process_path, bsc::model::Connection::protocol, bsc::net::sockdiag_lookup_tcp(), bsc::net::sockdiag_lookup_udp(), bsc::model::Connection::src_ip, bsc::model::Connection::src_port, and bsc::model::Connection::user_id.
Referenced by bsc::service::DaemonService::run().
|
nodiscard |
Definition at line 413 of file SocketSnapshot.cpp.
References bsc::ebpf::EBPFMon::drain(), ebpf_mon_, and list_connections().
Referenced by enrich_connection().
| void bsc::net::SocketSnapshot::invalidate_cache | ( | ) |
Definition at line 400 of file SocketSnapshot.cpp.
References cache_, cache_mutex_, bsc::net::SocketSnapshot::SnapshotCache::connections, and bsc::net::SocketSnapshot::SnapshotCache::updated_at.
Referenced by bsc::service::DaemonService::run().
|
nodiscard |
Definition at line 384 of file SocketSnapshot.cpp.
References cache_, cache_mutex_, cache_valid(), collect_connections(), bsc::net::SocketSnapshot::SnapshotCache::connections, and bsc::net::SocketSnapshot::SnapshotCache::updated_at.
Referenced by find_connection().
| bool bsc::net::SocketSnapshot::start_ebpf | ( | const std::string & | obj_path = "/usr/lib/bastionguard-sc/bsc_ebpf.o" | ) |
Definition at line 376 of file SocketSnapshot.cpp.
References ebpf_mon_, and bsc::ebpf::EBPFMon::start().
Referenced by bsc::service::DaemonService::run().
| void bsc::net::SocketSnapshot::stop_ebpf | ( | ) |
Definition at line 380 of file SocketSnapshot.cpp.
References ebpf_mon_, and bsc::ebpf::EBPFMon::stop().
|
mutableprivate |
Definition at line 46 of file SocketSnapshot.hpp.
Referenced by cache_valid(), discard_pending_events(), invalidate_cache(), and list_connections().
|
mutableprivate |
Definition at line 45 of file SocketSnapshot.hpp.
Referenced by discard_pending_events(), invalidate_cache(), and list_connections().
|
mutableprivate |
Definition at line 50 of file SocketSnapshot.hpp.
Referenced by collect_connections(), discard_pending_events(), enrich_connection(), find_connection(), start_ebpf(), and stop_ebpf().