Add opt-in conntrack network activity and CrowdSec firewall counters

This commit is contained in:
Maxim
2026-10-09 22:32:41 +03:00
parent ea890c01b1
commit 49de0b1f49
11 changed files with 712 additions and 9 deletions

View File

@@ -76,6 +76,7 @@ const trafficSchema = `CREATE TABLE IF NOT EXISTS traffic_events (
country TEXT NOT NULL, UNIQUE(agent,event_id));
CREATE INDEX IF NOT EXISTS traffic_ts ON traffic_events(ts);
CREATE INDEX IF NOT EXISTS traffic_filter ON traffic_events(domain,kind,ts);
CREATE TABLE IF NOT EXISTS network_sources(agent TEXT PRIMARY KEY, snapshot TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS traffic_sources(agent TEXT PRIMARY KEY, last_seen INTEGER NOT NULL, status_json TEXT NOT NULL);`
func (s *Store) SaveTraffic(agent string, batch TrafficBatch) error {
@@ -244,6 +245,7 @@ func (s *Store) TrafficView(domain, kind string, external bool) (TrafficView, er
func trafficRoutes(mux *http.ServeMux, s *Store) {
trafficSettingsRoute(mux, s)
networkRoutes(mux, s)
mux.HandleFunc("/traffic", func(w http.ResponseWriter, r *http.Request) {
if !s.TrafficSettings().Enabled {
http.Error(w, "Карта трафика отключена. Включите её в настройках Dashboard.", 404)