Add connection history per peer with country and network lookup
- The stats sampler records sessions per peer: start, end, address and
traffic. A session ends when the peer goes quiet or is disabled; a new
one starts when the device changes networks. Stored in stats.json and
kept as long as the daily traffic history (max 1000 per peer).
- Country and network operator come from the free DB-IP Lite databases
(CC BY 4.0), downloaded monthly and looked up locally, so peer
addresses never leave the server. Settings → Data retention can switch
this off, which deletes the databases.
- API: GET /peers/{id}/sessions; peer stats include the current location;
settings include the database status.
- Web UI and iOS app: connection history card, location line, country
code in the peer list (web), switch in data retention.
Claude-Session: https://claude.ai/code/session_01RAnLbyQZ5ZTA7KqwXP98nw
This commit is contained in:
@@ -32,9 +32,14 @@ type Config struct {
|
||||
// StatsConfig sets how long traffic history is kept in stats.json.
|
||||
type StatsConfig struct {
|
||||
HourlyHours int `json:"hourlyHours"` // hourly buckets, for the 24 h charts
|
||||
DailyDays int `json:"dailyDays"` // daily buckets, for the 7/30/90 day charts
|
||||
DailyDays int `json:"dailyDays"` // daily buckets and connection history
|
||||
// GeoIP looks up country and network of peer addresses in the DB-IP Lite
|
||||
// databases, downloaded monthly. Default on.
|
||||
GeoIP *bool `json:"geoip,omitempty"`
|
||||
}
|
||||
|
||||
func (c StatsConfig) geoEnabled() bool { return c.GeoIP == nil || *c.GeoIP }
|
||||
|
||||
// Limits for the retention settings.
|
||||
const (
|
||||
minLogSizeMB, maxLogSizeMB = 1, 1000
|
||||
|
||||
Reference in New Issue
Block a user