Add network activity map overlay and configurable monitoring filters

This commit is contained in:
Maxim
2026-10-09 22:59:32 +03:00
parent f198cc47d9
commit 6a940772f0
11 changed files with 462 additions and 67 deletions

View File

@@ -9,18 +9,27 @@ import (
)
type TrafficSettings struct {
NetworkEnabled bool `json:"networkEnabled"`
Enabled bool `json:"enabled"`
AgentID string `json:"agentId"`
ServerCountry string `json:"serverCountry"`
MonitoringRules []MonitoringRule `json:"monitoringRules"`
NetworkEnabled bool `json:"networkEnabled"`
Enabled bool `json:"enabled"`
AgentID string `json:"agentId"`
ServerCountry string `json:"serverCountry"`
}
func (s *Store) TrafficSettings() TrafficSettings {
var c TrafficSettings
s.loadJSONSetting("traffic", &c)
if c.MonitoringRules == nil {
c.MonitoringRules = []MonitoringRule{{IP: "192.168.0.10"}}
}
return c
}
func (s *Store) SaveTrafficSettings(c TrafficSettings) (TrafficSettings, error) {
rules, err := validateMonitoringRules(c.MonitoringRules)
if err != nil {
return c, err
}
c.MonitoringRules = rules
c.AgentID = strings.TrimSpace(c.AgentID)
c.ServerCountry = strings.ToUpper(strings.TrimSpace(c.ServerCountry))
if c.Enabled {
@@ -54,7 +63,7 @@ func trafficSettingsRoute(mux *http.ServeMux, s *Store) {
writeJSON(w, s.TrafficSettings(), nil)
case "PUT":
var c TrafficSettings
if json.NewDecoder(io.LimitReader(r.Body, 4096)).Decode(&c) != nil {
if json.NewDecoder(io.LimitReader(r.Body, 32<<10)).Decode(&c) != nil {
http.Error(w, "Некорректные настройки", 400)
return
}