espilon-source/tools/C3PO/web/routes/api_tunnel.py
Eun0us 79c2a4d4bf c3po: full server rewrite with modular routes and honeypot dashboard
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.
2026-02-28 20:12:27 +01:00

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