diff --git a/app/factory.py b/app/factory.py index cbdd9cc..bcddf2b 100644 --- a/app/factory.py +++ b/app/factory.py @@ -24,6 +24,7 @@ from app.services.chat import ChatService from app.services.admin import AdminService from app.services.updater import UpdateService from app.services.director import DirectorService +from app.services.rmq import RmqService from app.utils.cache import MultiCache from app.routes.main import register_routes from app.routes.api import register_api_routes @@ -45,6 +46,7 @@ def create_app(settings_path=None): app.config['SECRET_KEY'] = settings['dashboard']['secret_key'] app.config['SESSION_COOKIE_HTTPONLY'] = True app.config['SESSION_COOKIE_SAMESITE'] = 'Lax' + app.config['PERMANENT_SESSION_LIFETIME'] = 28800 # 8 hours app.config['WTF_CSRF_ENABLED'] = True app.config['WTF_CSRF_TIME_LIMIT'] = None @@ -58,7 +60,6 @@ def create_app(settings_path=None): and settings['dashboard']['ssl_key'] != 'null' ) - # Set SESSION_COOKIE_SECURE conditional on SSL being enabled app.config['SESSION_COOKIE_SECURE'] = ssl_enabled # Add security headers manually (replaces deprecated Flask-Talisman) @@ -252,6 +253,13 @@ def create_app(settings_path=None): namespace=settings['kubernetes']['namespace'], ) logging.debug(f"DirectorService initialized: port={settings.get('director', {}).get('port', 32479)}") + rmq_svc = RmqService( + admin_port=settings.get('rabbitmq', {}).get('admin_port', 30325), + game_port=settings.get('rabbitmq', {}).get('game_port', 32716), + username=settings.get('rabbitmq', {}).get('username', 'dashboard_admin'), + password=settings.get('rabbitmq', {}).get('password', ''), + ) + logging.debug(f"RmqService initialized: admin=localhost:{settings.get('rabbitmq', {}).get('admin_port', 30325)} game=localhost:{settings.get('rabbitmq', {}).get('game_port', 32716)}") services = { 'db': db_service, @@ -265,6 +273,7 @@ def create_app(settings_path=None): 'static_cache': static_cache, 'updater': updater_svc, 'director': director_svc, + 'rmq': rmq_svc, } logging.debug(f"All services registered: {list(services.keys())}") @@ -284,7 +293,7 @@ def create_app(settings_path=None): limiter = Limiter( app=app, key_func=get_remote_address, - default_limits=[], + default_limits=["200 per day", "50 per hour"], storage_uri="memory://", ) app.limiter = limiter @@ -292,16 +301,6 @@ def create_app(settings_path=None): if settings['auth']['enabled']: init_auth(app, settings, limiter, audit_svc) - # Auto-login for SPA frontend — bypasses login page - from flask_login import login_user - from app.routes.auth import AdminUser - - @app.before_request - def auto_login_dev(): - if not current_user.is_authenticated: - cfg_user = str(settings.get("auth", {}).get("username", "dune")) - login_user(AdminUser(cfg_user)) - register_routes(app, services, settings) register_api_routes(app, services, settings) register_websocket_handlers(socketio, settings) diff --git a/app/routes/api.py b/app/routes/api.py index 63c516b..6997b79 100644 --- a/app/routes/api.py +++ b/app/routes/api.py @@ -1732,6 +1732,118 @@ def register_api_routes(app, services, settings): except Exception as e: return jsonify({'success': False, 'error': str(e)}) + # ── Admin Experimental: RMQ Explorer ───────────────────────────── + @app.route('/api/admin-experimental/rmq/overview') + @auth_req + def admin_rmq_overview(): + try: + rmq = services.get('rmq') + if not rmq: + return jsonify({'success': False, 'error': 'RMQ service not available'}), 503 + data = rmq.combined_overview() + return jsonify({'success': True, 'data': data}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}) + + @app.route('/api/admin-experimental/rmq/queues') + @auth_req + def admin_rmq_queues(): + try: + rmq = services.get('rmq') + if not rmq: + return jsonify({'success': False, 'error': 'RMQ service not available'}), 503 + data = rmq.combined_queues() + return jsonify({'success': True, 'data': data}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}) + + @app.route('/api/admin-experimental/rmq/exchanges') + @auth_req + def admin_rmq_exchanges(): + try: + rmq = services.get('rmq') + if not rmq: + return jsonify({'success': False, 'error': 'RMQ service not available'}), 503 + data = rmq.combined_exchanges() + return jsonify({'success': True, 'data': data}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}) + + @app.route('/api/admin-experimental/rmq/bindings') + @auth_req + def admin_rmq_bindings(): + try: + rmq = services.get('rmq') + if not rmq: + return jsonify({'success': False, 'error': 'RMQ service not available'}), 503 + data = rmq.bindings() + return jsonify({'success': True, 'data': data}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}) + + @app.route('/api/admin-experimental/rmq/consumers') + @auth_req + def admin_rmq_consumers(): + try: + rmq = services.get('rmq') + if not rmq: + return jsonify({'success': False, 'error': 'RMQ service not available'}), 503 + data = rmq.consumers() + return jsonify({'success': True, 'data': data}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}) + + @app.route('/api/admin-experimental/rmq/peek', methods=['POST']) + @auth_req + def admin_rmq_peek(): + try: + rmq = services.get('rmq') + if not rmq: + return jsonify({'success': False, 'error': 'RMQ service not available'}), 503 + cfg = request.get_json() or {} + queue_name = cfg.get('queue', '') + count = int(cfg.get('count', 5)) + if not queue_name: + return jsonify({'success': False, 'error': 'queue name required'}), 400 + data = rmq.peek_messages(queue_name, count=count) + return jsonify({'success': True, 'data': data}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}) + + @app.route('/api/admin-experimental/rmq/publish', methods=['POST']) + @auth_req + def admin_rmq_publish(): + try: + rmq = services.get('rmq') + if not rmq: + return jsonify({'success': False, 'error': 'RMQ service not available'}), 503 + cfg = request.get_json() or {} + exchange = cfg.get('exchange', '') + routing_key = cfg.get('routing_key', '') + message = cfg.get('message', '') + side = cfg.get('side', 'admin') + if not exchange: + return jsonify({'success': False, 'error': 'exchange name required'}), 400 + if side == 'game': + result = rmq.game_publish(exchange, routing_key, message) + else: + result = rmq.publish(exchange, routing_key, message) + return jsonify({'success': True, 'data': result}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}) + + @app.route('/api/admin-experimental/rmq/health') + @auth_req + def admin_rmq_health(): + try: + rmq = services.get('rmq') + if not rmq: + return jsonify({'success': False, 'error': 'RMQ service not available'}), 503 + data = rmq.health() + return jsonify({'success': True, 'data': data}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}) + # ── Admin Experimental: Function Explorer ───────────────────────── @app.route('/api/admin-experimental/functions', methods=['GET']) @auth_req diff --git a/app/routes/auth.py b/app/routes/auth.py index caecd21..ccd48e3 100644 --- a/app/routes/auth.py +++ b/app/routes/auth.py @@ -2,7 +2,7 @@ import time import threading -from flask import render_template, request, redirect, url_for, flash +from flask import render_template, request, redirect, url_for, flash, session, make_response from flask_login import LoginManager, UserMixin, login_user, logout_user, login_required, current_user from flask_limiter import Limiter from flask_limiter.util import get_remote_address @@ -14,6 +14,15 @@ login_manager.login_message = 'Please log in.' # In-memory failed login tracker: {ip: {"count": int, "first_attempt": float}} _failed_attempts = {} _failed_lock = threading.Lock() + +# Reusable Argon2 verifier (created once, not per-request) +try: + from argon2 import PasswordHasher, exceptions as argon2_exceptions + _password_hasher = PasswordHasher(time_cost=3, memory_cost=65536) +except ImportError: + _password_hasher = None + argon2_exceptions = None +_failed_lock = threading.Lock() _MAX_FAILED_ATTEMPTS = 5 _BLOCK_DURATION = 900 # 15 minutes @@ -82,39 +91,41 @@ def init_auth(app, settings, limiter=None, audit_svc=None): u = request.form.get('username', '') p = request.form.get('password', '') auth = settings.get('auth', {}) - cfg_u = str(auth.get('username', '')) password_hash = auth.get('password_hash') - if u != cfg_u: - if audit_svc: - audit_svc.log('login_failed', {'username': u, 'reason': 'invalid_username'}, user='unknown', severity='warning') + if not password_hash: + flash('Authentication not configured. Please run setup.') + return render_template('login.html') + + try: + # Always run Argon2 verify regardless of username (prevents timing enumeration) + from argon2 import exceptions + _DUMMY = '$argon2id$v=19$m=65536,t=3,p=4$AAAAAAAAAAAAAAAAAAAAAA$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + hash_to_verify = password_hash if u == cfg_u else _DUMMY + verified = _password_hasher.verify(hash_to_verify, p) + + if verified and u == cfg_u: + _clear_failed_attempts(client_ip) + login_user(AdminUser(u)) + if audit_svc: + audit_svc.log('login_success', {'username': u}, user=u, severity='info') + return redirect(url_for('overview')) + else: + # Dummy always fails; wrong password also fails here + _record_failed_attempt(client_ip) + if u == cfg_u and audit_svc: + audit_svc.log('login_failed', {'username': u, 'reason': 'invalid_password'}, user=u, severity='warning') + elif audit_svc: + audit_svc.log('login_failed', {'username': u, 'reason': 'invalid_credentials'}, user='unknown', severity='warning') + flash('Invalid username or password') + return render_template('login.html') + except exceptions.VerifyMismatchError: _record_failed_attempt(client_ip) flash('Invalid username or password') return render_template('login.html') - - if password_hash: - try: - from argon2 import PasswordHasher, exceptions - ph = PasswordHasher(time_cost=3, memory_cost=65536) - if ph.verify(password_hash, p): - _clear_failed_attempts(client_ip) - login_user(AdminUser(u)) - if audit_svc: - audit_svc.log('login_success', {'username': u}, user=u, severity='info') - return redirect(url_for('overview')) - else: - if audit_svc: - audit_svc.log('login_failed', {'username': u, 'reason': 'invalid_password'}, user=u, severity='warning') - except exceptions.VerifyMismatchError: - if audit_svc: - audit_svc.log('login_failed', {'username': u, 'reason': 'invalid_password'}, user=u, severity='warning') - pass - except Exception: - flash('Authentication error. Please try again.') - return render_template('login.html') - else: - flash('Authentication not configured. Please run setup.') + except Exception as e: + flash('Authentication error. Please try again.') return render_template('login.html') _record_failed_attempt(client_ip) @@ -123,10 +134,13 @@ def init_auth(app, settings, limiter=None, audit_svc=None): return render_template('login.html') @app.route('/logout') - @login_required def logout(): user = current_user.id if current_user.is_authenticated else 'unknown' logout_user() + session.clear() if audit_svc: audit_svc.log('logout', {}, user=user, severity='info') - return redirect(url_for('login')) + resp = make_response(redirect(url_for('login'))) + resp.delete_cookie('session') + resp.delete_cookie('remember_token') + return resp diff --git a/app/routes/main.py b/app/routes/main.py index d06320e..e54a301 100644 --- a/app/routes/main.py +++ b/app/routes/main.py @@ -6,6 +6,7 @@ from flask import Blueprint, render_template, request, jsonify from flask_login import login_required, current_user from app.utils.constants import NAV_PAGES, GUILD_ROLES from app.utils.debug_logging import sanitize_for_log +from app.services.player import LIKE_PC logger = logging.getLogger(__name__) @@ -326,20 +327,32 @@ def register_routes(app, services, settings): try: buildings_list = db.query(""" SELECT a.id, a.class, a.map, a.transform::text as transform_text, - COALESCE(NULLIF(ps.character_name, ''), NULLIF(ea.platform_name, ''), 'ID:' || b.owner_id::text) as owner_name, + COALESCE(NULLIF(owner.character_name, ''), 'Base ' || b.id::text) as owner_name, (SELECT COUNT(*)::int FROM dune.building_instances bi WHERE bi.building_id = b.id) as instance_count, a.properties->>'m_bIsPowered' as is_powered, a.properties->>'m_PowerLevel' as power_level, a.properties->'PowerComponent'->>'m_PowerGridID' as power_grid_id FROM dune.buildings b JOIN dune.actors a ON b.id = a.id - LEFT JOIN dune.player_state ps ON b.owner_id = ps.player_pawn_id - LEFT JOIN dune.encrypted_accounts ea ON ea.id = ( - SELECT ps2.account_id FROM dune.player_state ps2 WHERE ps2.player_pawn_id = b.owner_id LIMIT 1 - ) + LEFT JOIN LATERAL ( + SELECT DISTINCT afe_totem.actor_id as totem_actor_id + FROM dune.building_instances bi + JOIN dune.actor_fgl_entities afe_totem ON afe_totem.entity_id = bi.owner_entity_id + WHERE bi.building_id = b.id + LIMIT 1 + ) totem ON true + LEFT JOIN LATERAL ( + SELECT ps.character_name + FROM dune.actors pawn + JOIN dune.player_state ps ON pawn.id = ps.player_pawn_id + WHERE pawn.id BETWEEN totem.totem_actor_id - 6 AND totem.totem_actor_id - 1 + AND pawn.class LIKE %s + ORDER BY totem.totem_actor_id - pawn.id + LIMIT 1 + ) owner ON true ORDER BY owner_name LIMIT 200 - """) or [] + """, [LIKE_PC]) or [] return render_template('buildings.html', buildings=buildings_list) except Exception as e: logger.exception("Error in buildings route") @@ -552,7 +565,7 @@ def register_routes(app, services, settings): name: cfg for name, cfg in map_config.items() if isinstance(cfg, dict) and cfg.get('image') and cfg.get('bounds') } - default_map = map_config.get('default_map', 'DeepDesert') + default_map = map_config.get('default_map', 'HaggaBasin') return map_config, configured_maps, default_map @@ -563,6 +576,7 @@ def register_routes(app, services, settings): map_options = [] for key, cfg in configured_maps.items(): image_size = cfg.get('image_size', {}) + bounds = cfg.get('bounds', {}) map_options.append({ 'key': key, 'label': cfg.get('label') or key, @@ -570,6 +584,7 @@ def register_routes(app, services, settings): 'width': image_size.get('width', 1000), 'height': image_size.get('height', 1000), 'default_zoom': cfg.get('default_zoom', 0.5), + 'bounds': bounds, 'counts': { 'players': sum(1 for p in player_locations if p.get('map') == key and p.get('in_bounds')), 'vehicles': sum(1 for v in vehicle_locations if v.get('map') == key and v.get('in_bounds')), @@ -597,27 +612,43 @@ def register_routes(app, services, settings): # Get vehicles with coordinates for configured map assets vehicles = db.query(""" - SELECT v.id, a.map, a.transform, a.class + SELECT DISTINCT ON (v.id) + v.id, a.map, a.transform, a.class, + COALESCE(NULLIF(ps.character_name, ''), 'Vehicle ' || v.id::text) as owner_name FROM dune.vehicles v JOIN dune.actors a ON v.id = a.id + LEFT JOIN dune.permission_actor_rank par ON par.permission_actor_id = v.id + LEFT JOIN dune.player_state ps ON par.player_id = ps.player_controller_id WHERE a.transform IS NOT NULL AND a.map = ANY(%s) - ORDER BY a.map, a.class + ORDER BY v.id, par.rank ASC """, [selected_map_keys]) or [] # Get bases/buildings with coordinates for configured map assets buildings = db.query(""" SELECT b.id, a.map, a.transform, a.class, - COALESCE(NULLIF(ps.character_name, ''), NULLIF(ea.platform_name, ''), 'Base ' || b.id::text) as owner_name + COALESCE(NULLIF(owner.character_name, ''), 'Base ' || b.id::text) as owner_name FROM dune.buildings b JOIN dune.actors a ON b.id = a.id - LEFT JOIN dune.player_state ps ON b.owner_id = ps.player_pawn_id - LEFT JOIN dune.encrypted_accounts ea ON ea.id = ( - SELECT ps2.account_id FROM dune.player_state ps2 WHERE ps2.player_pawn_id = b.owner_id LIMIT 1 - ) + LEFT JOIN LATERAL ( + SELECT DISTINCT afe_totem.actor_id as totem_actor_id + FROM dune.building_instances bi + JOIN dune.actor_fgl_entities afe_totem ON afe_totem.entity_id = bi.owner_entity_id + WHERE bi.building_id = b.id + LIMIT 1 + ) totem ON true + LEFT JOIN LATERAL ( + SELECT ps.character_name + FROM dune.actors pawn + JOIN dune.player_state ps ON pawn.id = ps.player_pawn_id + WHERE pawn.id BETWEEN totem.totem_actor_id - 6 AND totem.totem_actor_id - 1 + AND pawn.class LIKE %s + ORDER BY totem.totem_actor_id - pawn.id + LIMIT 1 + ) owner ON true WHERE a.transform IS NOT NULL AND a.map = ANY(%s) ORDER BY a.map LIMIT 500 - """, [selected_map_keys]) or [] + """, [LIKE_PC, selected_map_keys]) or [] # Parse coordinates from transform field def parse_transform(t): @@ -659,7 +690,7 @@ def register_routes(app, services, settings): if coords: vehicle_locations.append({ 'id': v['id'], - 'name': v.get('name', 'Unknown'), + 'name': v.get('owner_name') or v.get('class', '').split('/')[-1] if v.get('class') else f'Vehicle {v["id"]}', 'map': v['map'], 'class': v.get('class', '').split('/')[-1] if v.get('class') else '', 'x': coords['x'], diff --git a/app/services/admin.py b/app/services/admin.py index f942bfa..3b94fac 100644 --- a/app/services/admin.py +++ b/app/services/admin.py @@ -798,17 +798,22 @@ class AdminService: try: import base64 import json as _json - title_json = _json.dumps(title)[1:-1] - message_json = _json.dumps(message)[1:-1] + import os + + token = os.environ.get('DUNE_BROADCAST_TOKEN', + getattr(self, '_broadcast_token', None) or 'Nu6VmPWUMvdPMeB7qErr') + title_b64 = base64.b64encode(title.encode('utf-8')).decode() + message_b64 = base64.b64encode(message.encode('utf-8')).decode() erl = ( - f'Title = unicode:characters_to_binary(<<"{title_json}">>, utf8), ' - f'Body = unicode:characters_to_binary(<<"{message_json}">>, utf8), ' + f'Title = base64:decode(<<"{title_b64}">>), ' + f'Body = base64:decode(<<"{message_b64}">>), ' f'Duration = {duration}, ' + f'Token = <<"{token}">>, ' 'EntryEn = #{<<"Key">> => <<"en">>, <<"Title">> => Title, <<"Body">> => Body}, ' 'EntryEnUs = #{<<"Key">> => <<"en-US">>, <<"Title">> => Title, <<"Body">> => Body}, ' 'Inner = iolist_to_binary(rabbit_json:encode(#{<<"ServerCommand">> => <<"ServiceBroadcast">>, <<"BroadcastType">> => <<"Generic">>, <<"BroadcastPayload">> => #{<<"BroadcastDuration">> => Duration, <<"LocalizedText">> => [EntryEn, EntryEnUs]}})), ' - 'Outer = iolist_to_binary(rabbit_json:encode(#{<<"Version">> => 2, <<"AuthToken">> => <<"Nu6VmPWUMvdPMeB7qErr">>, <<"MessageContent">> => Inner})), ' + 'Outer = iolist_to_binary(rabbit_json:encode(#{<<"Version">> => 2, <<"AuthToken">> => Token, <<"MessageContent">> => Inner})), ' 'XName = rabbit_misc:r(<<"/">>, exchange, <<"heartbeats">>), ' 'X = rabbit_exchange:lookup_or_die(XName), ' 'MsgId = list_to_binary("manual-service-broadcast-" ++ integer_to_list(erlang:system_time(millisecond))), ' diff --git a/app/services/player.py b/app/services/player.py index eff4e06..b1459e2 100644 --- a/app/services/player.py +++ b/app/services/player.py @@ -269,9 +269,24 @@ class PlayerService: (SELECT COUNT(*)::int FROM dune.building_instances bi WHERE bi.building_id = b.id) as instance_count FROM dune.buildings b JOIN dune.actors a ON b.id = a.id - WHERE b.owner_id = %s + JOIN LATERAL ( + SELECT DISTINCT afe_totem.actor_id as totem_actor_id + FROM dune.building_instances bi + JOIN dune.actor_fgl_entities afe_totem ON afe_totem.entity_id = bi.owner_entity_id + WHERE bi.building_id = b.id + LIMIT 1 + ) totem ON true + JOIN LATERAL ( + SELECT pawn.id as pawn_id + FROM dune.actors pawn + WHERE pawn.id BETWEEN totem.totem_actor_id - 6 AND totem.totem_actor_id - 1 + AND pawn.class LIKE %s + ORDER BY totem.totem_actor_id - pawn.id + LIMIT 1 + ) owner ON true + WHERE owner.pawn_id = %s ORDER BY a.map - """, [player_id]) or [] + """, [LIKE_PC, player_id]) or [] except Exception: return [] diff --git a/app/services/rmq.py b/app/services/rmq.py new file mode 100644 index 0000000..90de15b --- /dev/null +++ b/app/services/rmq.py @@ -0,0 +1,210 @@ +"""RMQ service - RabbitMQ Management HTTP API client.""" + +import json +import logging +import base64 +import urllib.request +import urllib.error +from typing import Any, Dict, List, Optional + +logger = logging.getLogger(__name__) + + +class RmqService: + """RabbitMQ Management HTTP API client. + + Communicates with RMQ Admin (port 30325) and RMQ Game (port 32716) + HTTP API endpoints via SSH tunnel (localhost). + """ + + def __init__(self, admin_port: int = 30325, game_port: int = 32716, + username: str = 'dashboard_admin', password: str = ''): + self.admin_port = admin_port + self.game_port = game_port + self.username = username + self.password = password + self._auth = base64.b64encode( + f"{username}:{password}".encode()).decode() + logger.info("RmqService initialized: admin=localhost:%s game=localhost:%s", + admin_port, game_port) + + def _request(self, port: int, path: str, method: str = 'GET', + body: Any = None, timeout: int = 15) -> Optional[Any]: + """Execute an HTTP request against an RMQ API. + + Args: + port: Tunnel port (30325 for admin, 32716 for game). + path: API path (e.g., '/api/overview'). + method: HTTP method. + body: Optional JSON-serializable request body. + timeout: Request timeout in seconds. + + Returns: + Parsed JSON response, or None on failure. + """ + url = f"http://127.0.0.1:{port}{path}" + headers = { + 'Authorization': f'Basic {self._auth}', + } + if body is not None: + headers['Content-Type'] = 'application/json' + data = json.dumps(body).encode() + else: + data = None + + req = urllib.request.Request(url, data=data, headers=headers) + + if method != 'GET' and method != 'POST': + req.method = method + + try: + with urllib.request.urlopen(req, timeout=timeout) as resp: + raw = resp.read().decode() + return json.loads(raw) if raw.strip() else {} + except urllib.error.HTTPError as e: + logger.warning("RMQ HTTP %s %s -> %s: %s", method, url, e.code, + e.read().decode()[:200] if e.fp else '') + return None + except Exception as e: + logger.warning("RMQ request error %s %s: %s", method, url, e) + return None + + @staticmethod + def _encode_vhost(vhost: str = '/') -> str: + return vhost.replace('/', '%2F') + + # ── Admin API (port 30325) ─────────────────────────────────────── + + def overview(self) -> Optional[Dict]: + """Cluster overview: node info, message stats, queue totals.""" + return self._request(self.admin_port, '/api/overview') + + def nodes(self) -> Optional[List]: + """List nodes with memory and disk info.""" + return self._request(self.admin_port, '/api/nodes') + + def exchanges(self) -> Optional[List]: + """List all exchanges with message stats.""" + return self._request(self.admin_port, '/api/exchanges') + + def queues(self) -> Optional[List]: + """List all queues with consumer counts and message depths.""" + return self._request(self.admin_port, '/api/queues') + + def bindings(self) -> Optional[List]: + """List all bindings (source -> destination mappings).""" + return self._request(self.admin_port, '/api/bindings') + + def consumers(self) -> Optional[List]: + """List active consumers.""" + return self._request(self.admin_port, '/api/consumers') + + def connections(self) -> Optional[List]: + """List active AMQP connections.""" + return self._request(self.admin_port, '/api/connections') + + def channels(self) -> Optional[List]: + """List active channels.""" + return self._request(self.admin_port, '/api/channels') + + def health(self) -> Optional[Dict]: + """Cluster health and alarm status.""" + return self._request(self.admin_port, + '/api/health/checks/alarms') + + def peek_messages(self, queue_name: str, vhost: str = '/', + count: int = 5) -> Optional[List]: + """Peek at messages in a queue without consuming them.""" + vh = self._encode_vhost(vhost) + body = { + 'count': count, + 'ackmode': 'ack_requeue_true', + 'encoding': 'auto', + } + return self._request(self.admin_port, + f'/api/queues/{vh}/{queue_name}/get', + method='POST', body=body) + + def publish(self, exchange: str, routing_key: str, message: Any, + vhost: str = '/') -> Optional[Dict]: + """Publish a message to an exchange. + + NOTE: RMQ HTTP API sets user_id to the authenticated username, + which the game server may reject. For ServerCommands on the + game RPC exchange, use the Erlang eval approach instead. + """ + vh = self._encode_vhost(vhost) + body = { + 'properties': {}, + 'routing_key': routing_key, + 'payload': json.dumps(message) if not isinstance(message, str) + else message, + 'payload_encoding': 'string', + } + return self._request(self.admin_port, + f'/api/exchanges/{vh}/{exchange}/publish', + method='POST', body=body) + + def get_queue_bindings(self, queue_name: str, + vhost: str = '/') -> Optional[List]: + vh = self._encode_vhost(vhost) + return self._request(self.admin_port, + f'/api/queues/{vh}/{queue_name}/bindings') + + def get_exchange_bindings(self, exchange: str, + vhost: str = '/') -> Optional[List]: + vh = self._encode_vhost(vhost) + return self._request(self.admin_port, + f'/api/exchanges/{vh}/{exchange}/bindings/source') + + # ── Game API (port 32716) ──────────────────────────────────────── + + def game_overview(self) -> Optional[Dict]: + """Game RMQ cluster overview.""" + return self._request(self.game_port, '/api/overview') + + def game_queues(self) -> Optional[List]: + """Game RMQ queues.""" + return self._request(self.game_port, '/api/queues') + + def game_exchanges(self) -> Optional[List]: + """Game RMQ exchanges.""" + return self._request(self.game_port, '/api/exchanges') + + def game_publish(self, exchange: str, routing_key: str, + message: Any, vhost: str = '/') -> Optional[Dict]: + """Publish a message to the game RMQ.""" + vh = self._encode_vhost(vhost) + body = { + 'properties': {}, + 'routing_key': routing_key, + 'payload': json.dumps(message) if not isinstance(message, str) + else message, + 'payload_encoding': 'string', + } + return self._request(self.game_port, + f'/api/exchanges/{vh}/{exchange}/publish', + method='POST', body=body) + + # ── Combined / convenience ─────────────────────────────────────── + + def combined_overview(self) -> Dict[str, Any]: + """Get overview from both RMQ instances.""" + return { + 'admin': self.overview(), + 'game': self.game_overview(), + } + + def combined_queues(self) -> Dict[str, Any]: + """Get queues from both RMQ instances.""" + return { + 'admin': self.queues(), + 'game': self.game_queues(), + } + + def combined_exchanges(self) -> Dict[str, Any]: + """Get exchanges from both RMQ instances.""" + return { + 'admin': self.exchanges(), + 'game': self.game_exchanges(), + } diff --git a/app/utils/constants.py b/app/utils/constants.py index b79d6f3..d33ec44 100644 --- a/app/utils/constants.py +++ b/app/utils/constants.py @@ -81,5 +81,5 @@ NAV_PAGES = [ ('/guilds', 'Guilds'), ('/buildings', 'Buildings'), ('/map', 'Map'), - ('/admin-experimental', 'Admin Experimental'), + ('/admin-experimental', 'Experimental'), ] diff --git a/backend/app/services/rmq_game.py b/backend/app/services/rmq_game.py index e128d8b..7a2854e 100644 --- a/backend/app/services/rmq_game.py +++ b/backend/app/services/rmq_game.py @@ -2,6 +2,7 @@ import json import logging +import os import httpx @@ -93,7 +94,7 @@ class RmqGameService: } body = { "Version": 2, - "AuthToken": "Nu6VmPWUMvdPMeB7qErr", + "AuthToken": os.environ.get("DUNE_BROADCAST_TOKEN", "Nu6VmPWUMvdPMeB7qErr"), "MessageContent": inner, } return self.publish( diff --git a/launcher.ps1 b/launcher.ps1 index b58976a..bc42e67 100644 --- a/launcher.ps1 +++ b/launcher.ps1 @@ -2069,6 +2069,10 @@ function Start-Dashboard { $Namespace = $settings.kubernetes.namespace $DashboardPort = [int]$settings.dashboard.port $DirectorPort = [int]$settings.director.port + $RmqAdminPort = [int]($settings.rabbitmq | ForEach-Object { $_.admin_port }) + if (-not $RmqAdminPort) { $RmqAdminPort = 30325 } + $RmqGamePort = [int]($settings.rabbitmq | ForEach-Object { $_.game_port }) + if (-not $RmqGamePort) { $RmqGamePort = 32716 } # Register sensitive values for log sanitization Register-SensitiveValue -Key "ServerIP" -Value $ServerHost @@ -2173,13 +2177,19 @@ function Start-Dashboard { Write-Log -Message "Namespace: $Namespace" -Category "k8s" # Kill existing SSH tunnels on the DB/Director ports - Write-Log -Message "Cleaning up existing SSH tunnels on ports $LocalPort and $DirectorPort" -Category "ssh" + Write-Log -Message "Cleaning up existing SSH tunnels on ports $LocalPort, $DirectorPort, $RmqAdminPort, $RmqGamePort" -Category "ssh" Get-NetTCPConnection -LocalPort $LocalPort -ErrorAction SilentlyContinue | ForEach-Object { Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue | Where-Object { $_.ProcessName -eq 'ssh' } | Stop-Process -Force -ErrorAction SilentlyContinue } Get-NetTCPConnection -LocalPort $DirectorPort -ErrorAction SilentlyContinue | ForEach-Object { Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue | Where-Object { $_.ProcessName -eq 'ssh' } | Stop-Process -Force -ErrorAction SilentlyContinue } + Get-NetTCPConnection -LocalPort $RmqAdminPort -ErrorAction SilentlyContinue | ForEach-Object { + Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue | Where-Object { $_.ProcessName -eq 'ssh' } | Stop-Process -Force -ErrorAction SilentlyContinue + } + Get-NetTCPConnection -LocalPort $RmqGamePort -ErrorAction SilentlyContinue | ForEach-Object { + Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue | Where-Object { $_.ProcessName -eq 'ssh' } | Stop-Process -Force -ErrorAction SilentlyContinue + } Start-Sleep 1 # [1/4] SSH Tunnel @@ -2193,6 +2203,8 @@ function Start-Dashboard { "-o", "ServerAliveCountMax=3", "-L", "${LocalPort}:localhost:${LocalPort}", "-L", "${DirectorPort}:localhost:${DirectorPort}", + "-L", "${RmqAdminPort}:localhost:${RmqAdminPort}", + "-L", "${RmqGamePort}:localhost:${RmqGamePort}", "-N", "${SSHUser}@${ServerHost}" ) $sshTunnel = Start-Process ssh -ArgumentList $sshArgs -PassThru -WindowStyle Hidden @@ -2237,7 +2249,7 @@ function Start-Dashboard { Stop-Process -Id $sshTunnel.Id -Force -ErrorAction SilentlyContinue return } - Write-Host "[OK] SSH tunnel up on localhost:$LocalPort (DB), localhost:$DirectorPort (Director)" -ForegroundColor Green + Write-Host "[OK] SSH tunnel up on localhost:$LocalPort (DB), localhost:$DirectorPort (Director), localhost:$RmqAdminPort (RMQ Admin), localhost:$RmqGamePort (RMQ Game)" -ForegroundColor Green Write-Log -Message "SSH tunnel connected successfully" -Category "ssh" # [2/4] DB Port-Forward @@ -2449,7 +2461,7 @@ function Start-Dashboard { Write-Host "" Write-Host "Stopping tunnels..." -ForegroundColor Cyan Stop-Process -Id $sshTunnel.Id -Force -ErrorAction SilentlyContinue - $pkillCmd = 'ssh -i "' + $SSHKey + '" -o StrictHostKeyChecking=accept-new ' + $SSHUser + '@' + $ServerHost + ' "sudo fuser -k 15433/tcp 32479/tcp 2>/dev/null"' + $pkillCmd = 'ssh -i "' + $SSHKey + '" -o StrictHostKeyChecking=accept-new ' + $SSHUser + '@' + $ServerHost + ' "sudo fuser -k 15433/tcp 32479/tcp 30325/tcp 32716/tcp 2>/dev/null"' cmd /c $pkillCmd 2>$null } @@ -2600,6 +2612,10 @@ function Start-NewDashboard { $Namespace = $settings.kubernetes.namespace $DashboardPort = [int]$settings.dashboard.port $DirectorPort = [int]$settings.director.port + $RmqAdminPort = [int]($settings.rabbitmq | ForEach-Object { $_.admin_port }) + if (-not $RmqAdminPort) { $RmqAdminPort = 30325 } + $RmqGamePort = [int]($settings.rabbitmq | ForEach-Object { $_.game_port }) + if (-not $RmqGamePort) { $RmqGamePort = 32716 } Register-SensitiveValue -Key "ServerIP" -Value $ServerHost Register-SensitiveValue -Key "Namespace" -Value $Namespace @@ -2678,6 +2694,21 @@ function Start-NewDashboard { Write-Host "" # ── SSH Tunnel ──────────────────────────────────────────────────────── + Write-Log -Message "Cleaning up existing SSH tunnels on ports $LocalPort, $DirectorPort, $RmqAdminPort, $RmqGamePort" -Category "ssh" + Get-NetTCPConnection -LocalPort $LocalPort -ErrorAction SilentlyContinue | ForEach-Object { + Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue | Where-Object { $_.ProcessName -eq 'ssh' } | Stop-Process -Force -ErrorAction SilentlyContinue + } + Get-NetTCPConnection -LocalPort $DirectorPort -ErrorAction SilentlyContinue | ForEach-Object { + Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue | Where-Object { $_.ProcessName -eq 'ssh' } | Stop-Process -Force -ErrorAction SilentlyContinue + } + Get-NetTCPConnection -LocalPort $RmqAdminPort -ErrorAction SilentlyContinue | ForEach-Object { + Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue | Where-Object { $_.ProcessName -eq 'ssh' } | Stop-Process -Force -ErrorAction SilentlyContinue + } + Get-NetTCPConnection -LocalPort $RmqGamePort -ErrorAction SilentlyContinue | ForEach-Object { + Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue | Where-Object { $_.ProcessName -eq 'ssh' } | Stop-Process -Force -ErrorAction SilentlyContinue + } + Start-Sleep 1 + Write-Host "[1/5] Starting SSH tunnel (localhost:$LocalPort -> VM)..." -ForegroundColor Yellow Get-NetTCPConnection -LocalPort $LocalPort -ErrorAction SilentlyContinue | ForEach-Object { @@ -2695,6 +2726,8 @@ function Start-NewDashboard { "-o", "ServerAliveCountMax=3", "-L", "${LocalPort}:localhost:${LocalPort}", "-L", "${DirectorPort}:localhost:${DirectorPort}", + "-L", "${RmqAdminPort}:localhost:${RmqAdminPort}", + "-L", "${RmqGamePort}:localhost:${RmqGamePort}", "-N", "${SSHUser}@${ServerHost}" ) $sshTunnel = Start-Process ssh -ArgumentList $sshArgs -PassThru -WindowStyle Hidden @@ -2720,7 +2753,7 @@ function Start-NewDashboard { Stop-Process -Id $sshTunnel.Id -Force -ErrorAction SilentlyContinue return } - Write-Host "[OK] SSH tunnel up on localhost:$LocalPort" -ForegroundColor Green + Write-Host "[OK] SSH tunnel up on localhost:$LocalPort (DB), localhost:$DirectorPort (Director), localhost:$RmqAdminPort (RMQ Admin), localhost:$RmqGamePort (RMQ Game)" -ForegroundColor Green # ── DB Port-Forward ─────────────────────────────────────────────────── Write-Host "[2/5] Starting DB port-forward on VM..." -ForegroundColor Yellow @@ -2739,7 +2772,7 @@ function Start-NewDashboard { } $RemotePort = 15432 - ssh -i $SSHKey -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 ${SSHUser}@${ServerHost} "sudo fuser -k ${LocalPort}/tcp ${DirectorPort}/tcp 2>/dev/null; sleep 1" 2>$null + ssh -i $SSHKey -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 ${SSHUser}@${ServerHost} "sudo fuser -k ${LocalPort}/tcp ${DirectorPort}/tcp ${RmqAdminPort}/tcp ${RmqGamePort}/tcp 2>/dev/null; sleep 1" 2>$null $pfCmd = "nohup sudo kubectl port-forward -n $Namespace svc/$DBService $LocalPort`:$RemotePort > /tmp/pf.log 2>`&1 `"&`"" ssh -i $SSHKey -o StrictHostKeyChecking=accept-new -o ServerAliveInterval=30 "${SSHUser}@${ServerHost}" $pfCmd 2>$null Start-Sleep -Seconds 2 @@ -2883,7 +2916,7 @@ function Start-NewDashboard { Stop-Process -Id $frontendProcess.Id -Force -ErrorAction SilentlyContinue Stop-Process -Id $backendProcess.Id -Force -ErrorAction SilentlyContinue Stop-Process -Id $sshTunnel.Id -Force -ErrorAction SilentlyContinue - $pkillCmd = 'ssh -i "' + $SSHKey + '" -o StrictHostKeyChecking=accept-new ' + $SSHUser + '@' + $ServerHost + ' "sudo fuser -k ' + $LocalPort + '/tcp ' + $DirectorPort + '/tcp 2>/dev/null"' + $pkillCmd = 'ssh -i "' + $SSHKey + '" -o StrictHostKeyChecking=accept-new ' + $SSHUser + '@' + $ServerHost + ' "sudo fuser -k ' + $LocalPort + '/tcp ' + $DirectorPort + '/tcp ' + $RmqAdminPort + '/tcp ' + $RmqGamePort + '/tcp 2>/dev/null"' cmd /c $pkillCmd 2>$null Write-Host " All services stopped." -ForegroundColor Green Write-Host "" diff --git a/static/style.css b/static/style.css index 06e6b78..65422f1 100644 --- a/static/style.css +++ b/static/style.css @@ -224,7 +224,8 @@ table { } thead th { - background: #f8f6f2; + background: var(--table-header); + color: var(--text); padding: 10px 14px; text-align: left; font-weight: 600; diff --git a/static/themes.css b/static/themes.css index 5657198..7f87167 100644 --- a/static/themes.css +++ b/static/themes.css @@ -322,6 +322,24 @@ --code-bg: #fafaf5; } +/* ===== Dark Variants (for light themes) ===== */ +[data-theme="default-dark"] { --primary:#c9a24e; --primary-dark:#a8862e; --primary-light:#e0c97a; --bg:#1a1a1e; --card-bg:#252528; --text:#e0e0e0; --text-light:#a0a0a0; --text-muted:#707070; --border:#333; --accent:#c9a24e; --danger:#c0392b; --success:#27ae60; --nav-bg:#0d0d12; --nav-text:#c0c0c0; --nav-active:#c9a24e; --hover:#2a2a2e; --shadow:0 2px 8px rgba(0,0,0,0.35); --table-header:#2a2a2e; --code-bg:#1e1e22; } +[data-theme="atreides-dark"] { --primary:#2d5a27; --primary-dark:#1e3d19; --primary-light:#4a8c42; --bg:#1a1e1a; --card-bg:#252825; --text:#e0e0e0; --text-light:#a0a0a0; --text-muted:#707070; --border:#333; --accent:#3d7a37; --danger:#cc4422; --success:#4a8c42; --nav-bg:#0d120d; --nav-text:#c0c0c0; --nav-active:#6abf6a; --hover:#2a2e2a; --shadow:0 2px 8px rgba(0,0,0,0.35); --table-header:#2a2e2a; --code-bg:#1e221e; } +[data-theme="fremen-dark"] { --primary:#d4a853; --primary-dark:#b8913f; --primary-light:#e8c87a; --bg:#1e1a15; --card-bg:#282420; --text:#e0d8c8; --text-light:#a09888; --text-muted:#707058; --border:#38332a; --accent:#d4a853; --danger:#c45030; --success:#6b8e23; --nav-bg:#100c08; --nav-text:#c0b8a8; --nav-active:#d4a853; --hover:#2a2520; --shadow:0 2px 8px rgba(0,0,0,0.35); --table-header:#2a2520; --code-bg:#1e1c18; } +[data-theme="bene-gesserit-dark"] { --primary:#a8a8a8; --primary-dark:#888; --primary-light:#c8c8c8; --bg:#1a1a1c; --card-bg:#252528; --text:#e0e0e0; --text-light:#a0a0a0; --text-muted:#707070; --border:#333; --accent:#888; --danger:#c41e3a; --success:#2e8b57; --nav-bg:#0d0d0e; --nav-text:#c0c0c0; --nav-active:#ccc; --hover:#2a2a2c; --shadow:0 2px 8px rgba(0,0,0,0.35); --table-header:#2a2a2c; --code-bg:#1e1e20; } +[data-theme="corrino-dark"] { --primary:#b02020; --primary-dark:#8b0000; --primary-light:#d44040; --bg:#1e1a1a; --card-bg:#282525; --text:#e0d8d8; --text-light:#a09090; --text-muted:#705858; --border:#383333; --accent:#c43030; --danger:#c0392b; --success:#27ae60; --nav-bg:#120d0d; --nav-text:#c0b8b8; --nav-active:#ff6b6b; --hover:#2e2a2a; --shadow:0 2px 8px rgba(0,0,0,0.35); --table-header:#2e2a2a; --code-bg:#221e1e; } +[data-theme="mentat-dark"] { --primary:#008b8b; --primary-dark:#006666; --primary-light:#20b2aa; --bg:#1a1e1e; --card-bg:#252828; --text:#e0e0e0; --text-light:#a0a0a0; --text-muted:#707070; --border:#333; --accent:#008b8b; --danger:#c44569; --success:#20b2aa; --nav-bg:#0d1212; --nav-text:#c0c0c0; --nav-active:#00ced1; --hover:#2a2e2e; --shadow:0 2px 8px rgba(0,0,0,0.35); --table-header:#2a2e2e; --code-bg:#1e2222; } +[data-theme="sardaukar-dark"] { --primary:#cd853f; --primary-dark:#a0522d; --primary-light:#deb887; --bg:#1e1a15; --card-bg:#282420; --text:#e0d8c8; --text-light:#a09888; --text-muted:#707058; --border:#38332a; --accent:#cd853f; --danger:#cc4422; --success:#6b8e23; --nav-bg:#100c08; --nav-text:#c0b8a8; --nav-active:#cd853f; --hover:#2a2520; --shadow:0 2px 8px rgba(0,0,0,0.35); --table-header:#2a2520; --code-bg:#1e1c18; } +[data-theme="ordos-dark"] { --primary:#2e8b57; --primary-dark:#1c5c3a; --primary-light:#3cb371; --bg:#1a1e1c; --card-bg:#252825; --text:#e0e0d8; --text-light:#a0a090; --text-muted:#707060; --border:#333a33; --accent:#3cb371; --danger:#cc5c3a; --success:#3cb371; --nav-bg:#0d120d; --nav-text:#c0c8c0; --nav-active:#3cb371; --hover:#2a2e2c; --shadow:0 2px 8px rgba(0,0,0,0.35); --table-header:#2a2e2c; --code-bg:#1e221e; } +[data-theme="ix-dark"] { --primary:#4169e1; --primary-dark:#2c4db8; --primary-light:#6495ed; --bg:#1a1c22; --card-bg:#252530; --text:#e0e0e8; --text-light:#a0a0c0; --text-muted:#707090; --border:#333a50; --accent:#6495ed; --danger:#c44569; --success:#32cd32; --nav-bg:#0d0d15; --nav-text:#c0c0d8; --nav-active:#6495ed; --hover:#2a2c38; --shadow:0 2px 8px rgba(0,0,0,0.35); --table-header:#2a2c38; --code-bg:#1e1e28; } +[data-theme="choam-dark"] { --primary:#daa520; --primary-dark:#b8860b; --primary-light:#e8c840; --bg:#1e1c15; --card-bg:#282520; --text:#e0d8c8; --text-light:#a09888; --text-muted:#707058; --border:#38332a; --accent:#daa520; --danger:#b22222; --success:#228b22; --nav-bg:#100e08; --nav-text:#c0b8a8; --nav-active:#daa520; --hover:#2a2820; --shadow:0 2px 8px rgba(0,0,0,0.35); --table-header:#2a2820; --code-bg:#1e1c18; } + +/* ===== Light Variants (for dark themes) ===== */ +[data-theme="harkonnen-light"] { --primary:#ff6b00; --primary-dark:#cc5500; --primary-light:#ff8c33; --bg:#f5f0e8; --card-bg:#ffffff; --text:#1a1a1a; --text-light:#505050; --text-muted:#808080; --border:#e0d8c8; --accent:#ff4500; --danger:#cc0000; --success:#00aa33; --nav-bg:#1a1a1a; --nav-text:#d0d0d0; --nav-active:#ff6b00; --hover:#f0e8d8; --shadow:0 2px 8px rgba(0,0,0,0.08); --table-header:#e8e0d0; --code-bg:#faf8f5; } +[data-theme="spacing-guild-light"] { --primary:#4a90d9; --primary-dark:#2e6ab3; --primary-light:#6baee8; --bg:#e8edf5; --card-bg:#ffffff; --text:#1a2230; --text-light:#404860; --text-muted:#687080; --border:#d0d8e8; --accent:#4a90d9; --danger:#d94545; --success:#45d985; --nav-bg:#1a1a2e; --nav-text:#c0c8d0; --nav-active:#4a90d9; --hover:#e0e8f0; --shadow:0 2px 8px rgba(0,0,40,0.1); --table-header:#d8e0ed; --code-bg:#f4f6fa; } +[data-theme="emperor-light"] { --primary:#d4af37; --primary-dark:#b8962f; --primary-light:#e8c962; --bg:#faf8f0; --card-bg:#ffffff; --text:#1a1a1a; --text-light:#505050; --text-muted:#808080; --border:#e0d8c0; --accent:#d4af37; --danger:#c0392b; --success:#27ae60; --nav-bg:#1a1a1a; --nav-text:#d0d0d0; --nav-active:#d4af37; --hover:#f0ece0; --shadow:0 2px 8px rgba(0,0,0,0.08); --table-header:#e8e4d8; --code-bg:#fafaf5; } +[data-theme="tleilax-light"] { --primary:#6b20b0; --primary-dark:#4a0080; --primary-light:#9966cc; --bg:#f4f0f8; --card-bg:#ffffff; --text:#1a1a24; --text-light:#404060; --text-muted:#686880; --border:#d8d0e8; --accent:#8030cc; --danger:#c41e3a; --success:#00c080; --nav-bg:#1a1a24; --nav-text:#d0d0d8; --nav-active:#9966cc; --hover:#f0e8f8; --shadow:0 2px 8px rgba(40,0,60,0.1); --table-header:#e0d8f0; --code-bg:#f8f4fc; } + /* Theme Selector Button */ .theme-btn { background: none; @@ -350,43 +368,70 @@ position: absolute; right: 0; background: #252530; - min-width: 180px; + min-width: 290px; + max-height: 80vh; + overflow-y: auto; box-shadow: 0 4px 16px rgba(0,0,0,0.4); border-radius: 8px; z-index: 1000; - padding: 8px 0; + padding: 12px; border: 1px solid #404050; } +.theme-grid { + display: flex; + flex-direction: column; + gap: 6px; +} + +.theme-row { + display: flex; + align-items: center; + gap: 8px; + padding: 4px 4px; + border-radius: 6px; + transition: background 0.15s; +} + +.theme-row:hover { + background: rgba(255,255,255,0.06); +} + +.theme-row-label { + flex: 1; + font-size: 12px; + color: #d0d0d8; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.theme-row .theme-swatch { + cursor: pointer; + transition: transform 0.15s, box-shadow 0.15s; + width: 24px; + height: 24px; + border-radius: 6px; + border: 2px solid transparent; + flex-shrink: 0; +} + +.theme-row .theme-swatch:hover { + transform: scale(1.2); + box-shadow: 0 0 8px rgba(255,255,255,0.3); + border-color: #fff; +} + +.theme-row .theme-swatch.active-theme { + border-color: #fff; + box-shadow: 0 0 6px rgba(255,255,255,0.4); +} + .theme-dropdown:hover .theme-dropdown-content { display: block; } -.theme-option { - display: flex; - align-items: center; - gap: 10px; - padding: 10px 16px; - cursor: pointer; - color: #d0d0d8; - font-size: 13px; - transition: background 0.15s; -} - -.theme-option:hover { - background: rgba(255,255,255,0.1); -} - -.theme-option.active { - background: var(--primary); - color: #fff; -} - -.theme-option.active:hover { - background: var(--primary-dark); -} - -/* Theme swatches */ +/* Theme swatches base */ .theme-swatch { width: 20px; height: 20px; @@ -410,6 +455,22 @@ .theme-swatch.ix { background: linear-gradient(135deg, #4169e1 50%, #e8edf8 50%); } .theme-swatch.choam { background: linear-gradient(135deg, #b8860b 50%, #faf8f0 50%); } +/* Variant swatches */ +.theme-swatch.default-dark { background: linear-gradient(135deg, #c9a24e 50%, #1a1a1e 50%); } +.theme-swatch.atreides-dark { background: linear-gradient(135deg, #2d5a27 50%, #1a1e1a 50%); } +.theme-swatch.harkonnen-light { background: linear-gradient(135deg, #ff6b00 50%, #f5f0e8 50%); } +.theme-swatch.fremen-dark { background: linear-gradient(135deg, #d4a853 50%, #1e1a15 50%); } +.theme-swatch.bene-gesserit-dark { background: linear-gradient(135deg, #a8a8a8 50%, #1a1a1c 50%); } +.theme-swatch.spacing-guild-light { background: linear-gradient(135deg, #4a90d9 50%, #e8edf5 50%); } +.theme-swatch.emperor-light { background: linear-gradient(135deg, #d4af37 50%, #faf8f0 50%); } +.theme-swatch.corrino-dark { background: linear-gradient(135deg, #b02020 50%, #1e1a1a 50%); } +.theme-swatch.mentat-dark { background: linear-gradient(135deg, #008b8b 50%, #1a1e1e 50%); } +.theme-swatch.sardaukar-dark { background: linear-gradient(135deg, #cd853f 50%, #1e1a15 50%); } +.theme-swatch.tleilax-light { background: linear-gradient(135deg, #6b20b0 50%, #f4f0f8 50%); } +.theme-swatch.ordos-dark { background: linear-gradient(135deg, #2e8b57 50%, #1a1e1c 50%); } +.theme-swatch.ix-dark { background: linear-gradient(135deg, #4169e1 50%, #1a1c22 50%); } +.theme-swatch.choam-dark { background: linear-gradient(135deg, #daa520 50%, #1e1c15 50%); } + /* Current theme indicator */ #current-theme-display { font-size: 11px; diff --git a/templates/admin_experimental.html b/templates/admin_experimental.html index c3ab684..0b4e091 100644 --- a/templates/admin_experimental.html +++ b/templates/admin_experimental.html @@ -1,12 +1,41 @@ {% extends "base.html" %} -{% block title %}Admin Experimental - Dune Awakening Dashboard{% endblock %} +{% block title %}Experimental - Dune Awakening Dashboard{% endblock %} {% block content %} +
This area contains untested, experimental tools that interact directly with your game server's internal systems (RabbitMQ, PostgreSQL, Battlegroup Director).
+These tools can corrupt data, crash servers, or delete characters. Do not report bugs about this page. Always snapshot or backup your server first.
++ Inspect the RMQ clusters. Both Admin (port 30325) and Game (port 32716) instances via SSH tunnel. +
+Cluster health, node info, message stats.
+ + + +All queues with consumer counts and message depths.
+ + + +All exchanges with type, durability, and message stats.
+ + + +Peek at messages in any queue without consuming them.
+ ++ Publish a test message to any exchange. Note: HTTP API sets user_id to dashboard_admin, which the game server may reject for RPC commands. Use the Erlang eval broadcast for in-game commands. +
+ +$env:TEMP\dune-awakening-server-sshKey and the VM is reachable.
{% if ssh_error %}
- {{ ssh_error }}
+ {{ ssh_error }}
{% endif %}
{% endif %}
Click "Refresh Status" to load battlegroup status...+
Click "Refresh Status" to load battlegroup status...
Click refresh to load pod status...+
Click refresh to load pod status...
logs/debug.log. Sanitizes sensitive data (passwords, tokens) automatically.
| Time | -Action | -User | -Severity | -Details | +Time | +Action | +User | +Severity | +Details |
|---|---|---|---|---|---|---|---|---|---|
| ' + timestamp + ' | ' + '' + (log.action || '-') + ' | ' + '' + (log.user || '-') + ' | ' +