v0.7.5: silence benign log noise, graceful SSL permission errors, README trim
This commit is contained in:
1 parent
421b37e854
commit
91944a0213
11 files changed
+270
-70
No files matched your search
@@ -2,8 +2,6 @@
|
||||
|
||||
A modern, full‑featured management dashboard for **Dune: Awakening** private servers. Provides real‑time monitoring, player tools, chat logs, file browsing, admin utilities, and secure remote access.
|
||||
|
||||
> “A comprehensive web-based management dashboard for Dune: Awakening private servers.”
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
@@ -26,26 +24,18 @@ chmod +x start.sh
|
||||
## Features
|
||||
|
||||
- **Player Management** (vitals, inventory, vehicles, buildings, guilds, reputation)
|
||||
- **In-Game Notifications** — instant broadcasts plus scheduled one-shot/daily/weekly/monthly messages
|
||||
- **Graceful Shutdown / Restart** — in-game countdown warnings with cancel notices, plus scheduled restarts
|
||||
- **Battlegroup Control** — start/stop/restart/update, with update blocked while players are online
|
||||
- **Chat Logs** with channel filtering and auto-refresh
|
||||
- **Director Tools** (battlegroups, world state, transfers)
|
||||
- **SSH File Browser** + **in-browser shell**
|
||||
- **SSH File Browser** (jailed to allowed directories) + **in-browser shell**
|
||||
- **Pod Management** (list, logs, describe, delete with safe-mode for DB backup pods)
|
||||
- **Nav Layout** — switch between horizontal and vertical sidebar; persists preference; auto-enables sidebar on mobile
|
||||
- **Backup & Restore** — encrypted full-server snapshots with scheduled backups and retention cleanup
|
||||
- **Funcom Service Auth Token Management** — update the `ServiceAuthToken` JWT across files and live K8s resources with verification
|
||||
- **Firewall Hardening** via iptables
|
||||
- **Auto‑Update** with safe file replacement
|
||||
- **HTTPS + Remote Access** (self‑signed or Let’s Encrypt)
|
||||
- **Cross‑Platform Launchers**
|
||||
- **Organized Logging** with automatic cleanup and redaction
|
||||
- **Debug Mode** with full SSH/K8s tracing
|
||||
- **SSH Key Rotation** — scan all key locations and sync the newest key
|
||||
- **Backup & Restore** — full server snapshots (game DB, K8s resources, RMQ config, dashboard schema) with optional AES-256 encryption and password protection
|
||||
- **Scheduled Backups** — configurable interval or day/time-based scheduling with automatic retention cleanup
|
||||
- **Funcom Service Auth Token Management** — update the `ServiceAuthToken` JWT across files and live K8s resources (secret, YAML, BattleGroup CR) with verification
|
||||
- **Graceful Shutdown / Restart** — in-game countdown warnings, then `battlegroup stop` / `restart`, with cancel notices
|
||||
- **Custom Notifications** — instant in-game broadcasts, plus scheduled one-shot/daily/weekly/monthly messages
|
||||
- **Scheduled Restarts** — daily/weekly/monthly/one-shot with the same countdown, enable/disable/clear without losing settings
|
||||
- **Battlegroup Update Guard** — update refuses while game servers are online
|
||||
- **Jailed File Browser** — restricted to configured directories with symlink-aware checks
|
||||
- **HTTPS + Remote Access** (self-signed or Let's Encrypt)
|
||||
- **Cross-Platform Launchers** (Windows + Linux/macOS, incl. debug mode and SSH key rotation)
|
||||
|
||||
---
|
||||
|
||||
@@ -70,36 +60,12 @@ DuneDashboard/
|
||||
|
||||
---
|
||||
|
||||
## Security
|
||||
|
||||
- `settings.yaml` is never committed
|
||||
- SSH keys stored with restricted permissions
|
||||
- All DB queries parameterized
|
||||
- No raw SQL console — the old experimental query/execute endpoints were removed entirely
|
||||
- Shell parameters validated and quoted throughout
|
||||
- File browser jailed to allowed directories
|
||||
- All mutations audited
|
||||
- CSP, HSTS, X‑Frame‑Options enforced in production
|
||||
|
||||
> Because letting users run `DROP TABLE` from a web UI is how horror stories begin — so that UI no longer exists.
|
||||
|
||||
---
|
||||
|
||||
## Development
|
||||
|
||||
Run `launcher.bat` or `.\launcher.ps1` — the launcher handles dependencies, SSH key configuration, and server setup automatically.
|
||||
|
||||
---
|
||||
|
||||
## Branching Strategy
|
||||
|
||||
- **main** — stable-ish beta
|
||||
- **experimental** — where chaos becomes innovation
|
||||
|
||||
> “This seemed like a great idea at 3am.” — every experimental commit ever
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
Source Available under the **Dune Dashboard Source License (DDSL)**
|
||||
|
||||
@@ -388,7 +388,7 @@ class BackupService:
|
||||
with open(meta_path) as f:
|
||||
return json.load(f)
|
||||
except Exception as e:
|
||||
logger.warning(f'Could not read sidecar meta from {meta_path}: {e}')
|
||||
logger.debug(f'Could not read sidecar meta from {meta_path}: {e}')
|
||||
try:
|
||||
with tarfile.open(path, 'r:gz') as tar:
|
||||
for m in tar.getmembers():
|
||||
@@ -396,7 +396,9 @@ class BackupService:
|
||||
with tar.extractfile(m) as f:
|
||||
return json.loads(f.read().decode('utf-8'))
|
||||
except Exception as e:
|
||||
logger.warning(f'Could not read metadata from {path}: {e}')
|
||||
# Expected for encrypted archives (handled by verify with a
|
||||
# password) and pre-sidecar backups; not worth a warning.
|
||||
logger.debug(f'Could not read metadata from {path}: {e}')
|
||||
return {}
|
||||
|
||||
def delete_backup(self, name):
|
||||
|
||||
@@ -256,8 +256,15 @@ class DirectorService:
|
||||
def get_server_set_scale(self, map_name: str) -> Optional[Dict]:
|
||||
name = self._map_to_scale_name(map_name)
|
||||
cm_out, cm_err, cm_rc = self.k8s.run(
|
||||
f'get serversetscale {name} -o json')
|
||||
f'get serversetscale {name} -o json', quiet=True)
|
||||
if cm_rc != 0 or not cm_out:
|
||||
# A missing ServerSetScale just means the map has none; only
|
||||
# unexpected failures deserve a warning.
|
||||
if cm_rc != 0 and 'not found' not in (cm_err or '').lower():
|
||||
logger.warning("ServerSetScale lookup failed for %s: %s",
|
||||
map_name, (cm_err or '')[:150])
|
||||
else:
|
||||
logger.debug("No ServerSetScale for %s", map_name)
|
||||
return None
|
||||
return json.loads(cm_out)
|
||||
|
||||
|
||||
+2
-2
@@ -11,10 +11,10 @@ class K8sService:
|
||||
self.ssh = ssh_service
|
||||
self.namespace = namespace
|
||||
|
||||
def run(self, kubectl_command, timeout=30):
|
||||
def run(self, kubectl_command, timeout=30, quiet=False):
|
||||
full_cmd = f'sudo kubectl {kubectl_command} -n {shlex.quote(str(self.namespace))}'
|
||||
logger.debug(f"K8s executing: kubectl {kubectl_command} -n {self.namespace}")
|
||||
result = self.ssh.run(full_cmd, timeout=timeout)
|
||||
result = self.ssh.run(full_cmd, timeout=timeout, quiet=quiet)
|
||||
out, err, rc = result
|
||||
if rc != 0:
|
||||
logger.debug(f"K8s command failed (rc={rc}): {err[:100] if err else 'no error'}")
|
||||
|
||||
+15
-6
@@ -79,19 +79,22 @@ class SSHService:
|
||||
self._client = client
|
||||
return self._client
|
||||
|
||||
def run(self, command, timeout=30):
|
||||
def run(self, command, timeout=30, quiet=False):
|
||||
"""Execute a remote command via SSH.
|
||||
|
||||
Args:
|
||||
command: The shell command to execute.
|
||||
timeout: Maximum time in seconds to wait for the command.
|
||||
quiet: When True, expected non-zero results (e.g. probing for
|
||||
an optional resource) are logged at debug level instead of
|
||||
warning. Return values are unchanged.
|
||||
|
||||
Returns:
|
||||
Tuple of (stdout, stderr, return_code).
|
||||
"""
|
||||
cmd_display = command[:150] + '...' if len(command) > 150 else command
|
||||
logger.debug(f"SSH executing: {cmd_display}")
|
||||
|
||||
|
||||
try:
|
||||
client = self._get_client()
|
||||
stdin, stdout, stderr = client.exec_command(command, timeout=timeout)
|
||||
@@ -99,17 +102,23 @@ class SSHService:
|
||||
out = stdout.read().decode('utf-8', errors='replace')
|
||||
err = stderr.read().decode('utf-8', errors='replace')
|
||||
rc = stdout.channel.recv_exit_status()
|
||||
|
||||
|
||||
# Debug logging for result
|
||||
logger.debug(f"SSH result: host={self.host}, user={self.user}, rc={rc}, stdout_len={len(out)}, stderr_len={len(err)}")
|
||||
if err and rc != 0:
|
||||
logger.warning(f"SSH stderr (rc={rc}): {err[:200]}")
|
||||
if quiet:
|
||||
logger.debug(f"SSH stderr (rc={rc}): {err[:200]}")
|
||||
else:
|
||||
logger.warning(f"SSH stderr (rc={rc}): {err[:200]}")
|
||||
if out:
|
||||
logger.debug(f"SSH stdout preview: {out[:200]}")
|
||||
|
||||
|
||||
if rc != 0:
|
||||
cmd_short = command[:80] + '...' if len(command) > 80 else command
|
||||
logger.warning("SSH command failed (rc=%d): cmd=%s err=%s", rc, cmd_short, err[:100] if err else 'none')
|
||||
if quiet:
|
||||
logger.debug("SSH command rc=%d (quiet): cmd=%s err=%s", rc, cmd_short, err[:100] if err else 'none')
|
||||
else:
|
||||
logger.warning("SSH command failed (rc=%d): cmd=%s err=%s", rc, cmd_short, err[:100] if err else 'none')
|
||||
return out, err, rc
|
||||
except paramiko.SSHException as e:
|
||||
logger.error(f"SSH command error ({self.host}): {e}")
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
"""Production HTTP server builder (cheroot) with noise filtering.
|
||||
|
||||
Cheroot writes server-level errors (e.g. scanners dropping TLS handshakes)
|
||||
straight to stderr, bypassing the dashboard's log levels. The filter below
|
||||
sends the known-benign handshake noise to the debug log and lets everything
|
||||
else through untouched.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Fragments identifying a peer that vanished mid-handshake (typically an
|
||||
# internet scanner hitting the public HTTPS port). Never real failures.
|
||||
_HANDSHAKE_NOISE = (
|
||||
'during handshake',
|
||||
'SSLV3_ALERT',
|
||||
'UNEXPECTED_EOF',
|
||||
'TLSV1_ALERT',
|
||||
)
|
||||
|
||||
|
||||
def cheroot_error_filter(original_error_log, msg='', level=20, traceback=False):
|
||||
"""Drop-in replacement for ``server.error_log``.
|
||||
|
||||
Handshake noise -> debug log. Everything else -> original handler.
|
||||
"""
|
||||
text = str(msg)
|
||||
lowered = text.lower()
|
||||
if any(fragment.lower() in lowered for fragment in _HANDSHAKE_NOISE):
|
||||
logger.debug('TLS handshake dropped by peer: %s', text[:200])
|
||||
return
|
||||
original_error_log(msg, level=level, traceback=traceback)
|
||||
|
||||
|
||||
def build_server(host, port, wsgi_app, cert_path=None, key_path=None,
|
||||
numthreads=16, socket_timeout=60):
|
||||
"""Build a cheroot server with timeouts, bounded queues and TLS support."""
|
||||
from cheroot import wsgi as cheroot_wsgi
|
||||
|
||||
server = cheroot_wsgi.Server(
|
||||
(host, port), wsgi_app,
|
||||
numthreads=numthreads,
|
||||
request_queue_size=128,
|
||||
timeout=socket_timeout,
|
||||
accepted_queue_size=128,
|
||||
accepted_queue_timeout=10,
|
||||
)
|
||||
if cert_path and key_path:
|
||||
from cheroot.ssl.builtin import BuiltinSSLAdapter
|
||||
server.ssl_adapter = BuiltinSSLAdapter(cert_path, key_path)
|
||||
original = server.error_log
|
||||
server.error_log = lambda msg='', level=20, traceback=False: \
|
||||
cheroot_error_filter(original, msg, level=level, traceback=traceback)
|
||||
return server
|
||||
@@ -30,6 +30,23 @@ if __name__ == '__main__':
|
||||
cert_path = str(ssl_cert).strip("'\"")
|
||||
key_path = str(ssl_key).strip("'\"")
|
||||
if os.path.exists(cert_path) and os.path.exists(key_path):
|
||||
try:
|
||||
with open(cert_path, 'rb'):
|
||||
pass
|
||||
with open(key_path, 'rb'):
|
||||
pass
|
||||
except OSError:
|
||||
print(f"\n [ERROR] Cannot read SSL files (permission denied):")
|
||||
print(f" [ERROR] {cert_path}")
|
||||
print(f" [ERROR] {key_path}")
|
||||
print(f" [ERROR] The dashboard runs as '{os.environ.get('USERNAME', 'unknown')}'")
|
||||
print(" [ERROR] but these files are only readable by an Administrator.")
|
||||
print(" [ERROR] Fix with ONE of:")
|
||||
print(" [ERROR] 1. Run the launcher as Administrator (right-click -> Run as administrator)")
|
||||
print(" [ERROR] 2. Grant yourself read access, e.g. in an elevated terminal:")
|
||||
print(f' [ERROR] icacls "{cert_path}" /grant "%USERNAME%:(R)"')
|
||||
print(f' [ERROR] icacls "{key_path}" /grant "%USERNAME%:(R)"\n')
|
||||
sys.exit(1)
|
||||
ssl_context = (cert_path, key_path)
|
||||
protocol = "https"
|
||||
else:
|
||||
@@ -147,26 +164,24 @@ if __name__ == '__main__':
|
||||
# Socket.IO keeps working (threading mode = HTTP long-polling, which
|
||||
# runs on any WSGI server).
|
||||
try:
|
||||
from cheroot import wsgi as cheroot_wsgi
|
||||
import cheroot
|
||||
from app.utils.http_server import build_server
|
||||
except ImportError:
|
||||
logging.getLogger(__name__).warning(
|
||||
"cheroot not installed - falling back to dev server "
|
||||
"(no connection timeouts)")
|
||||
socketio.run(app, host=host, port=port, debug=debug, log_output=False, ssl_context=ssl_context)
|
||||
else:
|
||||
server = cheroot_wsgi.Server(
|
||||
(host, port), app,
|
||||
numthreads=16,
|
||||
request_queue_size=128,
|
||||
timeout=60,
|
||||
accepted_queue_size=128,
|
||||
accepted_queue_timeout=10,
|
||||
)
|
||||
if ssl_context:
|
||||
from cheroot.ssl.builtin import BuiltinSSLAdapter
|
||||
server.ssl_adapter = BuiltinSSLAdapter(cert_path, key_path)
|
||||
print(f" Server: cheroot (16 threads, 60s socket timeout, TLS on)")
|
||||
else:
|
||||
print(f" Server: cheroot (16 threads, 60s socket timeout)")
|
||||
try:
|
||||
if ssl_context:
|
||||
server = build_server(host, port, app, cert_path, key_path)
|
||||
print(f" Server: cheroot (16 threads, 60s socket timeout, TLS on)")
|
||||
else:
|
||||
server = build_server(host, port, app)
|
||||
print(f" Server: cheroot (16 threads, 60s socket timeout)")
|
||||
except OSError as e:
|
||||
print(f"\n [ERROR] Could not start TLS server: {e}")
|
||||
print(" [ERROR] If this is a permission error, run the launcher as Administrator once,\n")
|
||||
sys.exit(1)
|
||||
print(f" Watchdog: enabled (exit code 42 triggers launcher restart)\n")
|
||||
server.start()
|
||||
@@ -11,7 +11,7 @@ class FakeSSH:
|
||||
self.rc = rc
|
||||
self.commands = []
|
||||
|
||||
def run(self, command, timeout=30):
|
||||
def run(self, command, timeout=30, quiet=False):
|
||||
self.commands.append(command)
|
||||
return self.out, '', self.rc
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
"""Tests for the cheroot server builder + handshake-noise filter."""
|
||||
|
||||
import logging
|
||||
|
||||
from app.utils.http_server import build_server, cheroot_error_filter
|
||||
|
||||
|
||||
class TestHandshakeFilter:
|
||||
def test_handshake_drops_go_to_debug_only(self, caplog):
|
||||
calls = []
|
||||
|
||||
def orig(msg='', level=20, traceback=False):
|
||||
calls.append((msg, level))
|
||||
|
||||
with caplog.at_level(logging.DEBUG, logger='app.utils.http_server'):
|
||||
cheroot_error_filter(orig, 'Client (\'1.2.3.4\', 123) lost - peer '
|
||||
'dropped the TLS connection suddenly, during '
|
||||
'handshake: (8, \'[SSL: SSLV3_ALERT_CERTIFICATE_UNKNOWN] \')')
|
||||
assert calls == []
|
||||
assert any('handshake dropped' in r.message for r in caplog.records)
|
||||
assert all(r.levelno == logging.DEBUG for r in caplog.records)
|
||||
|
||||
def test_real_errors_pass_through(self):
|
||||
calls = []
|
||||
|
||||
def orig(msg='', level=20, traceback=False):
|
||||
calls.append((msg, level, traceback))
|
||||
|
||||
cheroot_error_filter(orig, 'socket.error 104', level=30, traceback=True)
|
||||
assert calls == [('socket.error 104', 30, True)]
|
||||
|
||||
|
||||
def _self_signed_pair(tmp_path):
|
||||
import datetime
|
||||
from cryptography import x509
|
||||
from cryptography.hazmat.primitives import hashes, serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import rsa
|
||||
from cryptography.x509.oid import NameOID
|
||||
key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
|
||||
name = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, 'localhost')])
|
||||
now = datetime.datetime.now(datetime.timezone.utc)
|
||||
cert = (x509.CertificateBuilder().subject_name(name).issuer_name(name)
|
||||
.public_key(key.public_key()).serial_number(x509.random_serial_number())
|
||||
.not_valid_before(now).not_valid_after(now + datetime.timedelta(days=1))
|
||||
.sign(key, hashes.SHA256()))
|
||||
cert_path = tmp_path / 'c.pem'
|
||||
key_path = tmp_path / 'k.pem'
|
||||
cert_path.write_bytes(cert.public_bytes(serialization.Encoding.PEM))
|
||||
key_path.write_bytes(key.private_bytes(
|
||||
serialization.Encoding.PEM,
|
||||
serialization.PrivateFormat.TraditionalOpenSSL,
|
||||
serialization.NoEncryption()))
|
||||
return str(cert_path), str(key_path)
|
||||
|
||||
|
||||
class TestBuildServer:
|
||||
def test_timeouts_and_queues(self):
|
||||
server = build_server('127.0.0.1', 0, None)
|
||||
try:
|
||||
assert server.numthreads == 16
|
||||
assert server.timeout == 60
|
||||
assert server.request_queue_size == 128
|
||||
finally:
|
||||
server.stop()
|
||||
|
||||
def test_tls_adapter(self, tmp_path):
|
||||
cert, key = _self_signed_pair(tmp_path)
|
||||
server = build_server('127.0.0.1', 0, None, cert, key)
|
||||
try:
|
||||
assert server.ssl_adapter is not None
|
||||
finally:
|
||||
server.stop()
|
||||
@@ -16,7 +16,7 @@ class FakeSSH:
|
||||
def __init__(self):
|
||||
self.commands = []
|
||||
|
||||
def run(self, command, timeout=30):
|
||||
def run(self, command, timeout=30, quiet=False):
|
||||
self.commands.append(command)
|
||||
return ('ok', '', 0)
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
"""Tests for SSHService.run(quiet=...) - log level only, same results."""
|
||||
|
||||
import logging
|
||||
|
||||
from app.services.ssh import SSHService
|
||||
|
||||
|
||||
class _FakeChannel:
|
||||
def __init__(self, rc):
|
||||
self._rc = rc
|
||||
|
||||
def settimeout(self, timeout):
|
||||
pass
|
||||
|
||||
def recv_exit_status(self):
|
||||
return self._rc
|
||||
|
||||
|
||||
class _FakeStream:
|
||||
def __init__(self, data, rc):
|
||||
self._data = data
|
||||
self.channel = _FakeChannel(rc)
|
||||
|
||||
def read(self):
|
||||
return self._data
|
||||
|
||||
|
||||
class _FakeClient:
|
||||
def __init__(self, out=b'', err=b'Error from server (NotFound)', rc=1):
|
||||
self._out = _FakeStream(out, rc)
|
||||
self._err = _FakeStream(err, rc)
|
||||
|
||||
def get_transport(self):
|
||||
return None
|
||||
|
||||
def exec_command(self, command, timeout=None):
|
||||
return None, self._out, self._err
|
||||
|
||||
|
||||
def _service_with_fake_client():
|
||||
svc = SSHService.__new__(SSHService)
|
||||
import threading
|
||||
svc.host = 'h'
|
||||
svc.user = 'u'
|
||||
svc.ssh_key = None
|
||||
svc._client = _FakeClient()
|
||||
svc._lock = threading.Lock()
|
||||
# Bypass reconnect logic: _get_client returns the fake directly when
|
||||
# its transport check is skipped. Patch at instance level.
|
||||
svc._get_client = lambda: svc._client
|
||||
return svc
|
||||
|
||||
|
||||
class TestQuietFlag:
|
||||
def test_results_identical_quiet_or_not(self, caplog):
|
||||
svc = _service_with_fake_client()
|
||||
with caplog.at_level(logging.DEBUG, logger='app.services.ssh'):
|
||||
out1, err1, rc1 = svc.run('kubectl get x', quiet=False)
|
||||
with caplog.at_level(logging.DEBUG, logger='app.services.ssh'):
|
||||
out2, err2, rc2 = svc.run('kubectl get x', quiet=True)
|
||||
assert (out1, err1, rc1) == (out2, err2, rc2) == ('', 'Error from server (NotFound)', 1)
|
||||
|
||||
def test_loud_logs_warning_quiet_logs_debug(self, caplog):
|
||||
svc = _service_with_fake_client()
|
||||
with caplog.at_level(logging.DEBUG, logger='app.services.ssh'):
|
||||
caplog.clear()
|
||||
svc.run('kubectl get x', quiet=False)
|
||||
loud_levels = {r.levelno for r in caplog.records if 'rc=1' in r.message}
|
||||
with caplog.at_level(logging.DEBUG, logger='app.services.ssh'):
|
||||
caplog.clear()
|
||||
svc.run('kubectl get x', quiet=True)
|
||||
quiet_levels = {r.levelno for r in caplog.records if 'rc=1' in r.message}
|
||||
assert logging.WARNING in loud_levels
|
||||
assert logging.WARNING not in quiet_levels
|
||||
Reference in new issue
Block a user