Documentation
¶
Overview ¶
Package alerts decides when to notify the user that their network usage has crossed a configured threshold (a daily total cap, or a per-app daily cap). It is pure logic — posting the actual macOS notification is the caller's job — and it de-duplicates so each threshold fires at most once per calendar day.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigPath ¶
func ConfigPath() string
ConfigPath returns the on-disk path for the alert config, or "" if it can't be determined (~/Library/Application Support/netscope/alerts.json on macOS).
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker evaluates thresholds against today's totals and remembers what it has already fired today so it doesn't repeat. Safe for concurrent use.
func (*Checker) Check ¶
Check evaluates the thresholds for the given day (e.g. "2026-06-19") against today's total bytes and per-app bytes, returning any alerts to post now. Each threshold fires at most once per day; the day rolling over resets that.
func (*Checker) CheckUpload ¶ added in v0.5.0
CheckUpload evaluates the upload-watch thresholds (privacy) for the day against today's total upload and per-app upload bytes. Like Check, each threshold fires at most once per day. Shares the day/fired state with Check.
type Config ¶
type Config struct {
DailyTotalBytes int64 `json:"dailyTotalBytes"` // alert when today's total crosses this
PerAppBytes int64 `json:"perAppBytes"` // alert when any one app crosses this today
// Upload watch (privacy): uploads are data leaving your machine — surprise
// backups, cloud sync, exfiltration. Zero disables.
DailyUploadBytes int64 `json:"dailyUploadBytes"` // alert when today's total upload crosses this
PerAppUploadBytes int64 `json:"perAppUploadBytes"` // alert when any one app's upload crosses this today
}
Config holds the user's alert thresholds, in bytes. A zero value disables that threshold.