summaryrefslogtreecommitdiff
path: root/internal/control/preflight.go
diff options
context:
space:
mode:
authorsergei <sergei@em-sysadmin.xyz>2026-04-14 06:23:55 +0400
committersergei <sergei@em-sysadmin.xyz>2026-04-14 06:23:55 +0400
commit3d51aa455006903345f554a2dd90034993796114 (patch)
tree62a7be2faf047f5eb7886feebc3b815556f03d7f /internal/control/preflight.go
downloadvpnem-main.tar.gz
vpnem-main.tar.bz2
vpnem-main.zip
vpnem: VPN infrastructure with load-balanced multi-protocol nodesHEADmain
- 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
Diffstat (limited to 'internal/control/preflight.go')
-rw-r--r--internal/control/preflight.go68
1 files changed, 68 insertions, 0 deletions
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
+}