// Engineering-only UI fixture: uses the production API and isolated storage. // No fixture is linked into cmd/node-agent or installed by the Debian package. package main import ( "bytes" "io/fs" "log" "net/http" "os" "path/filepath" "time" "nodedc.local/mission-core/node-agent/internal/node" "nodedc.local/mission-core/node-agent/web" ) func main() { dir := "/private/tmp/mc-node-ui-032-qa" store, err := node.OpenStore(dir); if err != nil { log.Fatal(err) } assets, _ := fs.Sub(web.Assets, "dist") memory, available := uint64(8388608), uint64(5242880) app := &node.Server{Store: store, Assets: assets, Origin: "http://127.0.0.1:8780", Version: "0.3.2-qa", Inventory: func() node.Inventory { inventory := node.Inventory{CollectedAt: time.Now().UTC().Format(time.RFC3339), Hostname:"qa-board", OS:"Ubuntu 24.04.4 LTS", Architecture:"amd64", CPUs:8, MemoryKiB:&memory, AvailableKiB:&available, NetworksReadable:true, Networks: []node.Network{{Name:"ethernet-qa", Up:true, AddressesReadable:true, Addresses:[]string{"192.0.2.10/24"}}}, USB:[]node.USB{{Port:"2-1", Vendor:"8086", ProductID:"0b5c", Product:"Intel RealSense D455 · QA", Speed:"5000"}}, USBReadable:true, Warnings:[]string{}} if _, err := os.Stat(filepath.Join(dir,"network-unavailable")); err == nil { inventory.NetworksReadable=false; inventory.Networks=[]node.Network{}; inventory.Warnings=[]string{"Не удалось прочитать сетевые интерфейсы"} } return inventory }, Access: &node.AccessStore{Path:filepath.Join(dir,"ssh-keys.json"), Users:func()[]string{return []string{"operator"}}}, Tailscale:func()node.TailscaleStatus { if _, err := os.Stat(filepath.Join(dir,"offline")); err == nil { return node.TailscaleStatus{Installed:true, State:"unavailable", Addresses:[]string{}} } return node.TailscaleStatus{Installed:true, State:"Running", Online:true, Addresses:[]string{"100.64.0.10"}} }} if err := os.WriteFile(filepath.Join(dir,"login-url"),[]byte(app.IssueLogin()),0600); err != nil {log.Fatal(err)} handler := app.Handler() http.HandleFunc("/",func(w http.ResponseWriter,r *http.Request){ if r.URL.Path == "/qa-bridge.js" { w.Header().Set("Content-Type","application/javascript"); _,_ = w.Write([]byte(`window.missionCoreDesktop={networkSetup:true};`)); return } if r.URL.Path == "/" { b,_:=fs.ReadFile(assets,"index.html"); b=bytes.Replace(b,[]byte(""),[]byte(``),1); w.Header().Set("Content-Type","text/html"); _,_=w.Write(b); return } handler.ServeHTTP(w,r) }) log.Print("isolated Node UI QA: 127.0.0.1:8780") log.Fatal(http.ListenAndServe("127.0.0.1:8780",nil)) }