NetworkPage.hpp

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: Header Interface. The file contains 183 lines and belongs to the pages/NetworkPage.hpp path.

The companion file is pages/NetworkPage.cpp.


2. Component Responsibilities

  • Declare the component API, owned state, callbacks, and data structures.
  • 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:

  • gtkmm.h
  • shumate/shumate.h
  • ../ipc/UIServer.hpp
  • ../util/GeoResolver.hpp

System and library dependencies:

  • chrono
  • mutex
  • string
  • unordered_map
  • vector

4. Declared Types

NetworkPage

Declares a class derived from or associated with public Gtk::Box.

Pin

Declares a struct.

Columns

Declares a struct derived from or associated with public Gtk::TreeModel::ColumnRecord.


5. Owned State and UI Members

User-interface members

  • Gtk::TreeModelColumn<Glib::ustring> col_country;
  • Gtk::TreeModelColumn<Glib::ustring> col_city;
  • Gtk::TreeModelColumn<Glib::ustring> col_ip;
  • Gtk::TreeModelColumn<Glib::ustring> col_host;
  • Gtk::TreeModelColumn<Glib::ustring> col_app;
  • Gtk::TreeModelColumn<Glib::ustring> col_isp;
  • Gtk::TreeModelColumn<uint32_t> col_hits;
  • Glib::RefPtr<Gtk::ListStore> m_store;
  • Gtk::TreeView m_treeView;
  • Gtk::ScrolledWindow m_scroll;
  • Gtk::Box m_mapHost{Gtk::Orientation::VERTICAL, 0};
  • Gtk::Label m_headerLabel;
  • Gtk::Label m_summaryLabel;
  • Gtk::Button m_clearBtn;
  • GtkWidget* m_simpleMap{nullptr};
  • ShumateViewport* m_viewport{nullptr};
  • ShumateMarkerLayer* m_markerLayer{nullptr};
  • GtkWidget* m_mapOverlay{nullptr};
  • GtkWidget* m_hoverCard{nullptr};
  • GtkWidget* m_hoverCardTitle{nullptr};
  • GtkWidget* m_hoverCardBody{nullptr};
  • GtkWidget* m_mapFxArea{nullptr};
  • std::unordered_map<std::string, Gtk::TreeModel::iterator> m_rows;

Threading, dispatch, and callback state

  • mutable std::mutex m_mu;
  • Glib::Dispatcher m_geoDispatcher;
  • std::mutex m_pendingMu;

Data and configuration state

  • std::string ip;
  • std::string host;
  • std::string app_name;
  • std::string country_code;
  • std::string country_name;
  • std::string city;
  • std::string isp;
  • double lat{0.0};
  • double lon{0.0};
  • uint32_t hits{0};
  • std::chrono::steady_clock::time_point last_seen;
  • int64_t last_seen_epoch{0};
  • bool geo_resolved{false};
  • Columns m_columns;
  • guint m_hoverHideSource{0};
  • std::chrono::steady_clock::time_point m_lastUserViewportInteraction{};
  • double m_selfLat{0.0};
  • double m_selfLon{0.0};
  • bool m_selfResolved{false};
  • guint m_pulseTimerId{0};
  • int m_pulseFrame{0};
  • static constexpr int64_t kRetentionSeconds = 7 * 24 * 3600;
  • std::unordered_map<std::string, Pin> m_pins;
  • std::vector<std::pair<std::string, bsc::ui_util::GeoEntry>> m_pendingGeo;

6. Signals and Event Integration

The file exposes or connects the following signal-related elements:

  • Glib::Dispatcher m_geoDispatcher;

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 24 detected function or method signatures.

1. NetworkPage

NetworkPage()

Implements the network page operation declared by this component.

2. ~NetworkPage

~NetworkPage() override

Releases resources owned by the object and stops any active background integration.

3. noteConnection

void noteConnection(const ConnectionInfo& info)

Records connection in the current in-memory model.

4. clear

void clear()

Clears clear and resets related state.

5. saveLog

void saveLog() const

Serializes or persists log.

6. loadLog

void loadLog()

Loads log from its persistent or runtime source.

7. logPath

static std::string logPath()

Implements the log path operation declared by this component.

8. drawConnectionArcs

void drawConnectionArcs(cairo_t* cr, int width, int height)

Implements the draw connection arcs operation declared by this component.

9. buildUI

void buildUI()

Builds and configures the ui user-interface or internal structure.

10. buildMapWidget

void buildMapWidget()

Builds and configures the map widget user-interface or internal structure.

11. rebuildMapMarkers

void rebuildMapMarkers()

Implements the rebuild map markers operation declared by this component.

12. createMarkerWidget

GtkWidget* createMarkerWidget(const Pin& pin)

Creates marker widget and initializes the resulting object or file.

13. createSelfMarkerWidget

GtkWidget* createSelfMarkerWidget()

Creates self marker widget and initializes the resulting object or file.

14. createHoverCard

GtkWidget* createHoverCard()

Creates hover card and initializes the resulting object or file.

15. showHoverCard

void 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.

16. hideHoverCard

void hideHoverCard()

Hides hover card.

17. maybeRecenterMap

void maybeRecenterMap(const std::vector<Pin>& pins)

Implements the maybe recenter map operation declared by this component.

18. onGeoResolved

void onGeoResolved()

Handles the geo resolved callback or user event.

19. updateSummary

void updateSummary()

Updates summary using the latest runtime data.

20. updateRow

void updateRow(const Pin& pin)

Updates row using the latest runtime data.

21. noteUserViewportInteraction

void noteUserViewportInteraction()

Records user viewport interaction in the current in-memory model.

22. shouldHoldUserViewport

bool shouldHoldUserViewport() const

Implements the should hold user viewport operation declared by this component.

23. requestSelfLocation

void requestSelfLocation()

Implements the request self location operation declared by this component.

24. triggerFxRedraw

void triggerFxRedraw()

Implements the trigger fx redraw operation declared by this component.


8. Runtime Flow

  1. Receive connection events and aggregate them by remote IP
  2. Queue geolocation lookups through GeoResolver
  3. Update table rows and summary statistics
  4. Create or refresh animated map markers
  5. Center the map automatically unless the user recently moved the viewport
  6. Display country, city, ISP, host, application, and hit count in hover cards
  7. Persist and reload retained network events
  8. Expire entries older than the retention window

9. Concurrency and Main-Loop Behavior

  • Protects shared state with a mutex.
  • Marshals results or callbacks onto the GLib/GTK main context.

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.

11. Error Handling and Operational Notes

  • Errors are propagated through the return type, callbacks, or the owning controller.

12. Source Integrity

Relative source path: pages/NetworkPage.hpp

SHA-256:

0c6993f5b25e8c8f5de271a49e85b335e3e45f5a7fcb60705c666842d9582e2f

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.