merge remote changes

This commit is contained in:
Reditus committed 2026-05-15 13:59:59 +01:00
1 parent 6161f36ea4
commit 9ddaa5f667
9 files changed
+125 -42

No files matched your search

+28 -9
View File
@@ -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)