ConnectionsPage

1. Overview

Little-Snitch-style GTK connection monitor with an application summary view, per-application connection details, verdict editing, grouped connection counts, estimated traffic, a live activity sparkline, and retained JSON-line history.

File role: Implementation. The file contains 1075 lines and belongs to the pages/ConnectionsPage.cpp path.

The companion file is pages/ConnectionsPage.hpp.


2. Component Responsibilities

  • Implement the behavior declared by the corresponding header or entry-point contract.
  • Build application and detailed tree views
  • Aggregate new connections by application
  • Group repeated destination tuples
  • Maintain a bounded per-application detail ring
  • Switch between application overview and detail views
  • Allow verdict changes through a combo renderer
  • Send selected replies to UIServer
  • Persist, load, prune, and clear connection history
  • Update the live sparkline from recent event buckets

3. Dependencies and Integration

Project-level dependencies:

  • ConnectionsPage.hpp
  • ../util/AppResolver.hpp
  • glibmm/i18n.h
  • glibmm/datetime.h
  • gtkmm/cellrenderercombo.h
  • gtkmm/cellrendererpixbuf.h
  • gtkmm/cellrenderertext.h
  • giomm/appinfo.h
  • giomm/desktopappinfo.h
  • giomm/themedicon.h
  • unistd.h

System and library dependencies:

  • iostream
  • fstream
  • sstream
  • filesystem
  • cstdlib
  • cstdio
  • ctime
  • cctype
  • algorithm

4. Signals and Event Integration

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

  • m_sparkTick = Glib::signal_timeout().connect(
  • // Disconnetti il timer prima della distruzione: Glib::signal_timeout()
  • m_backBtn.signal_clicked().connect(
  • m_clearBtn.signal_clicked().connect(
  • m_appTreeView.signal_row_activated().connect(
  • cell->signal_edited().connect(

GTK-facing callbacks must execute on the main UI context. Components with worker threads use dispatchers or idle callbacks to cross the thread boundary.


5. Functions and Methods

The file exposes or implements 36 detected function or method signatures.

1. ConnectionsPage

ConnectionsPage::ConnectionsPage(UIServer& uiServer) : Gtk::Box(Gtk::Orientation::VERTICAL, 0) , m_uiServer(uiServer)

Implements the connections page operation declared by this component.

2. ~ConnectionsPage

ConnectionsPage::~ConnectionsPage()

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

3. buildVerdictModel

void ConnectionsPage::buildVerdictModel()

Builds and configures the verdict model user-interface or internal structure.

4. buildToolbar

void ConnectionsPage::buildToolbar()

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

5. buildAppTreeView

void ConnectionsPage::buildAppTreeView()

Builds and configures the app tree view user-interface or internal structure.

6. buildDetailTreeView

void ConnectionsPage::buildDetailTreeView()

Builds and configures the detail tree view user-interface or internal structure.

7. buildSparkline

void ConnectionsPage::buildSparkline()

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

8. showAppsView

void ConnectionsPage::showAppsView()

Displays apps view.

9. showDetailView

void ConnectionsPage::showDetailView(const std::string& app)

Displays detail view.

10. onBackClicked

void ConnectionsPage::onBackClicked()

Handles the back clicked callback or user event.

11. onAppActivated

void ConnectionsPage::onAppActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* )

Handles the app activated callback or user event.

12. buildDesktopIndex

void ConnectionsPage::buildDesktopIndex()

Builds and configures the desktop index user-interface or internal structure.

13. resolveIconName

std::string ConnectionsPage::resolveIconName(const std::string& app_display)

Resolves icon name into normalized metadata or runtime data.

14. groupKeyFor

std::string ConnectionsPage::groupKeyFor(const std::string& app, const std::string& protocol, const std::string& host, const std::string& ip, uint32_t port)

Implements the group key for operation declared by this component.

15. formatBytes

std::string ConnectionsPage::formatBytes(uint64_t n)

Formats bytes for display or persistence.

16. formatEpochTime

std::string ConnectionsPage::formatEpochTime(int64_t epoch)

Formats epoch time for display or persistence.

17. onNewConnection

void ConnectionsPage::onNewConnection(const ConnectionInfo& info, bool pending)

Handles the new connection callback or user event.

18. updateAppAggregate

void ConnectionsPage::updateAppAggregate(const std::string& app_display)

Updates app aggregate using the latest runtime data.

19. pushDetailEvent

void ConnectionsPage::pushDetailEvent(const std::string& app_display, const DetailEvent& ev)

Implements the push detail event operation declared by this component.

20. populateDetailFromRing

void ConnectionsPage::populateDetailFromRing(const std::string& app_display)

Implements the populate detail from ring operation declared by this component.

21. addOrUpdateDetailRow

void ConnectionsPage::addOrUpdateDetailRow(const ConnectionInfo& info, const std::string& app_display, const std::string& argsStr, bool pending)

Adds or update detail row to the relevant model or index.

22. onSparkTick

bool ConnectionsPage::onSparkTick()

Handles the spark tick callback or user event.

23. onSparkDraw

void ConnectionsPage::onSparkDraw(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height)

Handles the spark draw callback or user event.

24. setLastVerdict

void ConnectionsPage::setLastVerdict(const std::string& verdict)

Updates last verdict and synchronizes dependent state.

25. onVerdictEdited

void ConnectionsPage::onVerdictEdited(const Glib::ustring& pathStr, const Glib::ustring& newText)

Handles the verdict edited callback or user event.

26. parseReplyAction

ReplyAction ConnectionsPage::parseReplyAction(const Glib::ustring& text) const

Parses reply action into a structured representation.

27. onClear

void ConnectionsPage::onClear()

Handles the clear callback or user event.

28. currentTime

std::string ConnectionsPage::currentTime()

Implements the current time operation declared by this component.

29. logPath

std::string ConnectionsPage::logPath()

Implements the log path operation declared by this component.

30. jsonEscapeStr

std::string ConnectionsPage::jsonEscapeStr(const std::string& s)

Implements the json escape str operation declared by this component.

31. jsonFieldStr

std::string ConnectionsPage::jsonFieldStr(const std::string& json, const std::string& key)

Implements the json field str operation declared by this component.

32. jsonFieldUint

uint32_t ConnectionsPage::jsonFieldUint(const std::string& json, const std::string& key)

Implements the json field uint operation declared by this component.

33. jsonFieldBool

bool ConnectionsPage::jsonFieldBool(const std::string& json, const std::string& key)

Implements the json field bool operation declared by this component.

34. saveLog

void ConnectionsPage::saveLog() const

Serializes or persists log.

35. loadLog

void ConnectionsPage::loadLog()

Loads log from its persistent or runtime source.

36. clearLog

void ConnectionsPage::clearLog()

Clears log and resets related state.


6. Filesystem, IPC, Network, and Command Interfaces

Relevant literal paths, endpoints, or resource locations include:

  • /tmp/bastionguard-sc-connections-

7. Runtime Flow

  1. Build application and detailed tree views
  2. Aggregate new connections by application
  3. Group repeated destination tuples
  4. Maintain a bounded per-application detail ring
  5. Switch between application overview and detail views
  6. Allow verdict changes through a combo renderer
  7. Send selected replies to UIServer
  8. Persist, load, prune, and clear connection history
  9. Update the live sparkline from recent event buckets

8. Runtime and Security Considerations

  • Limits in-memory detail history.
  • Escapes JSON strings before persistence.
  • Uses typed ReplyAction values for edited verdicts.
  • Retains only events inside the configured seven-day window.
  • JSON input and output must be treated as external data and validated before applying decisions.
  • Socket lifecycle and framing errors are handled without performing GTK operations directly from the I/O thread.
  • Temporary paths are used; file naming, permissions, and replacement behavior form part of the privilege boundary.

9. Error Handling and Operational Notes

  • Diagnostic failures are written to standard error or the GLib logging channel.
  • Boolean-returning operations use false to report recoverable failure.

10. Source Integrity

Relative source path: pages/ConnectionsPage.cpp

SHA-256:

5f198470cb0f48112d72001aa368d445e50f4a63bbc9a860df7b0bb160aaa5a0

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