merge remote changes
This commit is contained in:
1 parent
6161f36ea4
commit
9ddaa5f667
9 files changed
+125
-42
No files matched your search
@@ -23,6 +23,8 @@ DEFAULTS = {
|
||||
'ssl_key': None,
|
||||
'ssl_domain': None,
|
||||
'ssl_email': None,
|
||||
'http_redirect': False,
|
||||
'http_redirect_port': 80,
|
||||
},
|
||||
'database': {
|
||||
'host': '127.0.0.1',
|
||||
|
||||
+3
-3
@@ -73,10 +73,10 @@ def create_app(settings_path=None):
|
||||
# Content Security Policy
|
||||
response.headers['Content-Security-Policy'] = (
|
||||
"default-src 'self'; "
|
||||
"script-src 'self' 'unsafe-inline'; "
|
||||
"style-src 'self' 'unsafe-inline'; "
|
||||
"script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; "
|
||||
"style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; "
|
||||
"img-src 'self' data:; "
|
||||
"connect-src 'self' ws: wss:; "
|
||||
"connect-src 'self' ws: wss: https://cdn.jsdelivr.net; "
|
||||
"frame-ancestors 'self'; "
|
||||
"base-uri 'self'; "
|
||||
"form-action 'self'"
|
||||
|
||||
@@ -143,7 +143,7 @@ def register_websocket_handlers(socketio, settings):
|
||||
logger.error(f"Shell input error: {e}")
|
||||
|
||||
@socketio.on('shell_disconnect')
|
||||
def handle_shell_disconnect():
|
||||
def handle_shell_disconnect(data=None):
|
||||
shell_id = request.sid
|
||||
if shell_id in shell_processes:
|
||||
try:
|
||||
|
||||
@@ -39,7 +39,13 @@ if __name__ == '__main__':
|
||||
protocol = "http"
|
||||
|
||||
print(f"\n Dune Awakening Dashboard")
|
||||
print(f" {protocol}://{host}:{port}")
|
||||
print(f" Bind: {host}:{port}")
|
||||
if host == '0.0.0.0':
|
||||
print(f" Local: {protocol}://localhost:{port}")
|
||||
print(f" Local: {protocol}://127.0.0.1:{port}")
|
||||
print(f" Remote: {protocol}://<your-ip-or-domain>:{port}")
|
||||
else:
|
||||
print(f" URL: {protocol}://{host}:{port}")
|
||||
print(f" Debug: {debug}")
|
||||
|
||||
if debug and host not in ('127.0.0.1', 'localhost', '0.0.0.0'):
|
||||
@@ -61,14 +67,23 @@ if __name__ == '__main__':
|
||||
print(" [WARN] Binding to 0.0.0.0 without SSL! Credentials sent in cleartext.")
|
||||
print(" [WARN] DUNE_ALLOW_INSECURE_REMOTE is set - override is active\n")
|
||||
|
||||
# Start HTTP → HTTPS redirect server when SSL is enabled
|
||||
if ssl_context:
|
||||
# Start optional HTTP -> HTTPS redirect server when SSL is enabled.
|
||||
# This is convenience only; the dashboard works without port 80 if users visit https://host:port.
|
||||
if ssl_context and settings['dashboard'].get('http_redirect', False):
|
||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||
|
||||
class RedirectHandler(BaseHTTPRequestHandler):
|
||||
def _redirect_url(self):
|
||||
host_header = self.headers.get("Host", "localhost")
|
||||
redirect_host = host_header.rsplit(":", 1)[0] if ":" in host_header else host_header
|
||||
if not redirect_host or redirect_host == "0.0.0.0":
|
||||
redirect_host = "localhost"
|
||||
port_part = "" if int(port) == 443 else f":{port}"
|
||||
return f"https://{redirect_host}{port_part}{self.path}"
|
||||
|
||||
def do_GET(self):
|
||||
self.send_response(301)
|
||||
self.send_header('Location', f'https://{self.headers.get("Host", "localhost")}:{port}{self.path}')
|
||||
self.send_header('Location', self._redirect_url())
|
||||
self.end_headers()
|
||||
|
||||
def do_HEAD(self):
|
||||
@@ -80,11 +95,12 @@ if __name__ == '__main__':
|
||||
def log_message(self, format, *args):
|
||||
pass
|
||||
|
||||
# Try port 80 first, fall back to port+1
|
||||
# Try configured redirect port first, fall back to dashboard port+1.
|
||||
# Try 0.0.0.0 first (all interfaces), fall back to 127.0.0.1 (localhost only)
|
||||
http_port = None
|
||||
redirect_host = None
|
||||
for try_port in [80, port + 1]:
|
||||
redirect_port = int(settings['dashboard'].get('http_redirect_port', 80) or 80)
|
||||
for try_port in [redirect_port, port + 1]:
|
||||
for try_host in ['0.0.0.0', '127.0.0.1']:
|
||||
try:
|
||||
test_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
@@ -103,12 +119,15 @@ if __name__ == '__main__':
|
||||
redirect_server = HTTPServer((redirect_host, http_port), RedirectHandler)
|
||||
redirect_thread = threading.Thread(target=redirect_server.serve_forever, daemon=True)
|
||||
redirect_thread.start()
|
||||
print(f" HTTP redirect: http://0.0.0.0:{http_port} → https://{host}:{port}" if redirect_host == '0.0.0.0' else f" HTTP redirect: http://localhost:{http_port} → https://{host}:{port}")
|
||||
target_host = '<same-host>'
|
||||
print(f" HTTP redirect: http://0.0.0.0:{http_port} -> https://{target_host}:{port}" if redirect_host == '0.0.0.0' else f" HTTP redirect: http://localhost:{http_port} -> https://localhost:{port}")
|
||||
if http_port == 80:
|
||||
print(f" (visit http://localhost — auto redirects to https://)\n")
|
||||
print(f" (visit http://localhost to auto-redirect to HTTPS)\n")
|
||||
else:
|
||||
print(f" (visit http://localhost:{http_port} — auto redirects to https://)\n")
|
||||
print(f" (visit http://localhost:{http_port} to auto-redirect to HTTPS)\n")
|
||||
else:
|
||||
print(" [WARN] Could not start HTTP redirect server\n")
|
||||
elif ssl_context:
|
||||
print(" HTTP redirect: Disabled (visit the HTTPS URL directly)\n")
|
||||
|
||||
socketio.run(app, host=host, port=port, debug=debug, log_output=False, ssl_context=ssl_context)
|
||||
@@ -21,6 +21,8 @@ dashboard:
|
||||
ssl_key: null # Path to SSL key (null = HTTP only)
|
||||
ssl_domain: null # Domain for Let's Encrypt (e.g. dashboard.example.com)
|
||||
ssl_email: null # Email for Let's Encrypt notifications
|
||||
http_redirect: false # Optional HTTP -> HTTPS redirect listener
|
||||
http_redirect_port: 80 # Only needed if http_redirect is true
|
||||
# For Let's Encrypt or custom CA:
|
||||
# ssl_cert: /etc/letsencrypt/live/yourdomain/fullchain.pem
|
||||
# ssl_key: /etc/letsencrypt/live/yourdomain/privkey.pem
|
||||
|
||||
@@ -498,14 +498,55 @@ if (-not $UseLetsEncrypt) {
|
||||
$SslKey = "'$LeKeyPath'"
|
||||
}
|
||||
|
||||
# Firewall rules for HTTP redirect (port 80) and HTTPS dashboard
|
||||
# Remote access
|
||||
Write-Host ""
|
||||
Write-Host " Windows Firewall needs to allow incoming connections on ports 80 and $DashboardPort" -ForegroundColor Cyan
|
||||
Write-Host " for remote access to work. This requires Administrator privileges." -ForegroundColor Cyan
|
||||
$RemoteAccess = Read-Host " Enable remote access? (y/N)"
|
||||
$EnableRemote = ($RemoteAccess -eq 'y' -or $RemoteAccess -eq 'Y')
|
||||
|
||||
if ($EnableRemote) {
|
||||
$DashHost = "0.0.0.0"
|
||||
Write-Host " Remote access enabled. The dashboard will bind to 0.0.0.0 so localhost, 127.0.0.1, LAN IP, and public IP can all work." -ForegroundColor Green
|
||||
Write-Host " Dedicated server: allow TCP $DashboardPort in Windows Firewall/cloud firewall." -ForegroundColor Cyan
|
||||
Write-Host " Home network: port-forward TCP $DashboardPort from your router to this machine's LAN IP." -ForegroundColor Cyan
|
||||
} else {
|
||||
$DashHost = "127.0.0.1"
|
||||
Write-Host " Local-only access enabled. Use http(s)://localhost:$DashboardPort or http(s)://127.0.0.1:$DashboardPort." -ForegroundColor Green
|
||||
}
|
||||
|
||||
$HttpRedirect = $false
|
||||
$HttpRedirectPort = 80
|
||||
if ($EnableRemote -and ($SslCert -ne "null") -and ($SslKey -ne "null")) {
|
||||
Write-Host ""
|
||||
Write-Host " Optional HTTP to HTTPS redirect:" -ForegroundColor Cyan
|
||||
Write-Host " - Not required if you visit https://HOST:$DashboardPort directly." -ForegroundColor Cyan
|
||||
Write-Host " - Useful if you want http://HOST to redirect automatically." -ForegroundColor Cyan
|
||||
Write-Host " - Requires TCP port 80 to be free and forwarded/open." -ForegroundColor Cyan
|
||||
$RedirectAnswer = Read-Host " Enable HTTP redirect on port 80? (y/N)"
|
||||
$HttpRedirect = ($RedirectAnswer -eq 'y' -or $RedirectAnswer -eq 'Y')
|
||||
}
|
||||
|
||||
# Firewall rules for optional HTTP redirect and dashboard port
|
||||
Write-Host ""
|
||||
$SetupFirewall = Read-Host " Create firewall rules? (Y/n)"
|
||||
if ($EnableRemote) {
|
||||
$FirewallPorts = @($DashboardPort)
|
||||
if ($HttpRedirect) { $FirewallPorts = @(80) + $FirewallPorts }
|
||||
$FirewallPortList = ($FirewallPorts -join ',')
|
||||
Write-Host " Windows Firewall needs to allow incoming TCP port(s): $FirewallPortList" -ForegroundColor Cyan
|
||||
Write-Host " This requires Administrator privileges." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
} else {
|
||||
$FirewallPorts = @()
|
||||
$FirewallPortList = ""
|
||||
Write-Host " Skipping Windows Firewall rules because remote access is disabled." -ForegroundColor Cyan
|
||||
}
|
||||
Write-Host ""
|
||||
if ($EnableRemote) {
|
||||
$SetupFirewall = Read-Host " Create firewall rules? (Y/n)"
|
||||
} else {
|
||||
$SetupFirewall = "n"
|
||||
}
|
||||
if ($SetupFirewall -eq 'n' -or $SetupFirewall -eq 'N') {
|
||||
Write-Host " Skipped. Remote access may be blocked by firewall." -ForegroundColor Yellow
|
||||
if ($EnableRemote) { Write-Host " Skipped. Remote access may be blocked by firewall." -ForegroundColor Yellow }
|
||||
} else {
|
||||
$fwRuleName = "DuneDashboard"
|
||||
$fwExists = $null
|
||||
@@ -516,12 +557,12 @@ if ($SetupFirewall -eq 'n' -or $SetupFirewall -eq 'N') {
|
||||
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
if (-not $isAdmin) {
|
||||
Write-Host " Starting elevated PowerShell to add firewall rules..." -ForegroundColor Yellow
|
||||
$fwScript = "New-NetFirewallRule -DisplayName DuneDashboard -Direction Inbound -Action Allow -Protocol TCP -LocalPort 80,$DashboardPort; Write-Host ''; Read-Host 'Press Enter to close'"
|
||||
$fwScript = "New-NetFirewallRule -DisplayName DuneDashboard -Direction Inbound -Action Allow -Protocol TCP -LocalPort $FirewallPortList; Write-Host ''; Read-Host 'Press Enter to close'"
|
||||
Start-Process powershell -ArgumentList "-NoProfile", "-Command", $fwScript -Verb RunAs -Wait
|
||||
Write-Host " Firewall rules added." -ForegroundColor Green
|
||||
} else {
|
||||
New-NetFirewallRule -DisplayName DuneDashboard -Direction Inbound -Action Allow -Protocol TCP -LocalPort 80, $DashboardPort
|
||||
Write-Host " Firewall rules added for ports 80 (HTTP redirect) and $DashboardPort (HTTPS)." -ForegroundColor Green
|
||||
New-NetFirewallRule -DisplayName DuneDashboard -Direction Inbound -Action Allow -Protocol TCP -LocalPort $FirewallPorts
|
||||
Write-Host " Firewall rules added for TCP port(s): $FirewallPortList." -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -543,18 +584,6 @@ if ($UseLetsEncrypt) {
|
||||
}
|
||||
}
|
||||
|
||||
# Remote access
|
||||
Write-Host ""
|
||||
$RemoteAccess = Read-Host " Enable remote access? (y/N)"
|
||||
$EnableRemote = ($RemoteAccess -eq 'y' -or $RemoteAccess -eq 'Y')
|
||||
|
||||
if ($EnableRemote) {
|
||||
$DashHost = "0.0.0.0"
|
||||
Write-Host " Remote access enabled with HTTPS" -ForegroundColor Green
|
||||
} else {
|
||||
$DashHost = "127.0.0.1"
|
||||
}
|
||||
|
||||
# Firewall security hardening
|
||||
Write-Host ""
|
||||
Write-Host "[SECURITY] Firewall Hardening" -ForegroundColor Cyan
|
||||
@@ -636,6 +665,8 @@ dashboard:
|
||||
ssl_key: $SslKey
|
||||
ssl_domain: $leDomain
|
||||
ssl_email: $leEmail
|
||||
http_redirect: $HttpRedirect
|
||||
http_redirect_port: $HttpRedirectPort
|
||||
|
||||
database:
|
||||
host: 127.0.0.1
|
||||
|
||||
@@ -344,9 +344,26 @@ ENABLE_REMOTE=false
|
||||
|
||||
if [[ "$REMOTE_ANSWER" == "y" || "$REMOTE_ANSWER" == "Y" ]]; then
|
||||
DASH_HOST="0.0.0.0"
|
||||
echo " Remote access enabled with HTTPS"
|
||||
echo " Remote access enabled. The dashboard will bind to 0.0.0.0 so localhost, 127.0.0.1, LAN IP, and public IP can all work."
|
||||
echo " Dedicated server: allow TCP $DASHBOARD_PORT in the host/cloud firewall."
|
||||
echo " Home network: port-forward TCP $DASHBOARD_PORT from your router to this machine's LAN IP."
|
||||
else
|
||||
DASH_HOST="127.0.0.1"
|
||||
echo " Local-only access enabled. Use http(s)://localhost:$DASHBOARD_PORT or http(s)://127.0.0.1:$DASHBOARD_PORT."
|
||||
fi
|
||||
|
||||
HTTP_REDIRECT=false
|
||||
HTTP_REDIRECT_PORT=80
|
||||
if [ "$ENABLE_REMOTE" = true ] && [ "$SSL_CERT" != "null" ] && [ "$SSL_KEY" != "null" ]; then
|
||||
echo ""
|
||||
echo " Optional HTTP to HTTPS redirect:"
|
||||
echo " - Not required if you visit https://HOST:$DASHBOARD_PORT directly."
|
||||
echo " - Useful if you want http://HOST to redirect automatically."
|
||||
echo " - Requires TCP port 80 to be free and forwarded/open."
|
||||
read -rp " Enable HTTP redirect on port 80? (y/N): " REDIRECT_ANSWER
|
||||
if [[ "$REDIRECT_ANSWER" == "y" || "$REDIRECT_ANSWER" == "Y" ]]; then
|
||||
HTTP_REDIRECT=true
|
||||
fi
|
||||
fi
|
||||
|
||||
# Let's Encrypt auto-renewal via cron
|
||||
@@ -412,6 +429,8 @@ dashboard:
|
||||
ssl_key: $SSL_KEY
|
||||
ssl_domain: $LE_DOMAIN_YAML
|
||||
ssl_email: $LE_EMAIL_YAML
|
||||
http_redirect: $HTTP_REDIRECT
|
||||
http_redirect_port: $HTTP_REDIRECT_PORT
|
||||
|
||||
database:
|
||||
host: 127.0.0.1
|
||||
|
||||
@@ -225,21 +225,31 @@ Write-Host "[OK] Database connected" -ForegroundColor Green
|
||||
$fwRuleName = "DuneDashboard"
|
||||
$fwExists = $null
|
||||
try { $fwExists = Get-NetFirewallRule -DisplayName $fwRuleName -ErrorAction SilentlyContinue } catch {}
|
||||
if (-not $fwExists) {
|
||||
$remoteDashboard = "$($settings.dashboard.host)" -eq "0.0.0.0"
|
||||
if ($remoteDashboard -and -not $fwExists) {
|
||||
Write-Host "[WARN] No firewall rule found. Remote access to the dashboard will be blocked." -ForegroundColor Yellow
|
||||
Write-Host " Ports needed: 80 (HTTP redirect), $DashboardPort (HTTPS)" -ForegroundColor Yellow
|
||||
$redirectEnabled = $settings.dashboard.http_redirect -eq $true
|
||||
if ($redirectEnabled) {
|
||||
$redirectPort = if ($settings.dashboard.http_redirect_port) { $settings.dashboard.http_redirect_port } else { 80 }
|
||||
Write-Host " Ports needed: $redirectPort (optional HTTP redirect), $DashboardPort (dashboard)" -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host " Port needed: $DashboardPort (dashboard)" -ForegroundColor Yellow
|
||||
}
|
||||
Write-Host ""
|
||||
$SetupFirewall = Read-Host " Create firewall rules now? Requires Administrator (Y/n)"
|
||||
if ($SetupFirewall -ne 'n' -and $SetupFirewall -ne 'N') {
|
||||
$firewallPorts = @($DashboardPort)
|
||||
if ($redirectEnabled) { $firewallPorts = @($redirectPort) + $firewallPorts }
|
||||
$firewallPortList = ($firewallPorts -join ',')
|
||||
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
if (-not $isAdmin) {
|
||||
Write-Host " Starting elevated PowerShell to add firewall rules..." -ForegroundColor Yellow
|
||||
$fwScript = "New-NetFirewallRule -DisplayName DuneDashboard -Direction Inbound -Action Allow -Protocol TCP -LocalPort 80,$DashboardPort; Write-Host ''; Read-Host 'Press Enter to close'"
|
||||
$fwScript = "New-NetFirewallRule -DisplayName DuneDashboard -Direction Inbound -Action Allow -Protocol TCP -LocalPort $firewallPortList; Write-Host ''; Read-Host 'Press Enter to close'"
|
||||
Start-Process powershell -ArgumentList "-NoProfile", "-Command", $fwScript -Verb RunAs -Wait
|
||||
Write-Host "[OK] Firewall rules added." -ForegroundColor Green
|
||||
} else {
|
||||
New-NetFirewallRule -DisplayName DuneDashboard -Direction Inbound -Action Allow -Protocol TCP -LocalPort 80, $DashboardPort
|
||||
Write-Host "[OK] Firewall rules added for ports 80, $DashboardPort." -ForegroundColor Green
|
||||
New-NetFirewallRule -DisplayName DuneDashboard -Direction Inbound -Action Allow -Protocol TCP -LocalPort $firewallPorts
|
||||
Write-Host "[OK] Firewall rules added for port(s): $firewallPortList." -ForegroundColor Green
|
||||
}
|
||||
} else {
|
||||
Write-Host " Skipped. External access will be blocked." -ForegroundColor Yellow
|
||||
@@ -260,4 +270,4 @@ python run.py
|
||||
Write-Host "Stopping tunnels..." -ForegroundColor Cyan
|
||||
Stop-Process -Id $sshTunnel.Id -Force -ErrorAction SilentlyContinue
|
||||
$pkillCmd = 'ssh -i "' + $SSHKey + '" -o StrictHostKeyChecking=accept-new ' + $SSHUser + '@' + $ServerHost + ' "pkill -f kubectl-port-forward"'
|
||||
cmd /c $pkillCmd 2>$null
|
||||
cmd /c $pkillCmd 2>$null
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class="card">
|
||||
<div class="card-header" style="display:flex;justify-content:space-between;align-items:center;">
|
||||
<span>VM Shell</span>
|
||||
<button id="btn-shell-vm" onclick="toggleShell('vm')" style="padding:4px 12px;background:var(--primary);color:#fff;border:none;border-radius:4px;cursor:pointer;">Connect</button>
|
||||
<button id="btn-shell-vm" onclick="toggleShell('vm')" style="padding:4px 12px;background:var(--primary);color:#fff;border:none;border-radius:4px;cursor:pointer;position:relative;z-index:10;">Connect</button>
|
||||
</div>
|
||||
<div id="terminal-vm" style="height:300px;background:#1a1a1a;padding:10px;font-family:monospace;font-size:12px;overflow:auto;"></div>
|
||||
</div>
|
||||
@@ -28,7 +28,7 @@
|
||||
<option value="{{ pod.name }}">{{ pod.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button id="btn-shell-pod" onclick="toggleShell('pod')" style="padding:4px 12px;background:var(--primary);color:#fff;border:none;border-radius:4px;cursor:pointer;">Connect</button>
|
||||
<button id="btn-shell-pod" onclick="toggleShell('pod')" style="padding:4px 12px;background:var(--primary);color:#fff;border:none;border-radius:4px;cursor:pointer;position:relative;z-index:10;">Connect</button>
|
||||
</div>
|
||||
<div id="terminal-pod" style="height:300px;background:#1a1a1a;padding:10px;font-family:monospace;font-size:12px;overflow:auto;"></div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user