Update app.py

This commit is contained in:
Blackwhitebear8 2025-10-31 21:04:03 +01:00
parent 652290f9e8
commit 17913ba6f3

39
app.py
View file

@ -9,7 +9,17 @@ from datetime import datetime, timedelta
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,run_firewall_ipv4_curl_command, run_firewall_ipv6_curl_command, run_bgp_reset_command, run_bgp_shutdown_command, run_bgp_enable_command, run_firewall_log_curl_command, run_dhcpv6_leases_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, run_bgp_reset_command,
run_bgp_shutdown_command, run_bgp_enable_command,
run_firewall_log_curl_command, run_dhcpv6_leases_curl_command
)
from modules.bgp import parse_bgp_data, generate_bgp_json
from modules.arp import parse_arp_data, generate_arp_json
from modules.neighbors import parse_neighbors_data, generate_neighbors_json
@ -23,6 +33,8 @@ from modules.firewall import parse_firewall_data, parse_firewall_log_data
from modules.visual_route import generate_visual_route_graph
from modules.database import get_peer_history, get_total_routes_history, get_unique_peers
from modules.dhcpv6 import parse_dhcpv6_leases_data, generate_dhcpv6_leases_json
from modules.irr_tools import make_irr_api_request
@app.context_processor
def inject_global_vars():
@ -471,4 +483,27 @@ def dhcpv6_leases_json():
leases_table = parse_dhcpv6_leases_data(leases_data)
return jsonify(generate_dhcpv6_leases_json(leases_table))
except Exception as e:
return jsonify({"error": str(e)}), 500
return jsonify({"error": str(e)}), 500
@app.route('/irr-tools')
def irr_tools_page():
data = make_irr_api_request('GET', '/asns')
content = data.get('content', '')
error = data.get('error')
return render_template('irr_tools.html', asns_content=content, error=error)
@app.route('/irr-tools/save', methods=['POST'])
def irr_tools_save():
content = request.json.get('content')
result = make_irr_api_request('POST', '/asns', json_data={"content": content})
return jsonify(result)
@app.route('/irr-tools/run', methods=['POST'])
def irr_tools_run():
result = make_irr_api_request('POST', '/run-update')
return jsonify(result)
@app.route('/irr-tools/log', methods=['GET'])
def irr_tools_log():
result = make_irr_api_request('GET', '/log')
return jsonify(result)