46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
# 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)
|
|
from django.shortcuts import render
|
|
from django.core.paginator import Paginator
|
|
|
|
from bgpdata.models import CrawlRun, AS, Peering, ASLastSeen
|
|
from backend import crawler
|
|
|
|
|
|
def overview(request):
|
|
crawls = CrawlRun.objects.order_by("-startTime")
|
|
crawlsPage = Paginator(crawls, 200)
|
|
return render(request, 'bgpdata/overview.html', {"crawls": crawlsPage.page(1)})
|
|
|
|
|
|
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})
|
|
|
|
ASses = AS.objects.filter(crawl=crawl)
|
|
peerings = Peering.objects.filter(as1__crawl=crawl)
|
|
|
|
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})
|
|
|
|
|
|
def show_asn_last_seen(request):
|
|
return render(request, 'bgpdata/asn_last_seen.html', {'last_seen': ASLastSeen.objects.order_by("asn")})
|