1
0
Fork 0
mirror of https://github.com/sileht/bird-lg.git synced 2024-11-10 17:54:43 +01:00

Add prepend info on graph

This commit is contained in:
root 2016-03-02 09:46:51 +01:00
parent 6a7bd7f228
commit f0058c6a41
2 changed files with 15 additions and 3 deletions

16
lg.py
View file

@ -20,6 +20,7 @@
# #
### ###
from datetime import datetime
import memcache import memcache
import subprocess import subprocess
import logging import logging
@ -406,6 +407,7 @@ def show_bgpmap():
nodes = {} nodes = {}
edges = {} edges = {}
prepend_as = {}
def escape(label): def escape(label):
label = label.replace("&", "&") label = label.replace("&", "&")
@ -465,6 +467,7 @@ def show_bgpmap():
hop_label = "" hop_label = ""
for _as in asmap: for _as in asmap:
if _as == previous_as: if _as == previous_as:
prepend_as[_as] = prepend_as.get(_as, 1) + 1
continue continue
if not hop: if not hop:
@ -500,8 +503,17 @@ def show_bgpmap():
node = add_node(previous_as) node = add_node(previous_as)
node.set_shape("box") node.set_shape("box")
#return Response("<pre>" + graph.create_dot() + "</pre>") for _as in prepend_as:
return Response(graph.create_png(), mimetype='image/png') graph.add_edge(pydot.Edge(*(_as, _as), label=" %dx" % prepend_as[_as], color="grey", fontcolor="grey"))
#response = Response("<pre>" + graph.create_dot() + "</pre>")
response = Response(graph.create_png(), mimetype='image/png')
response.headers['Last-Modified'] = datetime.now()
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
response.headers['Pragma'] = 'no-cache'
response.headers['Expires'] = '-1'
return response
def build_as_tree_from_raw_bird_ouput(host, proto, text): def build_as_tree_from_raw_bird_ouput(host, proto, text):

View file

@ -4,6 +4,6 @@
{% if session.request_args != expression|replace("/32","")|replace("/128","") %} {% if session.request_args != expression|replace("/32","")|replace("/128","") %}
<i>DNS: <a href="/whois/{{session.request_args}}" class="whois">{{session.request_args}}</a> => <a href="/whois/{{ expression|replace("/32","")|replace("/128","") }}" class="whois">{{expression|replace("/32","")|replace("/128","")}}</a></i><br /> <i>DNS: <a href="/whois/{{session.request_args}}" class="whois">{{session.request_args}}</a> => <a href="/whois/{{ expression|replace("/32","")|replace("/128","") }}" class="whois">{{expression|replace("/32","")|replace("/128","")}}</a></i><br />
{% endif %}<br /> {% endif %}<br />
<a href="/bgpmap/?q={{detail}}"><img src="/bgpmap/?q={{detail}}" /></a> <a href="/bgpmap/?killcache=1&q={{detail}}"><img src="/bgpmap/?q={{detail}}" /></a>
<br /> <br />
{% endblock %} {% endblock %}