dnmapper/bgpdata/views.py

46 lines
1.5 KiB
Python
Raw Normal View History

2018-01-19 13:28:52 +01:00
# This file is part of dnmapper, an AS--level mapping tool
# Licensed under GNU General Public License v3 or later
# Written by Sebastian Lohff (seba@someserver.de)
2015-03-23 01:42:31 +01:00
from django.shortcuts import render
2017-01-14 00:15:21 +01:00
from django.core.paginator import Paginator
2015-03-23 01:42:31 +01:00
2020-06-10 03:12:23 +02:00
from bgpdata.models import CrawlRun, AS, Peering, ASLastSeen
from backend import crawler
2015-03-27 15:33:54 +01:00
def overview(request):
crawls = CrawlRun.objects.order_by("-startTime")
crawlsPage = Paginator(crawls, 200)
return render(request, 'bgpdata/overview.html', {"crawls": crawlsPage.page(1)})
2015-03-27 15:33:54 +01:00
2015-03-27 15:33:54 +01:00
def showMap(request, crawlId):
crawl = None
try:
crawl = CrawlRun.objects.get(id=crawlId)
except CrawlRun.DoesNotExist:
return render(request, "bgpdata/no-map-found.html", {"crawl_id": crawlId})
2015-03-28 22:12:42 +01:00
ASses = AS.objects.filter(crawl=crawl)
peerings = Peering.objects.filter(as1__crawl=crawl)
2015-03-27 15:33:54 +01:00
return render(request, 'bgpdata/map.html', {"crawl": crawl, 'ASses': ASses, 'peerings': peerings})
def show_new_map(request, crawl_id):
crawl = None
if crawl_id == 'live':
net = crawler.get_current_network()
crawl = crawler.make_crawl_from_net(net)
else:
try:
crawl = CrawlRun.objects.get(id=crawl_id)
except CrawlRun.DoesNotExist:
return render(request, "bgpdata/no-map-found.html", {"crawl_id": crawl_id})
return render(request, 'bgpdata/new_new_map.html', {"crawl": crawl})
2020-06-10 03:12:23 +02:00
def show_asn_last_seen(request):
return render(request, 'bgpdata/asn_last_seen.html', {'last_seen': ASLastSeen.objects.order_by("asn")})