1. Overview
Interactive network-activity page that aggregates remote IP connections, asynchronously resolves geolocation, displays a Shumate world map with animated markers and connection arcs, shows hover details, maintains a tabular view, and persists recent network history.
File role: Implementation. The file contains 1279 lines and belongs to the pages/NetworkPage.cpp path.
The companion file is pages/NetworkPage.hpp.
2. Component Responsibilities
- Implement the behavior declared by the corresponding header or entry-point contract.
- Receive connection events and aggregate them by remote IP
- Queue geolocation lookups through GeoResolver
- Update table rows and summary statistics
- Create or refresh animated map markers
- Center the map automatically unless the user recently moved the viewport
- Display country, city, ISP, host, application, and hit count in hover cards
- Persist and reload retained network events
- Expire entries older than the retention window
3. Dependencies and Integration
Project-level dependencies:
NetworkPage.hpp../util/AppResolver.hppglibmm/i18n.hgtk/gtk.hunistd.h
System and library dependencies:
algorithmcmathcstdioctimefilesystemfstreamsstream
4. Declared Types
AnimatedMarkerData
Declares a struct.
HoverPayload
Declares a struct.
LL
Declares a struct.
Arc
Declares a struct.
5. Constants and Fixed Configuration
The file declares or uses the following fixed values:
constexpr double kDefaultLat = 20.0;
constexpr double kDefaultLon = 10.0;
constexpr double kDefaultZoom = 2.2;
constexpr double kFocusedZoom = 3.0;
constexpr double kMaxZoom = 20.0;
constexpr double kMinZoom = 1.0;
constexpr auto kHoverHideDelay = std::chrono::milliseconds(140);
constexpr auto kUserViewportHold = std::chrono::seconds(8);
6. Signals and Event Integration
The file exposes or connects the following signal-related elements:
m_clearBtn.signal_clicked().connect([this]() { clear(); });g_signal_connect(g_signal_connect_data(
GTK-facing callbacks must execute on the main UI context. Components with worker threads use dispatchers or idle callbacks to cross the thread boundary.
7. Functions and Methods
The file exposes or implements 30 detected function or method signatures.
1. NetworkPage
NetworkPage::NetworkPage() : Gtk::Box(Gtk::Orientation::VERTICAL, 0)
Implements the network page operation declared by this component.
2. ~NetworkPage
NetworkPage::~NetworkPage()
Releases resources owned by the object and stops any active background integration.
3. buildUI
void NetworkPage::buildUI()
Builds and configures the ui user-interface or internal structure.
4. createHoverCard
GtkWidget* NetworkPage::createHoverCard()
Creates hover card and initializes the resulting object or file.
5. showHoverCard
void NetworkPage::showHoverCard(const std::string& country_code, const std::string& country_name, const std::string& city, const std::string& ip, const std::string& host, const std::string& app_name, const std::string& isp, uint32_t hits)
Displays hover card.
6. hideHoverCard
void NetworkPage::hideHoverCard()
Hides hover card.
7. buildMapWidget
void NetworkPage::buildMapWidget()
Builds and configures the map widget user-interface or internal structure.
8. createMarkerWidget
GtkWidget* NetworkPage::createMarkerWidget(const Pin& pin)
Creates marker widget and initializes the resulting object or file.
9. maybeRecenterMap
void NetworkPage::maybeRecenterMap(const std::vector<Pin>& pins)
Implements the maybe recenter map operation declared by this component.
10. rebuildMapMarkers
void NetworkPage::rebuildMapMarkers()
Implements the rebuild map markers operation declared by this component.
11. noteUserViewportInteraction
void NetworkPage::noteUserViewportInteraction()
Records user viewport interaction in the current in-memory model.
12. shouldHoldUserViewport
bool NetworkPage::shouldHoldUserViewport() const
Implements the should hold user viewport operation declared by this component.
13. noteConnection
void NetworkPage::noteConnection(const ConnectionInfo& info)
Records connection in the current in-memory model.
14. onGeoResolved
void NetworkPage::onGeoResolved()
Handles the geo resolved callback or user event.
15. updateRow
void NetworkPage::updateRow(const Pin& pin)
Updates row using the latest runtime data.
16. updateSummary
void NetworkPage::updateSummary()
Updates summary using the latest runtime data.
17. requestSelfLocation
void NetworkPage::requestSelfLocation()
Implements the request self location operation declared by this component.
18. createSelfMarkerWidget
GtkWidget* NetworkPage::createSelfMarkerWidget()
Creates self marker widget and initializes the resulting object or file.
19. drawConnectionArcs
void NetworkPage::drawConnectionArcs(cairo_t* cr, int width, int height)
Implements the draw connection arcs operation declared by this component.
20. triggerFxRedraw
void NetworkPage::triggerFxRedraw()
Implements the trigger fx redraw operation declared by this component.
21. clear
void NetworkPage::clear()
Clears clear and resets related state.
22. logPath
std::string NetworkPage::logPath()
Implements the log path operation declared by this component.
23. saveLog
void NetworkPage::saveLog() const
Serializes or persists log.
24. loadLog
void NetworkPage::loadLog()
Loads log from its persistent or runtime source.
25. animated_marker_tick
static gboolean animated_marker_tick(GtkWidget* widget, GdkFrameClock*, gpointer)
Implements the animated marker tick operation declared by this component.
26. animated_marker_data_destroy
static void animated_marker_data_destroy(gpointer data)
Implements the animated marker data destroy operation declared by this component.
27. hover_payload_destroy
static void hover_payload_destroy(gpointer data, GClosure*)
Implements the hover payload destroy operation declared by this component.
28. animated_marker_draw
static void animated_marker_draw(GtkDrawingArea*, cairo_t* cr, int width, int height, gpointer user_data)
Implements the animated marker draw operation declared by this component.
29. create_animated_dot_widget
static GtkWidget* create_animated_dot_widget(int hits)
Creates animated dot widget and initializes the resulting object or file.
30. map_fx_draw
static void map_fx_draw(GtkDrawingArea*, cairo_t* cr, int width, int height, gpointer user_data)
Implements the map fx draw operation declared by this component.
8. Filesystem, IPC, Network, and Command Interfaces
Relevant literal paths, endpoints, or resource locations include:
/tmp/bastionguard-sc-network-
9. Runtime Flow
- Receive connection events and aggregate them by remote IP
- Queue geolocation lookups through GeoResolver
- Update table rows and summary statistics
- Create or refresh animated map markers
- Center the map automatically unless the user recently moved the viewport
- Display country, city, ISP, host, application, and hit count in hover cards
- Persist and reload retained network events
- Expire entries older than the retention window
10. Runtime and Security Considerations
- Relies on GeoResolver private-address filtering before external lookup.
- Uses bounded history retention.
- Marshals asynchronous geolocation results back to the UI.
- Treats location results as enrichment rather than connection authorization data.
- JSON input and output must be treated as external data and validated before applying decisions.
- Temporary paths are used; file naming, permissions, and replacement behavior form part of the privilege boundary.
11. Error Handling and Operational Notes
- Boolean-returning operations use
falseto report recoverable failure.
12. Source Integrity
Relative source path: pages/NetworkPage.cpp
SHA-256:
8cd8b6f4dcffcb842380af49262cec5dd1fe2a60c5d4cc2ef50300c147a5d5d7
13. Licensing
The source header identifies this component as distributed under the GNU General Public License version 3. BastionGuard branding and trademarks remain subject to the notices stated in the source file.
