commit
49c565a6b1
|
@ -2,6 +2,7 @@ asgiref==3.7.2
|
||||||
build==1.0.3
|
build==1.0.3
|
||||||
click==8.1.7
|
click==8.1.7
|
||||||
Django==5.0.2
|
Django==5.0.2
|
||||||
|
django-admin-extra-buttons==1.5.7
|
||||||
flake8==7.0.0
|
flake8==7.0.0
|
||||||
mccabe==0.7.0
|
mccabe==0.7.0
|
||||||
packaging==23.2
|
packaging==23.2
|
||||||
|
@ -10,3 +11,4 @@ pycodestyle==2.11.1
|
||||||
pyflakes==3.2.0
|
pyflakes==3.2.0
|
||||||
pyproject_hooks==1.0.0
|
pyproject_hooks==1.0.0
|
||||||
sqlparse==0.4.4
|
sqlparse==0.4.4
|
||||||
|
zonefile-parser==0.1.14
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# This file is autogenerated by pip-compile with Python 3.11
|
# This file is autogenerated by pip-compile with Python 3.12
|
||||||
# by the following command:
|
# by the following command:
|
||||||
#
|
#
|
||||||
# pip-compile --output-file=requirements.txt requirements.in
|
# pip-compile --output-file=requirements.txt requirements.in
|
||||||
|
@ -18,6 +18,8 @@ click==8.1.7
|
||||||
# pip-tools
|
# pip-tools
|
||||||
django==5.0.2
|
django==5.0.2
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
|
django-admin-extra-buttons==1.5.7
|
||||||
|
# via -r requirements.in
|
||||||
flake8==7.0.0
|
flake8==7.0.0
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
mccabe==0.7.0
|
mccabe==0.7.0
|
||||||
|
@ -48,6 +50,8 @@ sqlparse==0.4.4
|
||||||
# django
|
# django
|
||||||
wheel==0.42.0
|
wheel==0.42.0
|
||||||
# via pip-tools
|
# via pip-tools
|
||||||
|
zonefile-parser==0.1.14
|
||||||
|
# via -r requirements.in
|
||||||
|
|
||||||
# The following packages are considered to be unsafe in a requirements file:
|
# The following packages are considered to be unsafe in a requirements file:
|
||||||
# pip
|
# pip
|
||||||
|
|
|
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'admin_extra_buttons',
|
||||||
'tldtester',
|
'tldtester',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,25 @@
|
||||||
|
from admin_extra_buttons.api import ExtraButtonsMixin, button
|
||||||
|
from admin_extra_buttons.utils import HttpResponseRedirectToReferrer
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import TLD
|
from .models import TLD
|
||||||
|
from .models import zonecontent
|
||||||
|
import tldtester.sorter as sorter
|
||||||
|
|
||||||
|
|
||||||
class tlds(admin.ModelAdmin):
|
class tlds(admin.ModelAdmin):
|
||||||
list_display = ('tld', 'inet', 'dnssec', 'lastEdition')
|
list_display = ('tld', 'inet', 'dnssec', 'lastEdition')
|
||||||
|
|
||||||
|
|
||||||
|
class zone(ExtraButtonsMixin, admin.ModelAdmin):
|
||||||
|
list_display = ('name', 'rtype', 'rclass', 'ttl', 'data', 'lastEdition')
|
||||||
|
|
||||||
|
@button(change_form=True, html_attrs={'style': 'background-color:#88FF88;color:black'})
|
||||||
|
def refresh(self, request):
|
||||||
|
self.message_user(request, 'refresh called')
|
||||||
|
sorter.main()
|
||||||
|
# Optional: returns HttpResponse
|
||||||
|
return HttpResponseRedirectToReferrer(request)
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(TLD, tlds)
|
admin.site.register(TLD, tlds)
|
||||||
|
admin.site.register(zonecontent, zone)
|
||||||
|
|
27
tldtester/migrations/0001_initial.py
Normal file
27
tldtester/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Generated by Django 5.0.2 on 2024-02-12 16:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TLD',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('tld', models.CharField(max_length=30)),
|
||||||
|
('dnssec', models.IntegerField(choices=[(0, 'Delete DS'), (1, 'RSA/MD5'), (2, 'Diffie-Hellman'), (3, 'DSA/SHA1'), (5, 'RSA/SHA-1'), (6, 'DSA-NSEC3-SHA1'), (7, 'RSASHA1-NSEC3-SHA1'), (8, 'RSA/SHA-256'), (10, 'RSA/SHA-512'), (12, 'GOST R 34.10-2001'), (13, 'ECDSA Curve P-256 with SHA-256'), (14, 'ECDSA Curve P-384 with SHA-384'), (15, 'Ed25519'), (16, 'Ed448'), (17, 'SM2 signing algorithm with SM3 hashing algorithm'), (23, 'GOST R 34.10-2012'), (252, 'Reserved for Indirect Keys'), (253, 'private algorithm'), (254, 'private algorithm OID'), (300, 'Unknown')], default=300)),
|
||||||
|
('inet', models.IntegerField(choices=[(0, 'IPv4'), (1, 'IPv6'), (2, 'IPv4 + IPv6')], default=0)),
|
||||||
|
('lastEdition', models.DateTimeField(auto_now=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'indexes': [models.Index(fields=['tld'], name='tldtester_t_tld_b4cdc5_idx'), models.Index(fields=['dnssec'], name='tldtester_t_dnssec_694343_idx'), models.Index(fields=['inet'], name='tldtester_t_inet_b6132b_idx')],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
24
tldtester/migrations/0002_zonecontent.py
Normal file
24
tldtester/migrations/0002_zonecontent.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Generated by Django 5.0.2 on 2024-02-12 19:45
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('tldtester', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='zonecontent',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('rtype', models.CharField(max_length=10)),
|
||||||
|
('name', models.CharField(max_length=100)),
|
||||||
|
('rclass', models.CharField(max_length=10)),
|
||||||
|
('ttl', models.IntegerField(default=0)),
|
||||||
|
('data', models.CharField(max_length=1000)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Generated by Django 5.0.2 on 2024-02-12 19:46
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('tldtester', '0002_zonecontent'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name='zonecontent',
|
||||||
|
index=models.Index(fields=['name'], name='tldtester_z_name_83c518_idx'),
|
||||||
|
),
|
||||||
|
]
|
18
tldtester/migrations/0004_zonecontent_lastedition.py
Normal file
18
tldtester/migrations/0004_zonecontent_lastedition.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 5.0.2 on 2024-02-12 19:48
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('tldtester', '0003_zonecontent_tldtester_z_name_83c518_idx'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='zonecontent',
|
||||||
|
name='lastEdition',
|
||||||
|
field=models.DateTimeField(auto_now=True),
|
||||||
|
),
|
||||||
|
]
|
18
tldtester/migrations/0005_alter_zonecontent_ttl.py
Normal file
18
tldtester/migrations/0005_alter_zonecontent_ttl.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 5.0.2 on 2024-02-12 20:04
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('tldtester', '0004_zonecontent_lastedition'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='zonecontent',
|
||||||
|
name='ttl',
|
||||||
|
field=models.CharField(max_length=5),
|
||||||
|
),
|
||||||
|
]
|
|
@ -43,3 +43,20 @@ class TLD(models.Model):
|
||||||
models.Index(fields=["dnssec"]),
|
models.Index(fields=["dnssec"]),
|
||||||
models.Index(fields=["inet"]),
|
models.Index(fields=["inet"]),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class zonecontent(models.Model):
|
||||||
|
rtype = models.CharField(max_length=10)
|
||||||
|
name = models.CharField(max_length=100)
|
||||||
|
rclass = models.CharField(max_length=10)
|
||||||
|
ttl = models.CharField(max_length=5)
|
||||||
|
data = models.CharField(max_length=1000)
|
||||||
|
lastEdition = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
indexes = [
|
||||||
|
models.Index(fields=["name"]),
|
||||||
|
]
|
||||||
|
|
|
@ -3,6 +3,9 @@ This file is dumping the IANA root zone and sorting it in the database
|
||||||
Link to IANA website : https://www.internic.net/domain/root.zone
|
Link to IANA website : https://www.internic.net/domain/root.zone
|
||||||
"""
|
"""
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
import zonefile_parser
|
||||||
|
import json
|
||||||
|
from tldtester.models import zonecontent
|
||||||
|
|
||||||
|
|
||||||
def downloader():
|
def downloader():
|
||||||
|
@ -22,13 +25,32 @@ def sorter(rawdata):
|
||||||
"""
|
"""
|
||||||
This file removes the tabs and line breaks from rawdata
|
This file removes the tabs and line breaks from rawdata
|
||||||
returns as a list with dictionary in it
|
returns as a list with dictionary in it
|
||||||
|
:returns: a list of dictionaries
|
||||||
"""
|
"""
|
||||||
print(str(rawdata))
|
encodeddata = zonefile_parser.parse(rawdata)
|
||||||
|
properdata = []
|
||||||
|
for line in encodeddata:
|
||||||
|
properdata.append(dict(json.loads(str(line).replace("'", '"'))))
|
||||||
|
return properdata
|
||||||
|
|
||||||
|
|
||||||
|
def dbwriter(data):
|
||||||
|
"""
|
||||||
|
Writes everything in the Zone database
|
||||||
|
"""
|
||||||
|
for line in data:
|
||||||
|
DB = zonecontent()
|
||||||
|
DB.rtype = line["rtype"]
|
||||||
|
DB.name = line["name"]
|
||||||
|
DB.rclass = line["rclass"]
|
||||||
|
DB.data = line["rdata"]
|
||||||
|
DB.ttl = int(line["ttl"])
|
||||||
|
DB.save()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
sorter(downloader())
|
dbwriter(sorter(downloader()))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue