Просмотр исходного кода

chore: close maintenance audit findings (#1634)

Add the collector module to Dependabot, pin toolchain go1.26.10 in the three Go modules, run gofmt and fix the nine go vet warnings in tests. deepmerge 4.3.1 stays as is: build-time only and still the latest release.

Closes #1633
Nacho 1 месяц назад
Родитель
Сommit
e5b876b8bd
41 измененных файлов с 174 добавлено и 156 удалено
  1. 4 0
      .github/dependabot.yml
  2. 3 3
      agent/cmd/netpulse-agent/netgrip_delegate.go
  3. 2 0
      agent/go.mod
  4. 3 3
      agent/internal/push/push_test.go
  5. 9 9
      agent/probe/lldp_test.go
  6. 2 0
      collector/go.mod
  7. 2 0
      server-go/go.mod
  8. 2 2
      server-go/internal/adapters/alerts_live_test.go
  9. 1 1
      server-go/internal/adapters/classify.go
  10. 4 4
      server-go/internal/adapters/demo.go
  11. 1 1
      server-go/internal/adapters/impostor.go
  12. 2 2
      server-go/internal/adapters/topo_semantics_test.go
  13. 3 3
      server-go/internal/adapters/topology_phantom_test.go
  14. 0 1
      server-go/internal/alerts/alerts_test.go
  15. 3 3
      server-go/internal/alerts/suppression.go
  16. 6 6
      server-go/internal/channelplan/store.go
  17. 2 2
      server-go/internal/clientbw/store_test.go
  18. 2 2
      server-go/internal/firmware/image.go
  19. 2 2
      server-go/internal/firmware/image_test.go
  20. 1 1
      server-go/internal/httpapi/adguard_detect.go
  21. 1 0
      server-go/internal/httpapi/device_links.go
  22. 12 12
      server-go/internal/httpapi/httpapi_test.go
  23. 2 1
      server-go/internal/httpapi/speedtest_api.go
  24. 1 1
      server-go/internal/httpapi/speedtest_api_test.go
  25. 0 1
      server-go/internal/httpapi/thresholds_hide_recovery_test.go
  26. 16 7
      server-go/internal/httpapi/tokens_api_test.go
  27. 10 10
      server-go/internal/internethealth/store.go
  28. 5 5
      server-go/internal/orchestr/dawn.go
  29. 8 8
      server-go/internal/orchestr/usteer.go
  30. 11 11
      server-go/internal/presence/store.go
  31. 9 9
      server-go/internal/roamevents/collector.go
  32. 0 1
      server-go/internal/roamevents/collector_test.go
  33. 2 2
      server-go/internal/snmp/fdbTable.go
  34. 12 12
      server-go/internal/snmp/ifTable.go
  35. 11 11
      server-go/internal/snmp/snmp_test.go
  36. 1 1
      server-go/internal/speedtest/http_runner_test.go
  37. 3 3
      server-go/internal/speedtest/ndt_runner_test.go
  38. 7 7
      server-go/internal/telegram/telegram.go
  39. 5 5
      server-go/internal/telegram/telegram_test.go
  40. 2 2
      server-go/internal/updater/autosched_test.go
  41. 2 2
      server-go/internal/wifisle/store.go

+ 4 - 0
.github/dependabot.yml

@@ -11,6 +11,10 @@ updates:
     directory: /agent
     schedule:
       interval: monthly
+  - package-ecosystem: gomod
+    directory: /collector
+    schedule:
+      interval: monthly
   - package-ecosystem: npm
     directory: /app
     schedule:

+ 3 - 3
agent/cmd/netpulse-agent/netgrip_delegate.go

@@ -13,9 +13,9 @@ import (
 )
 
 const (
-	netgripAddr       = "http://127.0.0.1:8080"
-	netgripTokenPath  = "/etc/netgrip/executor-token"
-	netgripTimeout    = 30 * time.Second
+	netgripAddr      = "http://127.0.0.1:8080"
+	netgripTokenPath = "/etc/netgrip/executor-token"
+	netgripTimeout   = 30 * time.Second
 )
 
 func readNetgripToken() (string, error) {

+ 2 - 0
agent/go.mod

@@ -2,4 +2,6 @@ module github.com/gnacho/netpulse/agent
 
 go 1.26.0
 
+toolchain go1.26.10
+
 require golang.org/x/net v0.59.0

+ 3 - 3
agent/internal/push/push_test.go

@@ -153,9 +153,9 @@ func TestPushFlushDescartaStales(t *testing.T) {
 	c := New(srv.URL, "tok", srv.Client())
 
 	now := time.Now().Unix()
-	staleA := mkPayload(now - 600)  // 10 min de edad: fuera de ventana
-	staleB := mkPayload(now - 480)  // 8 min: ídem
-	fresh := mkPayload(now)         // recién generado
+	staleA := mkPayload(now - 600) // 10 min de edad: fuera de ventana
+	staleB := mkPayload(now - 480) // 8 min: ídem
+	fresh := mkPayload(now)        // recién generado
 
 	// Servidor caído: A entra directo al buffer; el Push de B drena (A se
 	// descarta por stale) y B acaba también en el buffer.

+ 9 - 9
agent/probe/lldp_test.go

@@ -296,15 +296,15 @@ func TestLldpdBridgeOnly(t *testing.T) {
 		ifaces string
 		want   bool
 	}{
-		{"", false},                    // sin opción UCI: lldpd escucha en físicas
-		{"br-lan", true},               // el caso del issue (stock qualcommax)
-		{"br-lan,br-guest", true},      // varios bridges: igual de ciego
-		{"lan*,wan", false},            // el fix aplicado en la flota
-		{"lan1", false},                // puerto físico suelto
-		{"br-lan,lan1", false},         // mixto: ya escucha en físicas
-		{" lan1 , wan ", false},        // espacios tolerados
-		{"eth0", false},                // Linux genérico con nombre eth
-		{",,,", false},                 // tokens vacíos: sin binding efectivo
+		{"", false},               // sin opción UCI: lldpd escucha en físicas
+		{"br-lan", true},          // el caso del issue (stock qualcommax)
+		{"br-lan,br-guest", true}, // varios bridges: igual de ciego
+		{"lan*,wan", false},       // el fix aplicado en la flota
+		{"lan1", false},           // puerto físico suelto
+		{"br-lan,lan1", false},    // mixto: ya escucha en físicas
+		{" lan1 , wan ", false},   // espacios tolerados
+		{"eth0", false},           // Linux genérico con nombre eth
+		{",,,", false},            // tokens vacíos: sin binding efectivo
 	}
 	for _, c := range cases {
 		if got := LldpdBridgeOnly(c.ifaces); got != c.want {

+ 2 - 0
collector/go.mod

@@ -2,6 +2,8 @@ module github.com/gnacho/netpulse/collector
 
 go 1.26.0
 
+toolchain go1.26.10
+
 require modernc.org/sqlite v1.60.1
 
 require (

+ 2 - 0
server-go/go.mod

@@ -2,6 +2,8 @@ module github.com/gnacho/netpulse/server-go
 
 go 1.26.0
 
+toolchain go1.26.10
+
 require (
 	github.com/SherClockHolmes/webpush-go v1.4.0
 	github.com/gnacho/netpulse/agent v0.0.0

+ 2 - 2
server-go/internal/adapters/alerts_live_test.go

@@ -171,8 +171,8 @@ func TestLiveRouterOfflineFlappingDoesNotRearm(t *testing.T) {
 
 	// Flap: éxitos aislados no cierran el incidente ni rearman.
 	l.mu.Lock()
-	l.trackRouterRecovered(cfg) // streak 1
-	l.trackRouterRecovered(cfg) // streak 2
+	l.trackRouterRecovered(cfg)           // streak 1
+	l.trackRouterRecovered(cfg)           // streak 2
 	l.trackRouterOffline(cfg, errDown, 2) // vuelve a caer: sin alerta nueva
 	l.mu.Unlock()
 	if list := l.engine.List(); len(list) != 1 || !strings.HasPrefix(list[0].ID, "alert-offline-patio-") {

+ 1 - 1
server-go/internal/adapters/classify.go

@@ -125,7 +125,7 @@ func GuessDeviceType(hostname, manufacturer, dhcpVendorClass, dhcpClientID, lldp
 // devolver (y las claves devices.types.* del frontend). El override manual de
 // tipo (#797) valida contra esta lista.
 var ValidDeviceTypes = map[string]bool{
-	"modem": true, // #1495: ONT/módem en bridge (primer salto del enlace WAN)
+	"modem":   true, // #1495: ONT/módem en bridge (primer salto del enlace WAN)
 	"consola": true, "tv": true, "camara": true, "altavoz": true,
 	"tablet": true, "movil": true, "portatil": true, "servidor": true,
 	"ordenador": true, "switch": true, "iot": true, "desconocido": true,

+ 4 - 4
server-go/internal/adapters/demo.go

@@ -182,9 +182,9 @@ func (d *Demo) Tick(context.Context) error {
 // Snapshotter
 // ---------------------------------------------------------------------------
 
-func (d *Demo) Mode() string              { return "demo" }
-func (d *Demo) SetRouters([]RouterConfig) {} // la demo ignora la configuración
-func (d *Demo) Close() error              { return nil }
+func (d *Demo) Mode() string                { return "demo" }
+func (d *Demo) SetRouters([]RouterConfig)   {} // la demo ignora la configuración
+func (d *Demo) Close() error                { return nil }
 func (d *Demo) DismissUnknownDevice(string) {}
 
 func (d *Demo) GetUsteer(context.Context) (*Usteer, error) { return nil, nil }
@@ -228,7 +228,7 @@ func (d *Demo) buildOverview() *Overview {
 		UnreadAlerts:      d.engine.UnreadCount(),
 		DistributionNodes: dists,
 		Topology:          BuildTopoSemantics(d.routers, d.devices, wg, dists, "", nil, nil, nil), // SPEC-65 D65-3
-		VM:                ViewModelVersion,                                    // SPEC-65 D65-4
+		VM:                ViewModelVersion,                                                       // SPEC-65 D65-4
 		Ts:                time.Now().Unix(),
 	}
 }

+ 1 - 1
server-go/internal/adapters/impostor.go

@@ -198,7 +198,7 @@ func (l *Live) EvalSsidImpostors() {
 			routerName = rn
 		}
 		l.engine.Emit(AlertEvent{
-			ID:       alertID,
+			ID: alertID,
 			// CatClients y no CatSignal: signal está en LevelNone por defecto
 			// (alertas de cobertura) y una alerta de SEGURIDAD no puede
 			// quedar invisible en la config stock (#1358).

+ 2 - 2
server-go/internal/adapters/topo_semantics_test.go

@@ -545,8 +545,8 @@ func TestFleetFdbEvidenceRegisteredMac(t *testing.T) {
 			"A0:36:9F:7E:38:BC": "eth1", // NAS en tránsito por el uplink
 		}},
 		"core": {brMac: "AA:BB:CC:00:00:07", fdb: map[string]string{
-			"AA:BB:CC:00:00:01": "xg7",   // root port hacia gw
-			"A0:36:9F:7E:38:BC": "xg4",   // NIC del NAS
+			"AA:BB:CC:00:00:01": "xg7", // root port hacia gw
+			"A0:36:9F:7E:38:BC": "xg4", // NIC del NAS
 		}},
 		"nas": {brMac: "02:42:AC:11:00:03", fdb: map[string]string{}},
 	}

+ 3 - 3
server-go/internal/adapters/topology_phantom_test.go

@@ -19,9 +19,9 @@ const (
 // los devuelve lldpcli) y su FDB aprende al gateway por lan1 (root port).
 func phantomPolled(neighbors []LldpNeighbor, fdb map[string]string) map[string]*routerPolled {
 	return map[string]*routerPolled{
-		"gw":  {cfg: RouterConfig{ID: "gw", IsGateway: true}, brMac: macGw},
-		"rt2": {cfg: RouterConfig{ID: "rt2", Type: "openwrt"}, brMac: macRT2},
-		"rt3": {cfg: RouterConfig{ID: "rt3", Type: "openwrt"}, brMac: macRT3},
+		"gw":     {cfg: RouterConfig{ID: "gw", IsGateway: true}, brMac: macGw},
+		"rt2":    {cfg: RouterConfig{ID: "rt2", Type: "openwrt"}, brMac: macRT2},
+		"rt3":    {cfg: RouterConfig{ID: "rt3", Type: "openwrt"}, brMac: macRT3},
 		"swCore": {cfg: RouterConfig{ID: "swCore", Type: "managed-switch"}, brMac: macSwCor},
 		"swFar":  {cfg: RouterConfig{ID: "swFar", Type: "managed-switch"}, brMac: macSwFar},
 		"rt4": {cfg: RouterConfig{ID: "rt4", Type: "openwrt"}, brMac: "44:00:00:00:00:44",

+ 0 - 1
server-go/internal/alerts/alerts_test.go

@@ -296,7 +296,6 @@ func TestSeedSkipsConfigButKeepsDedup(t *testing.T) {
 	}
 }
 
-
 // TestEmitOrUpdateReepisodeAfterRestart (#1094): una alerta leída en una
 // sesión previa que se re-emite tras el arranque (p. ej. "Agent outdated"
 // al reiniciar el server) vuelve a NO-leída: es un episodio nuevo y el

+ 3 - 3
server-go/internal/alerts/suppression.go

@@ -8,9 +8,9 @@ import (
 // suppression: if a parent router is offline, child router alerts are marked
 // as suppressed instead of discarded (issue #332).
 type SuppressionGraph struct {
-	mu      sync.RWMutex
-	parent  map[string]string   // child -> parent routerId
-	down    map[string]bool     // routerId -> currently offline
+	mu     sync.RWMutex
+	parent map[string]string // child -> parent routerId
+	down   map[string]bool   // routerId -> currently offline
 }
 
 func NewSuppressionGraph() *SuppressionGraph {

+ 6 - 6
server-go/internal/channelplan/store.go

@@ -57,12 +57,12 @@ func (s *Store) SaveScan(routerID string, ts int64, scans []probe.ScanResult) er
 
 // ScanRow es un vecino persistido (forma plana para la UI/API).
 type ScanRow struct {
-	Iface    string `json:"iface"`
-	BSSID    string `json:"bssid"`
-	SSID     string `json:"ssid"`
-	Channel  int    `json:"channel"`
-	Freq     int    `json:"freq"`
-	Signal   int    `json:"signal"`
+	Iface   string `json:"iface"`
+	BSSID   string `json:"bssid"`
+	SSID    string `json:"ssid"`
+	Channel int    `json:"channel"`
+	Freq    int    `json:"freq"`
+	Signal  int    `json:"signal"`
 	// WidthMhz: ancho anunciado por el vecino (#1087); 0 = desconocido
 	// (agente viejo o BSS sin HT/VHT): la UI dibuja 20 MHz de fallback.
 	WidthMhz int    `json:"widthMhz"`

+ 2 - 2
server-go/internal/clientbw/store_test.go

@@ -40,7 +40,7 @@ func TestInsertAndQuery(t *testing.T) {
 	for i := 0; i < 10; i++ {
 		if err := s.Insert(Sample{
 			MAC: "aa:bb:cc:dd:ee:ff", RouterID: "gw",
-			TS: now.Add(time.Duration(i) * time.Minute),
+			TS:      now.Add(time.Duration(i) * time.Minute),
 			RxBytes: uint64(i * 1000), TxBytes: uint64(i * 500),
 			RxBps: float64(i * 8000), TxBps: float64(i * 4000),
 		}); err != nil {
@@ -102,7 +102,7 @@ func TestTopClients(t *testing.T) {
 		for j := 0; j < 5; j++ {
 			_ = s.Insert(Sample{
 				MAC: mac, RouterID: "gw",
-				TS: now.Add(time.Duration(j) * time.Minute),
+				TS:      now.Add(time.Duration(j) * time.Minute),
 				RxBytes: uint64((i + 1) * 1000), TxBytes: uint64((i + 1) * 500),
 			})
 		}

+ 2 - 2
server-go/internal/firmware/image.go

@@ -49,7 +49,7 @@ var ErrNoProfile = fmt.Errorf("firmware: perfil no encontrado para el board_name
 // RestrictToTarget helper no usado por ahora; se añade si hay que filtrar.
 type profilesJSON struct {
 	Profiles map[string]struct {
-		ImagePrefix      string `json:"image_prefix"`
+		ImagePrefix      string   `json:"image_prefix"`
 		SupportedDevices []string `json:"supported_devices"`
 		Images           []struct {
 			Filesystem string `json:"filesystem"`
@@ -90,7 +90,7 @@ func (r *ImageResolver) Resolve(ctx context.Context, version, target, boardName
 	}
 	// El board_name (p.ej. "redmi,ax6") casa con supported_devices de un perfil.
 	var best *struct {
-		ImagePrefix      string `json:"image_prefix"`
+		ImagePrefix      string   `json:"image_prefix"`
 		SupportedDevices []string `json:"supported_devices"`
 		Images           []struct {
 			Filesystem string `json:"filesystem"`

+ 2 - 2
server-go/internal/firmware/image_test.go

@@ -13,7 +13,7 @@ func sampleProfiles() map[string]any {
 	return map[string]any{
 		"profiles": map[string]any{
 			"redmi_ax6": map[string]any{
-				"image_prefix": "openwrt-25.12.5-qualcommax-ipq807x-redmi_ax6",
+				"image_prefix":      "openwrt-25.12.5-qualcommax-ipq807x-redmi_ax6",
 				"supported_devices": []string{"redmi,ax6"},
 				"images": []map[string]any{
 					{"filesystem": "squashfs", "name": "openwrt-25.12.5-qualcommax-ipq807x-redmi_ax6-squashfs-factory.ubi", "sha256": "aaaa", "type": "factory"},
@@ -21,7 +21,7 @@ func sampleProfiles() map[string]any {
 				},
 			},
 			"glinet_flint2": map[string]any{
-				"image_prefix":   "openwrt-25.12.5-qualcommax-ipq807x-glinet_flint2",
+				"image_prefix":      "openwrt-25.12.5-qualcommax-ipq807x-glinet_flint2",
 				"supported_devices": []string{"glinet,flint2"},
 				"images": []map[string]any{
 					{"filesystem": "squashfs", "name": "openwrt-25.12.5-qualcommax-ipq807x-glinet_flint2-squashfs-sysupgrade.bin", "sha256": "bbbb", "type": "sysupgrade"},

+ 1 - 1
server-go/internal/httpapi/adguard_detect.go

@@ -19,7 +19,7 @@ import (
 // host de la flota sirve la API de AdGuard Home.
 type adguardDetectResponse struct {
 	Found  bool   `json:"found"`
-	Mode   string `json:"mode,omitempty"`   // "glinet" | "standard"
+	Mode   string `json:"mode,omitempty"` // "glinet" | "standard"
 	Host   string `json:"host,omitempty"`
 	Port   int    `json:"port,omitempty"`
 	Source string `json:"source,omitempty"` // "gateway" | "fleet"

+ 1 - 0
server-go/internal/httpapi/device_links.go

@@ -8,6 +8,7 @@ import (
 	"net/http"
 	"strings"
 )
+
 // handleDeviceLinkPut: body {"target": "<mac>"} — enlaza la MAC {mac} como
 // alias del cliente {target}. Reglas: no enlaces a sí mismo, ni alias ya
 // enlazada (desenlazar primero), ni target que sea a su vez alias (sin

+ 12 - 12
server-go/internal/httpapi/httpapi_test.go

@@ -17,9 +17,9 @@ import (
 	"github.com/gnacho/netpulse/server-go/internal/apitoken"
 	"github.com/gnacho/netpulse/server-go/internal/auth"
 	"github.com/gnacho/netpulse/server-go/internal/channelplan"
+	"github.com/gnacho/netpulse/server-go/internal/clientbw"
 	"github.com/gnacho/netpulse/server-go/internal/config"
 	"github.com/gnacho/netpulse/server-go/internal/configbackup"
-	"github.com/gnacho/netpulse/server-go/internal/clientbw"
 	"github.com/gnacho/netpulse/server-go/internal/db"
 	"github.com/gnacho/netpulse/server-go/internal/httpapi"
 	"github.com/gnacho/netpulse/server-go/internal/orchestr"
@@ -94,12 +94,12 @@ func makeTestServerWithMode(t *testing.T, demoMode bool) *testServer {
 	chPlan := channelplan.NewStore(d.DB)
 	handler := httpapi.NewHandler(httpapi.Deps{
 		Config: cfg, DB: d, Adapter: adapter, Hub: hub, Secret: secret,
-		Started:       time.Now(),
-		TokenStore:    tokenStore,
-		ConfigBackup:  configBackup,
-		Orchestr:      orchestrMgr,
-		Agents:        agents,
-		ChannelPlan:   chPlan,
+		Started:      time.Now(),
+		TokenStore:   tokenStore,
+		ConfigBackup: configBackup,
+		Orchestr:     orchestrMgr,
+		Agents:       agents,
+		ChannelPlan:  chPlan,
 	})
 	srv := httptest.NewServer(handler)
 	ts := &testServer{Server: srv, db: d, secret: secret}
@@ -884,11 +884,11 @@ func TestSecurityHeaders(t *testing.T) {
 	res := get(t, srv.URL, "/api/health", "")
 	res.Body.Close()
 	want := map[string]string{
-		"X-Content-Type-Options":    "nosniff",
-		"X-Frame-Options":           "DENY",
-		"Referrer-Policy":           "strict-origin-when-cross-origin",
-		"Permissions-Policy":        "geolocation=(), microphone=(), camera=()",
-		"Content-Security-Policy":   "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data:; connect-src 'self'",
+		"X-Content-Type-Options":  "nosniff",
+		"X-Frame-Options":         "DENY",
+		"Referrer-Policy":         "strict-origin-when-cross-origin",
+		"Permissions-Policy":      "geolocation=(), microphone=(), camera=()",
+		"Content-Security-Policy": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data:; connect-src 'self'",
 	}
 	for k, v := range want {
 		if got := res.Header.Get(k); got != v {

+ 2 - 1
server-go/internal/httpapi/speedtest_api.go

@@ -4,7 +4,8 @@
 // GET  /api/speedtest/history  serie de la ventana ?hours= (default 168).
 // POST /api/speedtest/run      lanza un test manual (202; 409 si ya corre).
 // GET/PUT /api/settings/speedtest  configuración (intervalo, servidor,
-//                                 umbral de alerta) — admin.
+//
+//	umbral de alerta) — admin.
 //
 // Deps.Speedtest nil (demo) → 503 unavailable, como el resto de deps nulas.
 package httpapi

+ 1 - 1
server-go/internal/httpapi/speedtest_api_test.go

@@ -73,7 +73,7 @@ func makeSpeedtestServer(t *testing.T, runner speedtest.Runner) *testServer {
 	sched.SetHTTPRunner(runner)
 	handler := httpapi.NewHandler(httpapi.Deps{
 		Config: cfg, DB: d, Adapter: adapters.NewDemo(),
-		Hub: sse.NewHub(d, cfg.MaxSSEClients, func() any { return nil }),
+		Hub:    sse.NewHub(d, cfg.MaxSSEClients, func() any { return nil }),
 		Secret: secret, Agents: adapters.NewAgentRegistry(0),
 		TokenStore:  apitoken.NewStore(d, secret),
 		ChannelPlan: channelplan.NewStore(d.DB),

+ 0 - 1
server-go/internal/httpapi/thresholds_hide_recovery_test.go

@@ -55,4 +55,3 @@ func TestThresholdsHideRecoveryRoundTrip(t *testing.T) {
 		t.Fatalf("GET tras PUT off: hideRecoveryEvents = %v, esperaba false", body["hideRecoveryEvents"])
 	}
 }
-

+ 16 - 7
server-go/internal/httpapi/tokens_api_test.go

@@ -7,6 +7,15 @@ import (
 	"testing"
 )
 
+func mustDo(t *testing.T, req *http.Request) *http.Response {
+	t.Helper()
+	resp, err := http.DefaultClient.Do(req)
+	if err != nil {
+		t.Fatalf("request: %v", err)
+	}
+	return resp
+}
+
 func TestTokensCRUD(t *testing.T) {
 	ts := makeTestServer(t)
 	defer ts.Close()
@@ -24,7 +33,7 @@ func TestTokensCRUD(t *testing.T) {
 		req, _ := http.NewRequest("POST", ts.URL+"/api/tokens", bytes.NewReader(createBody))
 		req.Header.Set("Content-Type", "application/json")
 		req.Header.Set("Cookie", "session="+cookie)
-		resp, _ := http.DefaultClient.Do(req)
+		resp := mustDo(t, req)
 		defer resp.Body.Close()
 		if resp.StatusCode != http.StatusCreated {
 			t.Fatalf("create: expected 201, got %d", resp.StatusCode)
@@ -38,7 +47,7 @@ func TestTokensCRUD(t *testing.T) {
 	{
 		req, _ := http.NewRequest("GET", ts.URL+"/api/tokens", nil)
 		req.Header.Set("Cookie", "session="+cookie)
-		resp, _ := http.DefaultClient.Do(req)
+		resp := mustDo(t, req)
 		defer resp.Body.Close()
 		if resp.StatusCode != http.StatusOK {
 			t.Fatalf("list: expected 200, got %d", resp.StatusCode)
@@ -58,7 +67,7 @@ func TestTokensCRUD(t *testing.T) {
 	{
 		req, _ := http.NewRequest("DELETE", ts.URL+"/api/tokens/"+created.ID, nil)
 		req.Header.Set("Cookie", "session="+cookie)
-		resp, _ := http.DefaultClient.Do(req)
+		resp := mustDo(t, req)
 		defer resp.Body.Close()
 		if resp.StatusCode != http.StatusNoContent {
 			t.Fatalf("delete: expected 204, got %d", resp.StatusCode)
@@ -68,7 +77,7 @@ func TestTokensCRUD(t *testing.T) {
 	{
 		req, _ := http.NewRequest("GET", ts.URL+"/api/tokens", nil)
 		req.Header.Set("Cookie", "session="+cookie)
-		resp, _ := http.DefaultClient.Do(req)
+		resp := mustDo(t, req)
 		defer resp.Body.Close()
 		var body struct {
 			Tokens []struct{ ID string } `json:"tokens"`
@@ -91,7 +100,7 @@ func TestTokenBearerAuth(t *testing.T) {
 	req, _ := http.NewRequest("POST", ts.URL+"/api/tokens", bytes.NewReader(createBody))
 	req.Header.Set("Content-Type", "application/json")
 	req.Header.Set("Cookie", "session="+cookie)
-	resp, _ := http.DefaultClient.Do(req)
+	resp := mustDo(t, req)
 	defer resp.Body.Close()
 	var created struct {
 		Token string `json:"token"`
@@ -103,7 +112,7 @@ func TestTokenBearerAuth(t *testing.T) {
 
 	req, _ = http.NewRequest("GET", ts.URL+"/api/overview", nil)
 	req.Header.Set("Authorization", "Bearer "+created.Token)
-	resp2, _ := http.DefaultClient.Do(req)
+	resp2 := mustDo(t, req)
 	defer resp2.Body.Close()
 	if resp2.StatusCode == http.StatusUnauthorized {
 		t.Fatal("bearer token should authenticate, got 401")
@@ -116,7 +125,7 @@ func TestTokenBearerInvalid(t *testing.T) {
 
 	req, _ := http.NewRequest("GET", ts.URL+"/api/overview", nil)
 	req.Header.Set("Authorization", "Bearer np_invalidtoken")
-	resp, _ := http.DefaultClient.Do(req)
+	resp := mustDo(t, req)
 	defer resp.Body.Close()
 	if resp.StatusCode != http.StatusUnauthorized {
 		t.Fatalf("invalid bearer should get 401, got %d", resp.StatusCode)

+ 10 - 10
server-go/internal/internethealth/store.go

@@ -43,23 +43,23 @@ type ProbeResult struct {
 }
 
 type Outage struct {
-	ID         int64    `json:"id"`
-	StartedAt  int64    `json:"startedAt"`
-	EndedAt    *int64   `json:"endedAt"`
-	DurationS  *int64   `json:"durationS"`
+	ID          int64    `json:"id"`
+	StartedAt   int64    `json:"startedAt"`
+	EndedAt     *int64   `json:"endedAt"`
+	DurationS   *int64   `json:"durationS"`
 	TargetsDown []string `json:"targetsDown"`
 }
 
 type Summary struct {
-	LastProbe  *ProbeResult `json:"lastProbe"`
-	CurrentOutage *Outage   `json:"currentOutage"`
-	TotalOutages24h int     `json:"totalOutages24h"`
-	AvgLatency24h   float64 `json:"avgLatency24h"`
+	LastProbe       *ProbeResult `json:"lastProbe"`
+	CurrentOutage   *Outage      `json:"currentOutage"`
+	TotalOutages24h int          `json:"totalOutages24h"`
+	AvgLatency24h   float64      `json:"avgLatency24h"`
 }
 
 type Store struct {
-	mu   sync.Mutex
-	db   *db.DB
+	mu     sync.Mutex
+	db     *db.DB
 	outage *Outage
 }
 

+ 5 - 5
server-go/internal/orchestr/dawn.go

@@ -39,9 +39,9 @@ type DawnDesired struct {
 	Duration           string `json:"duration,omitempty"`           // default "150"
 	MinNumberToKick    string `json:"minNumberToKick,omitempty"`    // default "3"
 	BandwidthThreshold string `json:"bandwidthThreshold,omitempty"` // default "6"
-	EvalAuthReq        string `json:"evalAuthReq,omitempty"`      // default "0"
-	EvalAssocReq       string `json:"evalAssocReq,omitempty"`     // default "0"
-	EvalProbeReq       string `json:"evalProbeReq,omitempty"`     // default "0"
+	EvalAuthReq        string `json:"evalAuthReq,omitempty"`        // default "0"
+	EvalAssocReq       string `json:"evalAssocReq,omitempty"`       // default "0"
+	EvalProbeReq       string `json:"evalProbeReq,omitempty"`       // default "0"
 	IEEE80211K         bool   `json:"ieee80211k,omitempty"`
 	IEEE80211R         bool   `json:"ieee80211r,omitempty"`
 	IEEE80211V         bool   `json:"ieee80211v,omitempty"`
@@ -73,10 +73,10 @@ type DawnRadio struct {
 
 // DawnScenario describe el estado detectado de DAWN en un router.
 type DawnScenario struct {
-	Manager       string        // apk | opkg | ""
+	Manager       string // apk | opkg | ""
 	DawnInstalled bool
 	DawnRunning   bool
-	WpadVariant   string        // basic | mbedtls | wolfssl | openssl | other | ""
+	WpadVariant   string // basic | mbedtls | wolfssl | openssl | other | ""
 	HostapdDirOK  bool
 	Global        map[string]string
 	SSIDs         []DawnSSID

+ 8 - 8
server-go/internal/orchestr/usteer.go

@@ -28,8 +28,8 @@ import (
 // UsteerDesired es el estado deseado del modulo usteer.
 type UsteerDesired struct {
 	Enabled                bool   `json:"enabled"`
-	SSID                   string `json:"ssid,omitempty"`               // SSID a gestionar; vacio = todas las de modo AP
-	MobilityDomain         string `json:"mobilityDomain,omitempty"`       // p. ej. "2025"
+	SSID                   string `json:"ssid,omitempty"`                   // SSID a gestionar; vacio = todas las de modo AP
+	MobilityDomain         string `json:"mobilityDomain,omitempty"`         // p. ej. "2025"
 	Aggressiveness         string `json:"aggressiveness,omitempty"`         // default "3"
 	BandSteeringThreshold  string `json:"bandSteeringThreshold,omitempty"`  // default "5"
 	LoadBalancingThreshold string `json:"loadBalancingThreshold,omitempty"` // default "0"
@@ -65,14 +65,14 @@ type UsteerRadio struct {
 
 // UsteerScenario describe el estado detectado de usteer en un router.
 type UsteerScenario struct {
-	Manager        string            // apk | opkg | ""
+	Manager         string // apk | opkg | ""
 	UsteerInstalled bool
 	UsteerRunning   bool
-	WpadVariant    string            // basic | mbedtls | wolfssl | openssl | other | ""
-	HostapdDirOK   bool
-	Config         map[string]string // usteer.@usteer[-1] options
-	SSIDs          []UsteerSSID
-	Radios         []UsteerRadio
+	WpadVariant     string // basic | mbedtls | wolfssl | openssl | other | ""
+	HostapdDirOK    bool
+	Config          map[string]string // usteer.@usteer[-1] options
+	SSIDs           []UsteerSSID
+	Radios          []UsteerRadio
 }
 
 const probeUsteerCmd = `echo '===PKG_MGR==='

+ 11 - 11
server-go/internal/presence/store.go

@@ -11,10 +11,10 @@ import (
 const peopleKey = "presence.people.v1"
 
 type Person struct {
-	ID      string   `json:"id"`
-	Name    string   `json:"name"`
-	MACs    []string `json:"macs"`
-	Color   string   `json:"color"`
+	ID    string   `json:"id"`
+	Name  string   `json:"name"`
+	MACs  []string `json:"macs"`
+	Color string   `json:"color"`
 }
 
 type PresenceEvent struct {
@@ -25,16 +25,16 @@ type PresenceEvent struct {
 }
 
 type Status struct {
-	Person    string `json:"person"`
-	Home      bool   `json:"home"`
-	LastSeen  int64  `json:"lastSeen"`
-	DevicesOnline int `json:"devicesOnline"`
+	Person        string `json:"person"`
+	Home          bool   `json:"home"`
+	LastSeen      int64  `json:"lastSeen"`
+	DevicesOnline int    `json:"devicesOnline"`
 }
 
 type Store struct {
-	mu   sync.RWMutex
-	db   *db.DB
-	people []Person
+	mu          sync.RWMutex
+	db          *db.DB
+	people      []Person
 	macToPerson map[string]string
 }
 

+ 9 - 9
server-go/internal/roamevents/collector.go

@@ -29,20 +29,20 @@ import (
 
 // Tipo de evento roaming.
 const (
-	TypeConnected     = "connected"
-	TypeDisconnected  = "disconnected"
+	TypeConnected    = "connected"
+	TypeDisconnected = "disconnected"
 	TypeDawnDecision = "dawn_decision"
 )
 
 // Event es una fila de roam_events (entrada del feed).
 type Event struct {
-	ID        int64  `json:"id"`
-	TsMs      int64  `json:"ts_ms"`
-	RouterID  string `json:"router_id"`
-	Type      string `json:"type"`
-	MAC       string `json:"mac,omitempty"`
-	Iface     string `json:"iface,omitempty"`
-	Detail    string `json:"detail,omitempty"`
+	ID       int64  `json:"id"`
+	TsMs     int64  `json:"ts_ms"`
+	RouterID string `json:"router_id"`
+	Type     string `json:"type"`
+	MAC      string `json:"mac,omitempty"`
+	Iface    string `json:"iface,omitempty"`
+	Detail   string `json:"detail,omitempty"`
 }
 
 // RouterHost resuelve router_id → host para que el Collector haga SSH.

+ 0 - 1
server-go/internal/roamevents/collector_test.go

@@ -376,4 +376,3 @@ func TestListEventsFilters(t *testing.T) {
 		t.Errorf("filtro since 2000: %d, want 2", len(got))
 	}
 }
-

+ 2 - 2
server-go/internal/snmp/fdbTable.go

@@ -8,9 +8,9 @@ import (
 )
 
 type FdbEntry struct {
-	MAC            string
+	MAC             string
 	BridgePortIndex int
-	IfIndex        int
+	IfIndex         int
 }
 
 // FdbPoll es el resultado de sondear el FDB de un switch. Además de las

+ 12 - 12
server-go/internal/snmp/ifTable.go

@@ -9,24 +9,24 @@ import (
 )
 
 type PortStats struct {
-	Index      int
-	Name       string
-	Descr      string
-	Alias      string
-	Type       int
+	Index int
+	Name  string
+	Descr string
+	Alias string
+	Type  int
 	// Familia de la interfaz para las NO físicas (#1125): "lag", "vlan",
 	// "bridge", "tunnel" o "virtual". Vacío = boca física (o ifType no
 	// reportado por walk fallido: se conserva en el grupo físico, la misma
 	// defensa de la #1115). El frontend las agrupa colapsadas al pie de la
 	// tarjeta de puertos en vez de ocultarlas.
-	Family     string
-	SpeedBps   uint64
+	Family        string
+	SpeedBps      uint64
 	HighSpeedMbps uint32
-	OperUp     bool
-	RxBytes    uint64
-	TxBytes    uint64
-	RxErrors   uint64
-	TxErrors   uint64
+	OperUp        bool
+	RxBytes       uint64
+	TxBytes       uint64
+	RxErrors      uint64
+	TxErrors      uint64
 }
 
 func (p PortStats) SpeedString() string {

+ 11 - 11
server-go/internal/snmp/snmp_test.go

@@ -228,17 +228,17 @@ func TestIfFamilyClassification(t *testing.T) {
 		typ    int
 		family string
 	}{
-		{6, ""},          // ethernetCsmacd: física
-		{117, ""},        // gigabitEthernet: física
-		{161, "lag"},     // ieee8023adLag (LGS310C poN)
-		{136, "vlan"},    // l3ipvlan (LGS310C vlan1)
-		{135, "vlan"},    // l2vlan
-		{209, "bridge"},  // bridge
-		{131, "tunnel"},  // tunnel
-		{24, "virtual"},  // softwareLoopback
-		{53, "virtual"},  // propVirtual
-		{0, ""},          // sin ifType: físico (walk fallido conserva todo)
-		{9999, ""},       // desconocido: se trata como físico por exclusión
+		{6, ""},         // ethernetCsmacd: física
+		{117, ""},       // gigabitEthernet: física
+		{161, "lag"},    // ieee8023adLag (LGS310C poN)
+		{136, "vlan"},   // l3ipvlan (LGS310C vlan1)
+		{135, "vlan"},   // l2vlan
+		{209, "bridge"}, // bridge
+		{131, "tunnel"}, // tunnel
+		{24, "virtual"}, // softwareLoopback
+		{53, "virtual"}, // propVirtual
+		{0, ""},         // sin ifType: físico (walk fallido conserva todo)
+		{9999, ""},      // desconocido: se trata como físico por exclusión
 	}
 	for _, c := range cases {
 		if got := ifFamily(c.typ); got != c.family {

+ 1 - 1
server-go/internal/speedtest/http_runner_test.go

@@ -247,7 +247,7 @@ func TestExecuteUsaHTTPRunner(t *testing.T) {
 			}
 			return
 		}
-	time.Sleep(10 * time.Millisecond)
+		time.Sleep(10 * time.Millisecond)
 	}
 	t.Fatal("el test manual no persistio resultado")
 }

+ 3 - 3
server-go/internal/speedtest/ndt_runner_test.go

@@ -9,9 +9,9 @@ import (
 
 func TestNdtServerHost(t *testing.T) {
 	cases := map[string]string{
-		"":                            "",
-		"   ":                         "",
-		"ndt-mlab1-mad04.mlab-oti.org": "ndt-mlab1-mad04.mlab-oti.org",
+		"":                                      "",
+		"   ":                                   "",
+		"ndt-mlab1-mad04.mlab-oti.org":          "ndt-mlab1-mad04.mlab-oti.org",
 		"wss://ndt.example.com/ndt/v7/download": "ndt.example.com",
 		"ndt.example.com:4443":                  "ndt.example.com:4443",
 	}

+ 7 - 7
server-go/internal/telegram/telegram.go

@@ -20,13 +20,13 @@ const (
 	kvKeyChatID   = "telegram.chat_id"
 	kvKeyEnabled  = "telegram.enabled"
 
-	apiBase       = "https://api.telegram.org"
-	queueCap      = 64
-	maxRetries    = 3
-	baseRetry     = 2 * time.Second
-	sendTimeout   = 10 * time.Second
-	parseMode     = "HTML"
-	maxMsgLen     = 4096
+	apiBase     = "https://api.telegram.org"
+	queueCap    = 64
+	maxRetries  = 3
+	baseRetry   = 2 * time.Second
+	sendTimeout = 10 * time.Second
+	parseMode   = "HTML"
+	maxMsgLen   = 4096
 )
 
 type kvStore interface {

+ 5 - 5
server-go/internal/telegram/telegram_test.go

@@ -119,11 +119,11 @@ func TestCategoryEmoji(t *testing.T) {
 
 func TestHTMLEscape(t *testing.T) {
 	cases := map[string]string{
-		"hello":          "hello",
-		"<b>bold</b>":    "&lt;b&gt;bold&lt;/b&gt;",
-		"a & b":          "a &amp; b",
-		"no special":     "no special",
-		"<>&":            "&lt;&gt;&amp;",
+		"hello":       "hello",
+		"<b>bold</b>": "&lt;b&gt;bold&lt;/b&gt;",
+		"a & b":       "a &amp; b",
+		"no special":  "no special",
+		"<>&":         "&lt;&gt;&amp;",
 	}
 	for input, want := range cases {
 		got := htmlEscape(input)

+ 2 - 2
server-go/internal/updater/autosched_test.go

@@ -112,7 +112,7 @@ func TestSchedulerShotAppliesWhenDue(t *testing.T) {
 	_ = AutoUpdateSettings{Enabled: true, Kind: AutoDaily, Time: "03:30"}
 	s.shot(AutoUpdateSettings{}, autoRunState{})
 	if ua.applied.Load() != 1 {
-		t.Fatalf("debe aplicar: %d", ua.applied)
+		t.Fatalf("debe aplicar: %d", ua.applied.Load())
 	}
 	if _, res := AutoRunState(db); res != "applied" {
 		t.Fatalf("lastResult: %q", res)
@@ -178,6 +178,6 @@ func TestSchedulerTickMarksBeforeApply(t *testing.T) {
 		time.Sleep(10 * time.Millisecond)
 	}
 	if ua.applied.Load() != 1 {
-		t.Fatalf("tick con settings vencidos debe aplicar: %d", ua.applied)
+		t.Fatalf("tick con settings vencidos debe aplicar: %d", ua.applied.Load())
 	}
 }

+ 2 - 2
server-go/internal/wifisle/store.go

@@ -84,7 +84,7 @@ func (s *Store) Summary(routerID string, windowHours int) (*Summary, error) {
 		return nil, err
 	}
 	if dhcpReqs > 0 {
-		sc.DHCPSuccessPct = math.Round(float64(dhcpAcks) / float64(dhcpReqs) * 1000) / 10
+		sc.DHCPSuccessPct = math.Round(float64(dhcpAcks)/float64(dhcpReqs)*1000) / 10
 	} else {
 		sc.DHCPSuccessPct = 100
 	}
@@ -130,7 +130,7 @@ func (s *Store) Series(routerID string, from, to int64) ([]SLEReport, error) {
 			return nil, err
 		}
 		if r.DHCPRequests > 0 {
-			r.DHCPSuccessPct = math.Round(float64(r.DHCPAcks) / float64(r.DHCPRequests) * 1000) / 10
+			r.DHCPSuccessPct = math.Round(float64(r.DHCPAcks)/float64(r.DHCPRequests)*1000) / 10
 		} else {
 			r.DHCPSuccessPct = 100
 		}