Merge branch 'master' into feat/ssrf-ingest-source-whitelist

This commit is contained in:
sirius 2026-09-01 00:54:05 -04:00
commit 622c548792
16 changed files with 91 additions and 691 deletions

View file

@ -26,7 +26,7 @@ from uuid import UUID
import httpx
import structlog
from fastapi import BackgroundTasks, FastAPI, HTTPException, Query, WebSocket, WebSocketDisconnect
from fastapi import FastAPI, HTTPException, Query, WebSocket, WebSocketDisconnect
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse
from fastapi.staticfiles import StaticFiles
@ -871,21 +871,6 @@ async def trigger_social_ingest(query: str = "", max_items: int = 50):
return {"status": "ok", "signals_ingested": count}
@app.post("/api/ingest/masscan")
async def trigger_masscan(background_tasks: BackgroundTasks):
"""Queue one masscan pass at ≤200 pps. Does not block the request on the scan."""
from bg_jobs import MASSCAN_PPS_CAP, schedule_masscan_pass
async def _kick() -> None:
schedule_masscan_pass()
background_tasks.add_task(_kick)
return JSONResponse(
{"status": "accepted", "rate_pps": MASSCAN_PPS_CAP},
status_code=202,
)
@app.websocket("/ws/live")
async def live_ws(ws: WebSocket):
"""Viewport-filtered AIS/ADS-B fan-out. Client sends {type:viewport,bbox}."""
@ -1065,7 +1050,7 @@ async def list_cameras(
True,
description="Only cameras with a verified HTTP/MJPEG snapshot_url "
"(the ones that actually preview). Set false to include "
"unverified masscan port-554 hits.",
"rows without a snapshot_url.",
),
limit: int = Query(500, ge=1, le=5000),
):
@ -1142,7 +1127,7 @@ async def get_camera(camera_id: UUID):
async def camera_snapshot(camera_id: UUID):
"""Still image for one camera.
HTTP cameras go through the TTL cache. masscan/RTSP finds have no HTTP
HTTP cameras go through the TTL cache. RTSP finds have no HTTP
snapshot_url — we probe common still-image paths and, failing that, grab
one JPEG frame from RTSP via ffmpeg. No credentials are tried.
"""
@ -2006,4 +1991,4 @@ app.mount("/static", CachedStaticFiles(directory=str(STATIC_DIR)), name="static"
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
uvicorn.run(app, host="0.0.0.0", port=8000, workers=1) # single worker: in-memory WS/pubsub + layer caches