Compare commits
14 Commits
v1.1.1
..
79fdbc4687
| Author | SHA1 | Date | |
|---|---|---|---|
| 79fdbc4687 | |||
| 5fabd035c2 | |||
| 3e7cc11e08 | |||
| 58f7fb11a3 | |||
| 3f62661ed7 | |||
| b271c15267 | |||
| 3a3d46119a | |||
| 0b16218ce9 | |||
| 248c33ed80 | |||
| 933fa8f257 | |||
| 883ef20ced | |||
| ed4397b21b | |||
| da188ea290 | |||
| 42a50037ab |
@@ -3,7 +3,6 @@ __pycache__
|
||||
*.pyc
|
||||
*.pyo
|
||||
config.json
|
||||
data/
|
||||
screenshots/
|
||||
.claude/
|
||||
CLAUDE.md
|
||||
|
||||
+2
-6
@@ -23,9 +23,5 @@ __pycache__/
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Local config — contains the admin password hash and session secret.
|
||||
# Fresh installs start from config.json.example (see CONFIG.md).
|
||||
config.json
|
||||
|
||||
# Docker config volume (holds the live config.json with secrets)
|
||||
data/
|
||||
# Local config (uncomment if you want to ignore local changes)
|
||||
# config.json
|
||||
|
||||
@@ -18,14 +18,6 @@ python3 server.py
|
||||
|
||||
Access at http://localhost:{web_port} (configured in config.json)
|
||||
|
||||
### Deployment / fielding notes
|
||||
|
||||
- **Config path** is overridable via the `ADSBIT_CONFIG` env var (defaults to `config.json` beside `server.py`). Docker uses `/app/data/config.json` on a mounted volume.
|
||||
- **`/health`** (no auth) returns status/version/receiver/flight counts — used by the Docker `HEALTHCHECK` and any external monitoring.
|
||||
- **`VERSION`** constant in `server.py` is the single source of truth; surfaced at startup, via `GET /api/config`, and in the admin header. Bump it for releases.
|
||||
- **Auto-scan** (`scan_for_receivers`) skips subnets larger than `MIN_SCAN_PREFIX` (/20) so a docker `/16` doesn't stall startup; the manual scan endpoint enforces the same limit.
|
||||
- **`docker-entrypoint.sh`** seeds `config.json` from `config.json.example` on first run, so a fresh `docker compose up` needs no manual steps. SIGTERM/SIGINT shut down cleanly (no traceback).
|
||||
|
||||
## Architecture
|
||||
|
||||
### Components
|
||||
@@ -56,15 +48,11 @@ Access at http://localhost:{web_port} (configured in config.json)
|
||||
- **admin/** - Admin panel (login + tabbed settings UI)
|
||||
- Theme management: rename display names, upload per-direction background PNGs, create new themes
|
||||
- Display names stored in `config.json` `theme_names` map (folder name -> display name)
|
||||
- Receivers tab: live per-receiver health (via `GET /api/admin/receiver-status` and `POST /api/admin/test-receivers`), a select → SAVE & APPLY → auto-test flow, selectable scan results, and a per-interface scan selector
|
||||
- Version (from `server.py` `VERSION`) is surfaced via public `GET /api/config` and shown in the admin header
|
||||
- **pixel-editor.js** - In-app Canvas2D pixel editor (Sprites tab "EDIT" button)
|
||||
- Edits sprites at native 500x333; tools: pencil, eraser, color picker, fill bucket, pan, line, rectangle, ellipse (outline/filled), rectangular select
|
||||
- Select & move: marquee + floating layer, drag/arrow-nudge, Ctrl+C/X/V clipboard, Delete, Enter/Esc commit
|
||||
- Zoom/pan, undo/redo (snapshot-per-stroke), grid overlay, brush size & opacity, retro + custom (localStorage) + recent palettes, adjustable reference-image overlay
|
||||
- Edits sprites at native 500x333; tools: pencil, eraser, color picker, fill bucket, pan
|
||||
- Zoom/pan, undo/redo (snapshot-per-stroke), grid overlay, retro palette + native color input
|
||||
- Exports a 500x333 PNG via `srcCanvas.toBlob` and POSTs to the existing `/api/admin/sprites/{type}` upload endpoint (no new server route)
|
||||
- Keyboard: B/E/I/F/L/R/O/M tools, Space=pan, +/-/0 zoom, Ctrl+Z/Y undo/redo, Ctrl+C/X/V, arrows nudge, G grid, Esc close
|
||||
- **Asset cache-busting:** `admin.html` references `admin.css`/`admin.js`/`pixel-editor.js` with a `?v=YYYYMMDD[x]` query — bump it whenever those files change so browsers reload them
|
||||
- Keyboard: B/E/I/F tools, Space=pan, +/-/0 zoom, Ctrl+Z/Y undo/redo, G grid, Esc close
|
||||
|
||||
- **setup/** - First-run setup wizard (multi-step configuration)
|
||||
|
||||
|
||||
+2
-9
@@ -13,16 +13,9 @@ RUN pip install --no-cache-dir -r requirements.txt && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY . .
|
||||
RUN chmod +x /app/docker-entrypoint.sh
|
||||
|
||||
EXPOSE 2001
|
||||
|
||||
# Persist config on a mounted volume by default (see docker-compose.yml).
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
ADSBIT_CONFIG=/app/data/config.json
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
# Liveness probe against the unauthenticated /health endpoint.
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD python3 -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:2001/health',timeout=4).status==200 else 1)" || exit 1
|
||||
|
||||
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
||||
CMD ["python3", "server.py"]
|
||||
|
||||
@@ -7,16 +7,14 @@ A retro SNES-style side-view flight tracker that displays ADS-B aircraft data wi
|
||||
## Features
|
||||
|
||||
- Real-time aircraft tracking via ADS-B receivers
|
||||
- Custom pixel art sprites for 9 aircraft types (small prop, regional jet, narrow body, wide body, heavy, helicopter, balloon, glider, UAV)
|
||||
- Custom pixel art sprites for 6 aircraft types (small prop, regional jet, narrow body, wide body, heavy, helicopter)
|
||||
- Animated sun and moon with accurate astronomical positions
|
||||
- Dynamic sky colors based on time of day
|
||||
- Weather visualization with cloud sprites
|
||||
- Directional view (N/E/S/W) with themed backgrounds
|
||||
- Auto-discovery of ADS-B receivers on your network, with per-interface scanning
|
||||
- Auto-discovery of ADS-B receivers on your network
|
||||
- Canvas-based 10 FPS retro rendering
|
||||
- Admin panel with password authentication
|
||||
- **In-app pixel editor** — draw and edit sprites in the browser (pencil, shapes, fill, select & move, reference overlay, custom palettes)
|
||||
- **Receiver health dashboard** — live per-receiver status (receiving / no data / unreachable), connection testing, and select → save → apply flow
|
||||
- First-run setup wizard
|
||||
|
||||
## Quick Start
|
||||
@@ -44,16 +42,14 @@ On first run, visit http://localhost:2001 and the setup wizard will guide you th
|
||||
### First Run
|
||||
|
||||
```bash
|
||||
# Build and start — no config step needed
|
||||
# Create a config file (the setup wizard runs if you skip this)
|
||||
cp config.json.example config.json
|
||||
|
||||
# Build and start
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
A config file is created automatically in `data/` on first run, then the
|
||||
browser **setup wizard** walks you through receiver, location, and password
|
||||
setup. The web UI is available at http://localhost:2001.
|
||||
|
||||
A `/health` endpoint (used by the container healthcheck) reports status,
|
||||
version, and receiver/flight counts: `curl http://localhost:2001/health`.
|
||||
The web UI is available at http://localhost:2001.
|
||||
|
||||
### Useful Commands
|
||||
|
||||
@@ -84,11 +80,11 @@ The following paths are bind-mounted from the repo directory and persist across
|
||||
|
||||
| Path | Contents |
|
||||
|------|----------|
|
||||
| `data/` | Server configuration and credentials (`config.json`, auto-seeded) |
|
||||
| `config.json` | Server configuration and credentials |
|
||||
| `images/` | Aircraft and UI sprites (including uploads) |
|
||||
| `backgrounds/` | Theme background images (including custom themes) |
|
||||
|
||||
Host networking (`network_mode: host`) is used so the server can auto-scan your LAN for ADS-B receivers. Auto-scan skips oversized subnets (larger than /20, e.g. a Docker bridge `172.17.0.0/16`); if your receiver lives on such a network, set it explicitly via the admin Receivers tab.
|
||||
Host networking (`network_mode: host`) is used so the server can auto-scan your LAN for ADS-B receivers.
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -106,8 +102,8 @@ ADS-Bit uses a first-run setup wizard to configure your installation. You can al
|
||||
"receiver_port": 30003,
|
||||
"location": {
|
||||
"name": "My Location",
|
||||
"lat": 0.0,
|
||||
"lon": 0.0
|
||||
"lat": 36.2788,
|
||||
"lon": -115.2283
|
||||
},
|
||||
"web_port": 2001,
|
||||
"theme": "desert"
|
||||
|
||||
@@ -169,15 +169,6 @@ textarea {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.admin-version {
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
color: #54fc54;
|
||||
text-shadow: none;
|
||||
margin-left: 6px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/admin/admin.css?v=20260609d">
|
||||
<link rel="stylesheet" href="/admin/admin.css?v=20260609c">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Login Screen -->
|
||||
@@ -27,7 +27,7 @@
|
||||
<!-- Admin Panel -->
|
||||
<div id="admin-panel" class="hidden">
|
||||
<header class="admin-header">
|
||||
<h1 class="retro-title">ADS-Bit Admin <span id="admin-version" class="admin-version"></span></h1>
|
||||
<h1 class="retro-title">ADS-Bit Admin</h1>
|
||||
<div class="header-actions">
|
||||
<a href="/" class="btn btn-small">VIEWER</a>
|
||||
<button id="logout-btn" class="btn btn-small btn-danger">LOGOUT</button>
|
||||
@@ -297,7 +297,7 @@
|
||||
<div id="toast" class="toast hidden"></div>
|
||||
</div>
|
||||
|
||||
<script src="/admin/pixel-editor.js?v=20260609d"></script>
|
||||
<script src="/admin/admin.js?v=20260609d"></script>
|
||||
<script src="/admin/pixel-editor.js?v=20260609c"></script>
|
||||
<script src="/admin/admin.js?v=20260609c"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -28,22 +28,10 @@
|
||||
loadConfig();
|
||||
loadThemes();
|
||||
loadNetworkInfo();
|
||||
loadVersion();
|
||||
refreshStatus();
|
||||
statusInterval = setInterval(refreshStatus, 5000);
|
||||
}
|
||||
|
||||
async function loadVersion() {
|
||||
try {
|
||||
const res = await fetch('/api/config');
|
||||
if (!res.ok) return;
|
||||
const data = await res.json();
|
||||
if (data.version) {
|
||||
document.getElementById('admin-version').textContent = 'v' + data.version;
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
document.getElementById('login-form').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const pw = document.getElementById('login-password').value;
|
||||
|
||||
+2
-4
@@ -6,11 +6,9 @@ services:
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- PYTHONUNBUFFERED=1
|
||||
- ADSBIT_CONFIG=/app/data/config.json
|
||||
volumes:
|
||||
# Config persists here; auto-seeded from config.json.example on first run
|
||||
# (a directory mount, so a fresh `docker compose up` just works).
|
||||
- ./data:/app/data
|
||||
# Persist config (copy config.json.example to config.json before first run)
|
||||
- ./config.json:/app/config.json
|
||||
# Persist custom sprite uploads
|
||||
- ./images:/app/images
|
||||
# Persist custom theme backgrounds
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Seed a config file on first run so `docker compose up` works on a fresh
|
||||
# clone with no manual steps. The config lives on a mounted data volume so it
|
||||
# persists across container rebuilds.
|
||||
set -e
|
||||
|
||||
: "${ADSBIT_CONFIG:=/app/config.json}"
|
||||
CONFIG_DIR=$(dirname "$ADSBIT_CONFIG")
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
|
||||
if [ ! -f "$ADSBIT_CONFIG" ]; then
|
||||
echo "[entrypoint] No config at $ADSBIT_CONFIG — seeding from config.json.example"
|
||||
cp /app/config.json.example "$ADSBIT_CONFIG"
|
||||
fi
|
||||
|
||||
exec python3 server.py
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 264 KiB |
@@ -17,16 +17,8 @@ from aiohttp import web, ClientSession, ClientTimeout
|
||||
import netifaces
|
||||
import bcrypt
|
||||
|
||||
VERSION = "1.1.1"
|
||||
|
||||
WEB_DIR = Path(__file__).parent
|
||||
# Config path is overridable (handy for containers persisting config on a
|
||||
# named volume); defaults to config.json next to this script for bare-metal.
|
||||
CONFIG_FILE = Path(os.environ.get("ADSBIT_CONFIG") or (WEB_DIR / "config.json"))
|
||||
|
||||
# Smallest subnet prefix (largest network) we'll auto-scan: /20 = 4094 hosts.
|
||||
# Anything bigger (e.g. a docker /16) is skipped to keep scans fast and safe.
|
||||
MIN_SCAN_PREFIX = 20
|
||||
CONFIG_FILE = WEB_DIR / "config.json"
|
||||
|
||||
# Track server start time
|
||||
SERVER_START_TIME = time.time()
|
||||
@@ -420,15 +412,6 @@ async def scan_for_receivers():
|
||||
if ip and netmask and not ip.startswith('127.'):
|
||||
try:
|
||||
network = ipaddress.IPv4Network(f"{ip}/{netmask}", strict=False)
|
||||
# Skip subnets too large to scan quickly (e.g. a docker
|
||||
# bridge /16 = 65k hosts). Without this, AUTO discovery
|
||||
# hammers the network and stalls startup on any host with
|
||||
# Docker or a large/16. Use MANUAL or a custom subnet for
|
||||
# receivers that live on such networks.
|
||||
if network.prefixlen < MIN_SCAN_PREFIX:
|
||||
print(f"Skipping {network} on {iface}: too large "
|
||||
f"({network.num_addresses} hosts) for auto-scan")
|
||||
continue
|
||||
found.extend(await _scan_subnet(network, port))
|
||||
except ValueError as e:
|
||||
print(f"Invalid network {ip}/{netmask}: {e}")
|
||||
@@ -566,7 +549,6 @@ async def handle_receiver_location(request):
|
||||
async def handle_config(request):
|
||||
"""Return client-relevant configuration (public, no secrets)."""
|
||||
return web.json_response({
|
||||
"version": VERSION,
|
||||
"theme": config.get("theme", "desert"),
|
||||
"location": config["location"],
|
||||
"receivers": receivers,
|
||||
@@ -999,10 +981,9 @@ async def handle_admin_scan_receivers(request):
|
||||
return web.json_response(
|
||||
{"error": f"Invalid subnet: {subnet}"}, status=400)
|
||||
|
||||
if network.prefixlen < MIN_SCAN_PREFIX:
|
||||
if network.prefixlen < 20:
|
||||
return web.json_response(
|
||||
{"error": f"Subnet too large (max /{MIN_SCAN_PREFIX} = "
|
||||
f"{2 ** (32 - MIN_SCAN_PREFIX) - 2} hosts)"}, status=400)
|
||||
{"error": "Subnet too large (max /20 = 4096 hosts)"}, status=400)
|
||||
|
||||
port = config['receiver_port']
|
||||
found = await _scan_subnet(network, port)
|
||||
@@ -1188,17 +1169,6 @@ async def handle_http(request):
|
||||
return web.Response(status=404, text="Not Found")
|
||||
|
||||
|
||||
async def handle_health(request):
|
||||
"""GET /health - liveness/readiness probe (no auth, no secrets)."""
|
||||
return web.json_response({
|
||||
"status": "ok",
|
||||
"version": VERSION,
|
||||
"receivers": len(receivers),
|
||||
"flights": len(flights),
|
||||
"uptime_seconds": int(time.time() - SERVER_START_TIME),
|
||||
})
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Application setup
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -1211,7 +1181,6 @@ async def start_http_server():
|
||||
app.router.add_get('/ws', websocket_handler)
|
||||
|
||||
# Public API
|
||||
app.router.add_get('/health', handle_health)
|
||||
app.router.add_get('/api/receiver-location', handle_receiver_location)
|
||||
app.router.add_get('/api/config', handle_config)
|
||||
|
||||
@@ -1262,7 +1231,7 @@ async def main():
|
||||
"""Main entry point"""
|
||||
global receivers, receiver_tasks
|
||||
|
||||
print(f"ADS-Bit Server v{VERSION} Starting...")
|
||||
print("ADS-Bit Server Starting...")
|
||||
|
||||
load_config()
|
||||
|
||||
@@ -1310,11 +1279,4 @@ async def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Make SIGTERM (docker stop, systemctl stop) raise KeyboardInterrupt like
|
||||
# SIGINT does, so shutdown is clean and quiet instead of a stack trace.
|
||||
import signal
|
||||
signal.signal(signal.SIGTERM, signal.default_int_handler)
|
||||
try:
|
||||
asyncio.run(main())
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
print("ADS-Bit server shutting down.")
|
||||
|
||||
Reference in New Issue
Block a user