Replace monolithic CLI and web server with route-based Flask API. New routes: api_commands, api_build, api_can, api_monitor, api_ota, api_tunnel. Add honeypot security dashboard with real-time SSE, MITRE ATT&CK mapping, kill chain analysis. New TUI with commander/help modules. Add session management, tunnel proxy core, CAN bus data store. Docker support.
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""Flask API routes for tunnel/SOCKS5 proxy management."""
|
|
|
|
from flask import Blueprint, jsonify, request
|
|
|
|
|
|
def create_tunnel_blueprint(session):
|
|
bp = Blueprint("api_tunnel", __name__)
|
|
|
|
@bp.route("/api/tunnel/status")
|
|
def tunnel_status():
|
|
tunnel = getattr(session, "tunnel_server", None)
|
|
if tunnel is None:
|
|
return jsonify({"error": "tunnel server not initialized"}), 503
|
|
return jsonify(tunnel.get_status())
|
|
|
|
@bp.route("/api/tunnel/active", methods=["POST"])
|
|
def tunnel_set_active():
|
|
"""Switch SOCKS5 traffic to a different device."""
|
|
tunnel = getattr(session, "tunnel_server", None)
|
|
if tunnel is None:
|
|
return jsonify({"error": "tunnel server not initialized"}), 503
|
|
|
|
data = request.get_json(silent=True) or {}
|
|
device_id = data.get("device_id")
|
|
if not device_id:
|
|
return jsonify({"error": "device_id required"}), 400
|
|
|
|
if tunnel.set_active_device(device_id):
|
|
return jsonify({"status": "ok", "active_device": device_id})
|
|
return jsonify({"error": f"device '{device_id}' not connected"}), 404
|
|
|
|
return bp
|