Update app.py

This commit is contained in:
Blackwhitebear8 2025-08-14 18:15:25 +02:00
parent a5412391d4
commit a092c7010e

15
app.py
View file

@ -104,6 +104,21 @@ def execute_command():
if error:
return jsonify({"error": error}), 400
ipv4_commands = ['ping', 'mtr', 'traceroute']
ipv6_commands = ['ping6', 'mtr6', 'traceroute6']
try:
ip = ipaddress.ip_address(target)
if method in ipv6_commands and ip.version == 4:
return jsonify({"error": f"An IPv6 address is required for the '{method}' command."}), 400
if method in ipv4_commands and ip.version == 6:
return jsonify({"error": f"An IPv4 address is required for the '{method}' command."}), 400
except ValueError:
pass
return Response(execute_command_streaming(method, target), mimetype='text/plain')
@app.route('/api/bgp_raw_lookup', methods=['POST'])