Skip to content
markksantosPublic

Repository files navigation

🛡️ Sentry

Sentry icon

A native macOS menu bar app that monitors all outbound network connections in real time.

Swift SwiftUI macOS License CI

Features · Getting Started · Tech Stack


Features

  • Live Connection Scanner — Polls lsof every 3 seconds to discover all active TCP/UDP connections, grouped by app
  • App Icon Resolution — Automatically resolves process icons from running applications via PID lookup
  • GeoIP Country Lookup — Pure Swift MMDB parser maps remote IPs to country codes with flag emoji, using a bundled public-domain country database (no MaxMind account required)
  • Reverse DNS Resolution — Async hostname lookups with TTL-based LRU cache (1,000 entries, 5-minute TTL)
  • Connection History — SQLite-backed persistent history with full-text search, app/country filters, and CSV export
  • Tracker Detection — Suffix-matched blocklist of 100+ known tracker domains flags suspicious connections
  • Trust System — First-seen detection with per-connection and per-app trust levels stored in SQLite + UserDefaults
  • Native Notifications — Alerts on new, never-before-seen connections via UNUserNotificationCenter
  • Menu Bar Only — Lives entirely in the menu bar with no Dock icon; full SwiftUI popover with tabbed Live/History views
  • Zero Dependencies — No SPM packages; SQLite via system C API, GeoIP via pure Swift, DNS via POSIX getnameinfo

Getting Started

Prerequisites

  • macOS 14.0 (Sonoma) or later
  • Xcode 15+ or Swift 5.9+ toolchain
  • For rebuilding the icon only: librsvg (brew install librsvg)

Run from source

git clone https://github.com/markksantos/Sentry.git
cd Sentry
make run          # or: swift run SentryApp

Running via SwiftPM is the quickest way to try it, but two features are intentionally inert in that mode because they require a real app bundle: Launch at Login (SMAppService) and Notifications (UNUserNotificationCenter). Build the packaged app to exercise them.

Build the packaged app

make app          # release build -> dist/Sentry.app (ad-hoc signed) + dist/Sentry.zip
open dist/Sentry.app

The bundled country database (GeoLite2-Country.mmdb) is generated from the public-domain geo-whois-asn-country dataset, so GeoIP works out of the box with no MaxMind account. To swap in MaxMind's official GeoLite2-Country DB instead, drop it over Sources/SentryEngine/Resources/GeoLite2-Country.mmdb and rebuild — the pure-Swift reader handles standard MMDB files.

Permissions

Sentry uses lsof to read network connections. On first run, macOS may prompt for permissions:

  • Full Disk Access is not required — lsof reads connection state directly
  • Notifications — grant when prompted to receive alerts on new connections
  • Sentry ships un-sandboxed (see Resources/Sentry.entitlements): the App Sandbox cannot spawn lsof or inspect other processes' sockets, so the app is distributed directly rather than through the Mac App Store

Make targets

Command What it does
make build Debug SwiftPM build
make release Optimized release build
make test Run the 53-test engine/UI suite
make run Run from SwiftPM (no bundle)
make app Assemble dist/Sentry.app + zip
make icon Regenerate AppIcon.icns from the SVG
make clean Remove .build and dist

Tech Stack

Component Technology
Language Swift 5.9
UI Framework SwiftUI (MenuBarExtra, .window style)
Concurrency Swift Actors, AsyncStream, structured concurrency
Database SQLite3 C API (import SQLite3)
GeoIP Pure Swift MMDB binary parser
DNS POSIX getnameinfo (IPv4 + IPv6)
Notifications UserNotifications framework
Network Scanning lsof -i -n -P +c0 -F pcnPtTf (machine-readable output)
Architecture 3-module SPM: SentryApp / SentryEngine / SentryUI

Project Structure

Sentry/
├── Package.swift
├── Makefile
├── LICENSE
├── Resources/                       # app-bundle assets (not SwiftPM resources)
│   ├── AppIcon.svg / AppIcon.icns
│   ├── Info.plist
│   └── Sentry.entitlements
├── scripts/
│   ├── build-app.sh                 # release -> Sentry.app -> codesign -> zip
│   └── make-icon.sh                 # SVG -> AppIcon.icns
├── Sources/
│   ├── SentryApp/
│   │   ├── AppDelegate.swift
│   │   └── SentryApp.swift
│   ├── SentryEngine/
│   │   ├── DNS/ReverseDNSResolver.swift
│   │   ├── GeoIP/{GeoIPLookup,MMDBReader}.swift
│   │   ├── Models/ConnectionEntry.swift
│   │   ├── Resources/
│   │   │   ├── GeoLite2-Country.mmdb
│   │   │   ├── tracker-domains.txt
│   │   │   └── ResourceBundle.swift  # public bundle-URL accessor
│   │   ├── Scanner/{LSOFParser,NetworkScanner}.swift
│   │   ├── Storage/SQLiteStore.swift
│   │   └── Trust/{BlocklistMatcher,TrustManager}.swift
│   └── SentryUI/
│       ├── {AppDetail,AppList,ConnectionRow,History,MenuBar,Settings}View.swift
│       └── ViewModels/{Dashboard,History}ViewModel.swift
└── Tests/
    └── SentryEngineTests/
        ├── Fixtures/lsof-sample-output.txt
        ├── LSOFParserTests.swift
        ├── GeoIPTests.swift
        ├── BlocklistMatcherTests.swift
        ├── TrustManagerTests.swift
        ├── SQLiteStoreTests.swift
        └── ReverseDNSResolverTests.swift

Distribution

make app produces an ad-hoc-signed bundle, fine for personal use. To distribute to other Macs without Gatekeeper warnings:

# 1. Sign with your Developer ID instead of ad-hoc:
CODESIGN_IDENTITY="Developer ID Application: Your Name (TEAMID)" make app

# 2. Notarize the zip and staple:
xcrun notarytool submit dist/Sentry.zip --keychain-profile "AC_NOTARY" --wait
xcrun stapler staple dist/Sentry.app

A valid Apple Developer ID certificate (paid Apple Developer Program) is required for steps 1–2.

License

MIT License © 2026 Mark Santos


Built with ❤️ by NoSleepLab

Releases

Packages

Contributors

Languages