From 3d51aa455006903345f554a2dd90034993796114 Mon Sep 17 00:00:00 2001 From: sergei Date: Tue, 14 Apr 2026 06:23:55 +0400 Subject: vpnem: VPN infrastructure with load-balanced multi-protocol nodes - Multi-protocol VPS nodes (VLESS-REALITY + Hysteria2 + SOCKS5) - Smart load balancing via recommendation API - Windows/Linux client (Go + Wails + sing-box) - Server API with RealIP detection and connection tracking - Auto-deployment via vpnui control plane - Silent Windows installer with UAC elevation - Load-based server recommendation (no sticky sessions) - Best Server one-click connection workflow --- internal/control/preflight.go | 68 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 internal/control/preflight.go (limited to 'internal/control/preflight.go') diff --git a/internal/control/preflight.go b/internal/control/preflight.go new file mode 100644 index 0000000..44db7d0 --- /dev/null +++ b/internal/control/preflight.go @@ -0,0 +1,68 @@ +package control + +import "strings" + +func RenderPreflightInspectScript() string { + return `set -eu +if [ -r /etc/os-release ]; then + . /etc/os-release +fi +printf 'OS_ID=%s\n' "${ID:-}" +printf 'OS_PRETTY=%s\n' "${PRETTY_NAME:-}" +printf 'OS_LIKE=%s\n' "${ID_LIKE:-}" +if [ -d /opt/vpnem-node/current ]; then + printf 'MANAGED=1\n' +else + printf 'MANAGED=0\n' +fi +if command -v docker >/dev/null 2>&1; then + printf 'DOCKER=1\n' +else + printf 'DOCKER=0\n' +fi +if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then + printf 'COMPOSE=1\n' +elif command -v docker-compose >/dev/null 2>&1; then + printf 'COMPOSE=1\n' +else + printf 'COMPOSE=0\n' +fi +if command -v ss >/dev/null 2>&1; then + if ss -lnt 2>/dev/null | awk 'NR>1 {print $4}' | grep -Eq '(^|[:.])443$'; then + printf 'TCP_443=1\n' + else + printf 'TCP_443=0\n' + fi + if ss -lnu 2>/dev/null | awk 'NR>1 {print $4}' | grep -Eq '(^|[:.])443$'; then + printf 'UDP_443=1\n' + else + printf 'UDP_443=0\n' + fi + if ss -lnt 2>/dev/null | awk 'NR>1 {print $4}' | grep -Eq '(^|[:.])54101$'; then + printf 'TCP_54101=1\n' + else + printf 'TCP_54101=0\n' + fi +else + printf 'TCP_443=unknown\n' + printf 'UDP_443=unknown\n' + printf 'TCP_54101=unknown\n' +fi +` +} + +func ParsePreflightInspectOutput(stdout string) map[string]string { + values := map[string]string{} + for _, line := range strings.Split(stdout, "\n") { + line = strings.TrimSpace(line) + if line == "" { + continue + } + key, value, ok := strings.Cut(line, "=") + if !ok { + continue + } + values[strings.TrimSpace(key)] = strings.TrimSpace(value) + } + return values +} -- cgit v1.2.3