From dee5ddd7edab6e88420c6a9b6b4ad321bd5972c5 Mon Sep 17 00:00:00 2001 From: Blackwhitebear8 Date: Wed, 13 Aug 2025 16:25:49 +0200 Subject: [PATCH] Update app.py --- app.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 21e217a..ec5e6d3 100644 --- a/app.py +++ b/app.py @@ -8,7 +8,7 @@ from flask import Flask, render_template_string, jsonify, url_for, redirect, ren app = Flask(__name__) -from modules.parse import run_bgp_curl_command, run_arp_curl_command, run_neighbors_curl_command, run_interfaces_curl_command, run_bgp_route_curl_command, run_rpki_cache_connection_curl_command, run_rpki_lookup_curl_command, run_bgp_neighbor_detail_curl_command, run_bfd_peers_curl_command, run_bfd_peer_detail_curl_command, run_bgp_dampeningv4_curl_command, run_bgp_dampeningv6_curl_command +from modules.parse import run_bgp_curl_command, run_arp_curl_command, run_neighbors_curl_command, run_interfaces_curl_command, run_bgp_route_curl_command, run_rpki_cache_connection_curl_command, run_rpki_lookup_curl_command, run_bgp_neighbor_detail_curl_command, run_bfd_peers_curl_command, run_bfd_peer_detail_curl_command, run_bgp_dampeningv4_curl_command, run_bgp_dampeningv6_curl_command,run_firewall_ipv4_curl_command, run_firewall_ipv6_curl_command from modules.bgp import parse_bgp_data, generate_bgp_json @@ -28,6 +28,8 @@ from modules.bfd import parse_bfd_peers_data from modules.bgp_dampening import parse_dampened_data, generate_dampened_json +from modules.firewall import parse_firewall_data + from modules.visual_route import generate_visual_route_graph @app.context_processor @@ -273,4 +275,21 @@ def visual_route_graph(): if "error" in graph_data: return jsonify(graph_data), 400 - return jsonify(graph_data) \ No newline at end of file + return jsonify(graph_data) + +@app.route('/firewall') +def firewall_page(): + return render_template("firewall.html") + +@app.route('/firewall/json') +def firewall_json(): + try: + ipv4_raw = run_firewall_ipv4_curl_command() + ipv6_raw = run_firewall_ipv6_curl_command() + + ipv4_rulesets = parse_firewall_data(ipv4_raw) + ipv6_rulesets = parse_firewall_data(ipv6_raw) + + return jsonify({"ipv4": ipv4_rulesets, "ipv6": ipv6_rulesets}) + except Exception as e: + return jsonify({"error": "Failed to retrieve firewall data.", "details": str(e)}), 500 \ No newline at end of file