commit
586c194c2a
0
atlas/__init__.py
Normal file
0
atlas/__init__.py
Normal file
21
atlas/admin.py
Normal file
21
atlas/admin.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from admin_extra_buttons.api import ExtraButtonsMixin, button
|
||||
from admin_extra_buttons.utils import HttpResponseRedirectToReferrer
|
||||
from django.contrib import admin
|
||||
from .models import Atlas
|
||||
import atlas.atlascreator as atlascreator
|
||||
import threading
|
||||
|
||||
|
||||
class atlas(ExtraButtonsMixin, admin.ModelAdmin):
|
||||
list_display = ('unicodetld', 'stack', 'measurement', 'lastEdition')
|
||||
|
||||
@button(change_form=True, html_attrs={'style': 'background-color:#88FF88;color:black'})
|
||||
def refresh(self, request):
|
||||
self.message_user(request, 'refresh called')
|
||||
t1 = threading.Thread(target=atlascreator.main())
|
||||
t1.start()
|
||||
# Optional: returns HttpResponse
|
||||
return HttpResponseRedirectToReferrer(request)
|
||||
|
||||
|
||||
admin.site.register(Atlas, atlas)
|
6
atlas/apps.py
Normal file
6
atlas/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AtlasConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'atlas'
|
101
atlas/atlascreator.py
Normal file
101
atlas/atlascreator.py
Normal file
|
@ -0,0 +1,101 @@
|
|||
import requests
|
||||
import config
|
||||
from tldtester.models import TLD
|
||||
from .models import Atlas
|
||||
|
||||
|
||||
def webrequest(tld, stack):
|
||||
description_string = ("DNS measurement for ." + tld + " in IPv" + str(stack))
|
||||
url = "https://atlas.ripe.net/api/v2/measurements/"
|
||||
api_key = config.ATLAS_API
|
||||
headers = {
|
||||
"Authorization": f"Key {api_key}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
data = {
|
||||
"definitions": [
|
||||
{
|
||||
"type": "dns",
|
||||
"af": stack,
|
||||
"resolve_on_probe": True,
|
||||
"description": description_string,
|
||||
"query_class": "IN",
|
||||
"query_type": "SOA",
|
||||
"use_macros": False,
|
||||
"protocol": "UDP",
|
||||
"udp_payload_size": 512,
|
||||
"retry": 0,
|
||||
"skip_dns_check": False,
|
||||
"include_qbuf": False,
|
||||
"include_abuf": True,
|
||||
"prepend_probe_id": False,
|
||||
"set_rd_bit": True,
|
||||
"set_do_bit": False,
|
||||
"set_cd_bit": False,
|
||||
"timeout": 5000,
|
||||
"use_probe_resolver": True,
|
||||
"set_nsid_bit": True,
|
||||
"query_argument": tld
|
||||
}
|
||||
],
|
||||
"probes": [
|
||||
{
|
||||
"type": "msm",
|
||||
"value": 69775666,
|
||||
"requested": 624
|
||||
}
|
||||
],
|
||||
"is_oneoff": True,
|
||||
"bill_to": config.BILLING_RIPE
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
|
||||
if response.status_code == 201:
|
||||
data = (response.json())
|
||||
measurement = data['measurements'][0]
|
||||
else:
|
||||
measurement = None
|
||||
dbwriter(tld, stack, measurement)
|
||||
|
||||
|
||||
def dbwriter(unicodetld, stack, measurement):
|
||||
tld = Atlas.objects.filter(unicodetld=unicodetld)
|
||||
tldstack = tld.filter(stack=stack)
|
||||
if tldstack.exists():
|
||||
primary_key = tldstack.values_list('pk', flat=True).first()
|
||||
db = Atlas.objects.get(pk=primary_key)
|
||||
else:
|
||||
db = Atlas()
|
||||
db.unicodetld = unicodetld
|
||||
db.stack = stack
|
||||
db.measurement = measurement
|
||||
db.save()
|
||||
tld = TLD.objects.filter(unicodetld=unicodetld)
|
||||
if tld.exists():
|
||||
primary_key = tld.values_list('pk', flat=True).first()
|
||||
db = TLD.objects.get(pk=primary_key)
|
||||
if stack == 4:
|
||||
db.atlasv4 = measurement
|
||||
db.save()
|
||||
elif stack == 6:
|
||||
db.atlasv6 = measurement
|
||||
db.save()
|
||||
else:
|
||||
print("Unknown IP version")
|
||||
|
||||
|
||||
def main():
|
||||
unicodetlds = []
|
||||
# This will get the TLD's in unicode format from the database and put them in the list
|
||||
tlds = TLD.objects.all().order_by('tld')
|
||||
for tld in tlds:
|
||||
db = TLD.objects.get(tld=tld)
|
||||
unicodetlds.append(db.unicodetld)
|
||||
for tld in unicodetlds:
|
||||
webrequest(tld, 4)
|
||||
webrequest(tld, 6)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
0
atlas/migrations/__init__.py
Normal file
0
atlas/migrations/__init__.py
Normal file
17
atlas/models.py
Normal file
17
atlas/models.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class Atlas(models.Model):
|
||||
STACK = ((0, "Unknown"), (4, "IPv4"), (6, "IPv6"))
|
||||
unicodetld = models.CharField(max_length=100)
|
||||
stack = models.IntegerField(default=0, choices=STACK)
|
||||
measurement = models.IntegerField(default=0, blank=True, null=True)
|
||||
lastEdition = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.unicodetld
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
models.Index(fields=['stack', 'unicodetld']),
|
||||
]
|
3
atlas/tests.py
Normal file
3
atlas/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
atlas/views.py
Normal file
3
atlas/views.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
|
@ -9,3 +9,7 @@ DBUSER = "tldtest"
|
|||
DBPASSWORD = "clubmate2010"
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = []
|
||||
|
||||
ATLAS_API = ""
|
||||
|
||||
BILLING_RIPE = ""
|
||||
|
|
|
@ -801,6 +801,10 @@ video {
|
|||
color: rgb(255 255 255 / var(--tw-text-opacity));
|
||||
}
|
||||
|
||||
.underline {
|
||||
text-decoration-line: underline;
|
||||
}
|
||||
|
||||
.shadow {
|
||||
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
||||
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
|
||||
|
|
1
staticfiles/CACHE/css/output.184c6e037351.css
Normal file
1
staticfiles/CACHE/css/output.184c6e037351.css
Normal file
File diff suppressed because one or more lines are too long
1
staticfiles/CACHE/css/output.4e2760cc9291.css
Normal file
1
staticfiles/CACHE/css/output.4e2760cc9291.css
Normal file
File diff suppressed because one or more lines are too long
1
staticfiles/CACHE/css/output.d6040720db0c.css
Normal file
1
staticfiles/CACHE/css/output.d6040720db0c.css
Normal file
File diff suppressed because one or more lines are too long
1
staticfiles/CACHE/css/output.e2ebb4dc4350.css
Normal file
1
staticfiles/CACHE/css/output.e2ebb4dc4350.css
Normal file
File diff suppressed because one or more lines are too long
1
staticfiles/CACHE/css/output.f2a7c333645b.css
Normal file
1
staticfiles/CACHE/css/output.f2a7c333645b.css
Normal file
File diff suppressed because one or more lines are too long
|
@ -801,6 +801,10 @@ video {
|
|||
color: rgb(255 255 255 / var(--tw-text-opacity));
|
||||
}
|
||||
|
||||
.underline {
|
||||
text-decoration-line: underline;
|
||||
}
|
||||
|
||||
.shadow {
|
||||
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
||||
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
|
||||
|
|
|
@ -40,6 +40,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.staticfiles',
|
||||
'admin_extra_buttons',
|
||||
'tldtester.apps.TldtesterConfig',
|
||||
'atlas.apps.AtlasConfig',
|
||||
'tldtest',
|
||||
'compressor',
|
||||
'rest_framework',
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
<table class="table-auto border-separate border border-slate-500">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="border border-slate-600">Top Level Domain</th>
|
||||
<th class="border border-slate-600 text-l-blue-600">Total servers</th>
|
||||
<th class="border border-slate-600">TLD</th>
|
||||
<th class="border border-slate-600 text-l-blue-600"># Servers</th>
|
||||
<th class="border border-slate-600 text-red-700">IPv4</th>
|
||||
<th class="border border-slate-600 text-green-600">IPv6</th>
|
||||
<th class="border border-slate-600">Strongest DNSSEC algo</th>
|
||||
<th class="border border-slate-600"># DNSSEC keys</th>
|
||||
<th class="border border-slate-600"># keys</th>
|
||||
<th class="border border-slate-600">RDAP</th>
|
||||
<th class="border border-slate-600">latency-map</th>
|
||||
<th class="border border-slate-600">Organisation</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -31,6 +32,7 @@
|
|||
{% else %}
|
||||
<td class="border border-slate-700 text-red-700">{{ TLD.rdap }}</td>
|
||||
{% endif %}
|
||||
<td class="border border-slate-700"><a class="text-red-700 underline" href="https://atlas.ripe.net/measurementdetail/{{ TLD.atlasv4 }}" target="_blank">IPv4</a> <a class="text-green-600 underline" href="https://atlas.ripe.net/measurementdetail/{{ TLD.atlasv6 }}" target="_blank">IPv6</a></td>
|
||||
<td class="border border-slate-700"><a href="{{ TLD.link }}"
|
||||
class="font-medium text-blue-600 dark:text-blue-500 hover:underline"
|
||||
target="_blank"
|
||||
|
|
|
@ -7,7 +7,7 @@ import threading
|
|||
|
||||
|
||||
class tlds(ExtraButtonsMixin, admin.ModelAdmin):
|
||||
list_display = ('tld', 'nsamount', 'v4nsamount', 'v6nsamount', 'dnssec', 'lastEdition')
|
||||
list_display = ('tld', 'nsamount', 'v4nsamount', 'v6nsamount', 'dnssec', 'atlasv4', 'atlasv6', 'lastEdition')
|
||||
|
||||
@button(change_form=True, html_attrs={'style': 'background-color:#88FF88;color:black'})
|
||||
def refresh(self, request):
|
||||
|
|
|
@ -39,6 +39,8 @@ class TLD(models.Model):
|
|||
organisation = models.CharField(max_length=100)
|
||||
rdap = models.CharField(max_length=10, default="No")
|
||||
link = models.CharField(max_length=800, default="https://tldtest.net/")
|
||||
atlasv4 = models.IntegerField(default=0, blank=True, null=True)
|
||||
atlasv6 = models.IntegerField(default=0, blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.tld
|
||||
|
|
Loading…
Reference in a new issue