diff --git a/main.py b/main.py index 81476ec..41141d8 100644 --- a/main.py +++ b/main.py @@ -139,39 +139,35 @@ def check_list_of_prefixes_against_ROA(origin, prefixes, origins, roa_prefix, ro existing_roa_status]) return messages -@app.route('/', methods=['GET', 'POST']) -def index(): - """ main function to handle the web page - :return: web page - """ +@app.route('/results', methods=['GET']) +def results(): + """ process the form data and return the results """ + if request.method == 'GET': - if request.method == 'POST': - # Get the user input - roa_ip_prefix = request.form['ip_prefix'] + roa_ip_prefix = request.args.get('ip_prefix') roa_ip_prefix = roa_ip_prefix.strip() - # Validate the IP prefix - if not is_valid_prefix(roa_ip_prefix): - return f"\"{roa_ip_prefix}\" is an Invalid IP prefix" - - origin_asn = request.form['origin_asn'] + origin_asn = request.args.get('origin_asn') origin_asn = origin_asn.strip() - origin_asn = get_asn_from_as(origin_asn) + roa_origin_asn = origin_asn + roa_prefix_maxlength = request.args.get('prefix_maxlength') + roa_prefix_maxlength = roa_prefix_maxlength.strip() + # Validate the IP prefix + if not is_valid_prefix(roa_ip_prefix): + return f"\"{roa_ip_prefix}\" is an Invalid IP prefix" + # Validate the origin ASN if not is_valid_asn(origin_asn): return f"\"{origin_asn}\" is an Invalid origin ASN" - roa_prefix_maxlength = request.form['prefix_maxlength'] - roa_prefix_maxlength = roa_prefix_maxlength.strip() + # Validate the prefix maxlength if not is_valid_prefix_maxlength(roa_ip_prefix, roa_prefix_maxlength): return f"\"{roa_prefix_maxlength}\" is an Invalid prefix maxlength" - roa_ip_prefix = request.form['ip_prefix'] - roa_prefix_maxlength = int(request.form['prefix_maxlength']) - roa_origin_asn = request.form['origin_asn'] - roa_origin_asn = get_asn_from_as(roa_origin_asn) + roa_prefix_maxlength = int(roa_prefix_maxlength) + prefix_info = get_prefix_info(roa_ip_prefix) if prefix_info is None: return "Prefix not found or problems with RIPEstat API" @@ -184,6 +180,10 @@ def index(): else: return render_template('index.html') +@app.route('/', methods=['GET']) +def index(): + return render_template('index.html') + if __name__ == '__main__': print("new version - ssw") app.run(port=8000, host='0.0.0.0') diff --git a/templates/index.html b/templates/index.html index 1d00251..1f7647e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -43,14 +43,14 @@

This app queries the stat.ripe.net to determine if a RPKI-ROA created with the following information
would likely agree (i.e., not evaluate as invalid) for routes currently seen in the Internet

-
+ > - + - + - - + +
diff --git a/templates/results.html b/templates/results.html new file mode 100644 index 0000000..8a353b2 --- /dev/null +++ b/templates/results.html @@ -0,0 +1,51 @@ + + + + + Title + + +
+

Proposed ROA Prefix = {{ roa_info[0] }}

+

Max Length = {{ roa_info[1]}}

+

and origin ASN = {{roa_info[2] }}

+
+ + + + + + + + + + + + {% for item in items %} + + + + {% if item[1] == "invalid" %} + + {% elif item[1] =="valid" %} + + {% else %} + + {% endif %} + + {% if item[3] == "valid" %} + + {% elif item[3] == "invalid" %} + + {% else %} + + {% endif %} + + + {% endfor %} + +
The first row is the prefix specified in the proposed ROA. + Subsequent lines list more specifics that are seen in the global routing table.If you create the proposed ROA, this is how it would be evaluated for each prefix.For this prefix, this is the origin ASN as seen in the global Internet.This is the status of this prefix due to an existing ROA.
{{ item[0] }}{{ item[1] }}{{ item[1] }}{{ item[1] }}{{ item[2] }}{{ item[3] }}{{ item[3] }}{{ item[3] }}
+ + + \ No newline at end of file