Forráskód Böngészése

fix(ci): simplificar build de agentes para embed (sin loops ni vars de shell)

gnacho 4 hónapja
szülő
commit
0b655607a1
4 módosított fájl, 29 hozzáadás és 18 törlés
  1. 10 7
      .github/workflows/go.yml
  2. 10 7
      .github/workflows/release.yml
  3. 3 0
      web/app.js
  4. 6 4
      web/i18n.js

+ 10 - 7
.github/workflows/go.yml

@@ -48,14 +48,17 @@ jobs:
         run: go test ./...
 
       - name: Build agent binaries para embed (todas las arquitecturas)
+        env:
+          CGO_ENABLED: 0
+          GOOS: linux
         run: |
-          for target in amd64 arm64 armv7; do
-            goarch="$target"
-            goarm=""
-            if [ "$target" = "armv7" ]; then goarch="arm"; goarm="GOARM=7"; fi
-            echo "→ agente linux/$target"
-            (cd agent && CGO_ENABLED=0 GOOS=linux GOARCH=$goarch $goarm go build -trimpath -ldflags "-s -w" -o ../server-go/internal/agentbin/agents/netpulse-agent-$target ./cmd/netpulse-agent)
-          done
+          set -e
+          # amd64
+          GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o server-go/internal/agentbin/agents/netpulse-agent-amd64 ./agent/cmd/netpulse-agent
+          # arm64
+          GOARCH=arm64 go build -trimpath -ldflags "-s -w" -o server-go/internal/agentbin/agents/netpulse-agent-arm64 ./agent/cmd/netpulse-agent
+          # armv7
+          GOARCH=arm GOARM=7 go build -trimpath -ldflags "-s -w" -o server-go/internal/agentbin/agents/netpulse-agent-armv7 ./agent/cmd/netpulse-agent
 
       - name: Build binario (linux/${{ matrix.arch }})
         working-directory: server-go

+ 10 - 7
.github/workflows/release.yml

@@ -45,14 +45,17 @@ jobs:
           (cd collector && go test ./...)
 
       - name: Build agent binaries para embed (todas las arquitecturas)
+        env:
+          CGO_ENABLED: 0
+          GOOS: linux
         run: |
-          for target in amd64 arm64 armv7; do
-            goarch="$target"
-            goarm=""
-            if [ "$target" = "armv7" ]; then goarch="arm"; goarm="GOARM=7"; fi
-            echo "→ agente linux/$target"
-            (cd agent && CGO_ENABLED=0 GOOS=linux GOARCH=$goarch $goarm go build -trimpath -ldflags "-s -w" -o ../server-go/internal/agentbin/agents/netpulse-agent-$target ./cmd/netpulse-agent)
-          done
+          set -e
+          # amd64
+          GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o server-go/internal/agentbin/agents/netpulse-agent-amd64 ./agent/cmd/netpulse-agent
+          # arm64
+          GOARCH=arm64 go build -trimpath -ldflags "-s -w" -o server-go/internal/agentbin/agents/netpulse-agent-arm64 ./agent/cmd/netpulse-agent
+          # armv7
+          GOARCH=arm GOARM=7 go build -trimpath -ldflags "-s -w" -o server-go/internal/agentbin/agents/netpulse-agent-armv7 ./agent/cmd/netpulse-agent
 
       - name: Valida config goreleaser
         uses: goreleaser/goreleaser-action@v6

+ 3 - 0
web/app.js

@@ -360,6 +360,9 @@ let routersPlayed = false
 
 /* ===== datos demo canonicos (demo-canon.json, D65-1) ===== */
 const DEMO_WAN = {"plan":"600/600 Mbps","downMbps":84.2,"upMbps":12.6,"latencyMs":8,"lossPct":0,"publicIp":"84.122.x.x","isp":"Digi","peakTodayMbps":412,"peakTodayTime":"21:14","avgDownMbps":61,"total24h":"1,32 TB"}
+/* tráfico WAN por rango (mock.ts, canon) y AdGuard Home (demo-canon.json) */
+const DEMO_TRAFFIC = {"1h":[{"t":"21:30","down":68,"up":9},{"t":"21:33","down":74,"up":10},{"t":"21:36","down":81,"up":11},{"t":"21:39","down":92,"up":12},{"t":"21:42","down":88,"up":10},{"t":"21:45","down":96,"up":13},{"t":"21:48","down":104,"up":14},{"t":"21:51","down":98,"up":12},{"t":"21:54","down":90,"up":11},{"t":"21:57","down":86,"up":10},{"t":"22:00","down":82,"up":11},{"t":"22:03","down":78,"up":12},{"t":"22:06","down":84,"up":13},{"t":"22:09","down":91,"up":14},{"t":"22:12","down":88,"up":12},{"t":"22:15","down":84,"up":11},{"t":"22:18","down":80,"up":10},{"t":"22:21","down":83,"up":12},{"t":"22:24","down":86,"up":13},{"t":"22:27","down":84,"up":12.6}],"24h":[{"t":"00","down":42,"up":8},{"t":"01","down":28,"up":6},{"t":"02","down":15,"up":5},{"t":"03","down":9,"up":4},{"t":"04","down":7,"up":4},{"t":"05","down":8,"up":5},{"t":"06","down":14,"up":6},{"t":"07","down":32,"up":9},{"t":"08","down":58,"up":14},{"t":"09","down":74,"up":18},{"t":"10","down":88,"up":21},{"t":"11","down":96,"up":24},{"t":"12","down":112,"up":26},{"t":"13","down":124,"up":28},{"t":"14","down":118,"up":25},{"t":"15","down":132,"up":27},{"t":"16","down":148,"up":30},{"t":"17","down":176,"up":34},{"t":"18","down":224,"up":42},{"t":"19","down":298,"up":55},{"t":"20","down":356,"up":71},{"t":"21","down":412,"up":96},{"t":"22","down":284,"up":48},{"t":"23","down":122,"up":21}],"7d":[{"t":"Mon","down":61,"up":12},{"t":"Tue","down":58,"up":11},{"t":"Wed","down":64,"up":13},{"t":"Thu","down":71,"up":15},{"t":"Fri","down":88,"up":19},{"t":"Sat","down":96,"up":22},{"t":"Sun","down":84,"up":18}],"30d":[{"t":"1","down":54,"up":10},{"t":"4","down":58,"up":11},{"t":"7","down":62,"up":12},{"t":"10","down":57,"up":11},{"t":"13","down":66,"up":13},{"t":"16","down":72,"up":15},{"t":"19","down":68,"up":14},{"t":"22","down":75,"up":16},{"t":"25","down":81,"up":18},{"t":"28","down":78,"up":17},{"t":"30","down":84,"up":19}]}
+const DEMO_ADGUARD = {"blockedPct":18.6,"blocked24h":15687,"queries24h":84312,"trackersBlocked":9204,"dnsLatencyMs":14,"clientsUsing":60,"clientsTotal":65,"topBlocked":[{"domain":"graph.facebook.com","count":1204},{"domain":"adservice.google.com","count":986},{"domain":"metrics.icloud.com","count":731}]}
 const DEMO_WG = {
   interface: 'wg0', subnet: '10.0.0.1/24', status: 'active',
   peers: [

+ 6 - 4
web/i18n.js

@@ -64,7 +64,7 @@ const I18N = {
       st6t: 'Alerts that find you',
       st6p: 'Temperature spikes, new devices, firmware available, WireGuard handshakes — pushed to the bell and, with Web Push, to your phone.',
     },
-    health: { caption: 'Network health score', label: 'Excellent' },
+    health: { caption: 'Network health score', label: 'Excellent', note: 'Penalized by the Patio temperature.' },
     wan: { live: 'LIVE', title: 'WAN traffic', plan: 'plan' },
     topo: {
       wired: 'Wired', wifi: 'WiFi', tunnel: 'WG tunnel', gw: 'gateway', inet: 'Internet',
@@ -163,7 +163,7 @@ const I18N = {
       st6t: 'Alertas que te encuentran',
       st6p: 'Picos de temperatura, dispositivos nuevos, firmware disponible, handshakes de WireGuard — en la campana y, con Web Push, en tu móvil.',
     },
-    health: { caption: 'Puntuación de salud de la red', label: 'Excelente' },
+    health: { caption: 'Puntuación de salud de la red', label: 'Excelente', note: 'Penalizado por la temperatura del Patio.' },
     wan: { live: 'EN VIVO', title: 'Tráfico WAN', plan: 'plan' },
     topo: {
       wired: 'Cable', wifi: 'WiFi', tunnel: 'Túnel WG', gw: 'gateway', inet: 'Internet',
@@ -1021,7 +1021,7 @@ function detectLang() {
 
 let CURRENT = detectLang()
 
-function t(path) {
+function t(path, vars) {
   const seg = path.split('.')
   let o = I18N[CURRENT]
   for (const s of seg) { o = o ? o[s] : undefined }
@@ -1029,7 +1029,9 @@ function t(path) {
     o = I18N.en
     for (const s of seg) { o = o ? o[s] : undefined }
   }
-  return o ?? path
+  const out = o ?? path
+  if (vars) return out.replace(/\{(\w+)\}/g, (_, k) => vars[k] ?? `{${k}}`)
+  return out
 }
 
 /** Nombre localizado de un nodo del canon (routers/dispositivos/peers).