Skip to content

Commit

Permalink
Merge pull request #25 from tldtest/link-and-rdap
Browse files Browse the repository at this point in the history
adding code for RDAP and TLD websites
  • Loading branch information
altf4arnold authored Apr 14, 2024
2 parents 1b9115b + 0321c20 commit ed633df
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 5 deletions.
10 changes: 10 additions & 0 deletions static/src/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,11 @@ video {
font-weight: 600;
}

.text-blue-600 {
--tw-text-opacity: 1;
color: rgb(37 99 235 / var(--tw-text-opacity));
}

.text-gray-500 {
--tw-text-opacity: 1;
color: rgb(107 114 128 / var(--tw-text-opacity));
Expand Down Expand Up @@ -932,6 +937,11 @@ video {
background-color: rgb(17 24 39 / var(--tw-bg-opacity));
}

.dark\:text-blue-500 {
--tw-text-opacity: 1;
color: rgb(59 130 246 / var(--tw-text-opacity));
}

.dark\:text-gray-400 {
--tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity));
Expand Down
1 change: 1 addition & 0 deletions staticfiles/CACHE/css/output.184c6e037351.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions staticfiles/src/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,11 @@ video {
font-weight: 600;
}

.text-blue-600 {
--tw-text-opacity: 1;
color: rgb(37 99 235 / var(--tw-text-opacity));
}

.text-gray-500 {
--tw-text-opacity: 1;
color: rgb(107 114 128 / var(--tw-text-opacity));
Expand Down Expand Up @@ -932,6 +937,11 @@ video {
background-color: rgb(17 24 39 / var(--tw-bg-opacity));
}

.dark\:text-blue-500 {
--tw-text-opacity: 1;
color: rgb(59 130 246 / var(--tw-text-opacity));
}

.dark\:text-gray-400 {
--tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity));
Expand Down
13 changes: 11 additions & 2 deletions tldtest/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<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">RDAP</th>
<th class="border border-slate-600">Organisation</th>
</tr>
</thead>
Expand All @@ -22,9 +23,17 @@
<td class="border border-slate-700 text-l-blue-600">{{ TLD.nsamount }}</td>
<td class="border border-slate-700 text-red-700">{{ TLD.v4nsamount }}</td>
<td class="border border-slate-700 text-green-600">{{ TLD.v6nsamount }}</td>
<td class="border border-slate-700">{% if TLD.dnssec != 400 %} Algo {{ TLD.dnssec }} {{ TLD.get_dnssec_display }} {% else %} {{ TLD.get_dnssec_display }} {% endif %}</td>
<td class="border border-slate-700">{% if TLD.dnssec != 400 %} Algo {{ TLD.dnssec }}
{{ TLD.get_dnssec_display }} {% else %} {{ TLD.get_dnssec_display }} {% endif %}</td>
<td class="border border-slate-700">{{ TLD.amountofkeys }}</td>
<td class="border border-slate-700">{{ TLD.organisation }}</td>
{% if TLD.rdap == "Yes" %}
<td class="border border-slate-700 text-green-600">{{ TLD.rdap }}</td>
{% else %}
<td class="border border-slate-700 text-red-700">{{ TLD.rdap }}</td>
{% endif %}
<td class="border border-slate-700"><a href="{{ TLD.link }}"
class="font-medium text-blue-600 dark:text-blue-500 hover:underline">{{ TLD.organisation }}</a>
</td>
</tr>
{% endfor %}
</tbody>
Expand Down
2 changes: 2 additions & 0 deletions tldtester/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class TLD(models.Model):
amountofkeys = models.IntegerField(default=0)
lastEdition = models.DateTimeField(auto_now=True)
organisation = models.CharField(max_length=100)
rdap = models.CharField(max_length=10, default="No")
link = models.CharField(max_length=800, default="https://tldtest.net/")

def __str__(self):
return self.tld
Expand Down
47 changes: 44 additions & 3 deletions tldtester/sorter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Link to IANA website : https://www.internic.net/domain/root.zone
"""
import json
import config
import urllib.request
from tldtester.models import TLD, RootZone
from django.core.exceptions import MultipleObjectsReturned
Expand Down Expand Up @@ -44,6 +45,8 @@ def zonesorter(zonefile):
Takes the zonefile as an input and writes the records to the database
"""
for line in zonefile:
if config.DEBUG is True:
print(line)
value = ""
record = line.split()
if len(record) >= 5:
Expand All @@ -56,6 +59,8 @@ def zonesorter(zonefile):
value = value + record[i + 4] + " "
towrite = {"name": name, "type": recordtype, "value": value}
zonedbwriter(towrite)
if config.DEBUG is True:
print("Done Parsing the Zones")


def zonedbwriter(recs):
Expand Down Expand Up @@ -85,20 +90,25 @@ def tlddbwriter(recs):
db.dnssec = recs["algo"]
db.amountofkeys = recs["amountofkeys"]
db.organisation = recs["organisation"]
db.link = recs["link"]
db.rdap = recs["rdap"]
db.save()


def grabber(data):
def grabber(data, rdaptlds):
"""
This function takes the TLD's and makes querrys to the DNS. It looks up how many authoritative DNS's there are and
analyses the v4, v6 and DNSSEC. Returns a list of dictionaries with all the vallues to write in the database
"""
for tld in data:
if config.DEBUG is True:
print("starting with " + tld)
nsservers = []
dnsseckeys = []
Arecords = 0
AAAArecords = 0
amountofkeys = 0
link = "https://tldtest.net"
nses = RootZone.objects.all().filter(name=tld + ".", rectype="NS")
for ns in nses:
nsservers.append(ns.value)
Expand Down Expand Up @@ -154,23 +164,54 @@ def grabber(data):
organisation = entity["vcardArray"][1][2][3]
except:
organisation = "Reserved"
try:
link = data["links"][2]["href"]
except Exception as e:
print("link not found for " + tld)
print(e)
if tld in rdaptlds:
rdap = "Yes"
else:
rdap = "No"

results = {"tld": tld, "unicodeTld": unicodetld, "nsserveramount": int(len((nsservers))),
"organisation": organisation, "v4resolvers": Arecords, "v6resolvers": AAAArecords, "algo": algo,
"amountofkeys": amountofkeys}
"amountofkeys": amountofkeys, "link": link, "rdap": rdap}
if config.DEBUG is True:
print(results)
tlddbwriter(results)


def rdaper():
"""
Downloads the RDAP link database from IANA and creates a list of all the tlds that currently support it.
returns either a full or an empty list.
"""
rdaptlds = []
url = urllib.request.urlopen("https://data.iana.org/rdap/dns.json")
if url.getcode() == 200:
raw = url.read()
raw = raw.decode("utf-8")
else:
raw = None
data = json.loads(raw)
for i in data["services"]:
for j in i[0]:
rdaptlds.append(j)
return rdaptlds


def main():
try:
zonefile = zonedownloader().splitlines(True)
rdaptlds = rdaper()
if zonefile is not None:
# First delete the entire zone database if file polling is successful and re write
RootZone.objects.all().delete()
zonesorter(zonefile)
tlds = tlddownloader()
if tlds is not None:
grabber(tlds)
grabber(tlds, rdaptlds)
except Exception as e:
print(e)

Expand Down

0 comments on commit ed633df

Please sign in to comment.