Add network activity map overlay and configurable monitoring filters
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user