feat: add IPv4 address space graph with interactive tooltip

This commit is contained in:
zwitschi committed 2026-08-06 11:45:24 +02:00
1 parent 51f57f7a04
commit 94f62ae591
6 files changed
+609 -3

No files matched your search

+37
View File
@@ -143,6 +143,10 @@ def create_app() -> Flask:
"""Build and configure the Flask application."""
app = Flask(__name__)
# Seed the in-memory job store from disk so the dashboard keeps showing
# recent scans across server restarts.
web_scan.load_persisted()
@app.get("/")
def index():
return render_template("dashboard.html")
@@ -167,6 +171,10 @@ def create_app() -> Flask:
def whitelist_page():
return render_template("whitelist.html", whitelist_names=WHITELIST_NAMES)
@app.get("/graph")
def graph_page():
return render_template("graph.html")
# --- status ------------------------------------------------------------
@app.get("/api/status")
@@ -284,6 +292,35 @@ def create_app() -> Flask:
return _with_router(_remove)
# --- graph --------------------------------------------------------------
@app.get("/api/graph/ipv4")
def graph_ipv4():
"""Data for the IPv4 /8 tile map.
Blocked targets come from the consolidated blocklist
(``reports/app/data/blocklist_ipv4.txt``); whitelisted ranges from the
router snapshot (``data/mikrotik/address_list_ipv4.json``) filtered to
the configured whitelist address-list names.
"""
blocked = _read_lines(
os.path.join(APP_REPORT_DATA_DIR, "blocklist_ipv4.txt"))
addr_v4 = _read_json(
os.path.join(MIKROTIK_DATA_DIR, "address_list_ipv4.json"))
whitelisted = sorted({e.get("address") for e in addr_v4
if e.get("list") in WHITELIST_NAMES
and e.get("address")})
return jsonify({
"blocked": blocked,
"whitelisted": whitelisted,
"counts": {
"blocked": len(blocked),
"whitelisted": len(whitelisted),
},
"blocklist_name": BLOCKLIST_NAME,
"whitelist_names": WHITELIST_NAMES,
})
# --- firewall ----------------------------------------------------------
@app.get("/api/firewall/state")