Network monitor: hub, probes, Docker and native installers
Hub (FastAPI + no-build web UI): - Network health: live probe/target matrix, status strips, incidents - Probes: add (with install command), rename, remove, latency and throughput charts - Clients merged from AdGuard, DHCP, query log and probe ARP tables; names, categories, suspicious flag, notes, per-client DNS requests - Query log, domain detail (clients, related subdomains), blocked domains via the AdGuard Home /control API Probe: tests peers (ping, HTTP, throughput), gateway, LAN and public DNS, internet URLs and an optional VPS; buffers results while the hub is down. Gateway and ARP from /proc/net on Linux, route/arp on macOS. Install: install.sh (hub) and install-probe.sh (generated from it), each in docker mode (compose; default on Linux hosts) or native mode (venv + systemd or launchd; default on macOS and in LXC). Both modes deploy with an update command that checks the new commit and rolls back on failure. CLAUDE.md carries shared context for Claude Code sessions on each machine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
54a765510a
63 changed files with 6464 additions and 0 deletions
28
app/main.py
Normal file
28
app/main.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"""Entry point for both roles. ROLE=hub (the default) serves the web UI and API;
|
||||
ROLE=probe runs a network probe. `update` imports this module as its pre-flight check."""
|
||||
|
||||
import contextlib
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
if os.environ.get("ROLE", "hub").strip().lower() == "probe":
|
||||
from app.probe.server import app
|
||||
else:
|
||||
from app.hub.server import app
|
||||
|
||||
DATA_DIR = Path(os.environ.get("DATA_DIR", "data"))
|
||||
_role_lifespan = app.router.lifespan_context
|
||||
|
||||
|
||||
@contextlib.asynccontextmanager
|
||||
async def lifespan(a):
|
||||
# Startup work goes here, not at import time: `update` imports this module as a check
|
||||
# before restarting. Shared by both roles; each role's own startup runs inside.
|
||||
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
||||
async with _role_lifespan(a):
|
||||
yield
|
||||
|
||||
|
||||
app.router.lifespan_context = lifespan
|
||||
|
||||
__all__ = ["app"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue