From 2fe1b691743a94add1cd3fbb773b8518d12c3060 Mon Sep 17 00:00:00 2001 From: Slatian Date: Mon, 7 Aug 2023 21:09:14 +0200 Subject: [PATCH] Beeter communication of dns errors --- src/main.rs | 17 ++++++++++++++++- src/simple_dns.rs | 10 ++++++---- templates/dig.html | 28 ++++++++++++++++++---------- templates/dig.txt | 30 ++++++++++++++++++++---------- 4 files changed, 60 insertions(+), 25 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1b0bb43..ca6e70c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -706,7 +706,22 @@ async fn get_dig_result( used_dns_resolver: dns_resolver_name.clone(), } } + } else { + return DigResult { + records: DnsLookupResult{ + invalid_name: true, + .. Default::default() + }, + .. Default::default() + } + } + } else { + return DigResult { + records: DnsLookupResult{ + unkown_resolver: true, + .. Default::default() + }, + .. Default::default() } } - return Default::default(); } diff --git a/src/simple_dns.rs b/src/simple_dns.rs index 1b9cd74..a951d43 100644 --- a/src/simple_dns.rs +++ b/src/simple_dns.rs @@ -38,10 +38,12 @@ pub struct DnsLookupResult { pub txt: Option>, pub srv: Option>, pub caa: Option>, - pub other_error: bool, - pub dns_error: bool, - pub nxdomain: bool, - pub timeout: bool, + pub other_error: bool, + pub dns_error: bool, + pub nxdomain: bool, + pub timeout: bool, + pub invalid_name: bool, + pub unkown_resolver: bool, } #[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq)] diff --git a/templates/dig.html b/templates/dig.html index 1773d48..553fd64 100644 --- a/templates/dig.html +++ b/templates/dig.html @@ -26,8 +26,16 @@

DNS Records

- {% if r.nxdomain %} -

Our DNS-Server claims that this domain doesn't exist, there shouldn't be any results.

+ {% set show_nonpresent = true %} + {% if r.unkown_resolver %} +

The resolver you chose is not one of the available ones, if you can reproduce this error by just using the UI please report it.

+ {% set show_nonpresent = false %} + {% elif r.invalid_name %} +

This domain name does not conform to the dns specification (std3) rules and was therefore not resolved.

+ {% set show_nonpresent = false %} + {% elif r.nxdomain %} +

The DNS-Server claims that this domain doesn't exist, there shouldn't be any results.

+ {% set show_nonpresent = false %} {% elif r.timeout %}

There was at least one timeout error while resolving this domain, the results below are incomplete.

{% elif r.other_error %} @@ -66,7 +74,7 @@
  • {{ helper::ip(extra=extra, ip=address) }}
  • {% endfor %} - {% elif not r.nxdomain %} + {% elif show_nonpresent %}

    No A (IPv4) Records.

    {% endif %} @@ -77,7 +85,7 @@
  • {{ helper::ip(extra=extra, ip=address) }}
  • {% endfor %} - {% elif not r.nxdomain %} + {% elif show_nonpresent %}

    No AAAA (IPv6) Records.

    {% endif %} @@ -90,7 +98,7 @@
  • {{ helper::dig(extra=extra, name=mx.exchange, fqdn=true, prefix=mx.preference) }}
  • {% endfor %} - {% elif not r.nxdomain %} + {% elif show_nonpresent %}

    No MX (Mail Exchange) records.

    {% endif %} @@ -116,7 +124,7 @@ {% endfor %} - {% elif not r.nxdomain %} + {% elif show_nonpresent %}

    No SOA records.

    {% endif %} @@ -129,7 +137,7 @@
  • {{ helper::dig(extra=extra, name=ns) }}
  • {% endfor %} - {% elif not r.nxdomain %} + {% elif show_nonpresent %}

    No NS (Name Server) records.

    {% endif %} @@ -141,7 +149,7 @@
  • {{caa}}
  • {% endfor %} - {% elif not r.nxdomain %} + {% elif show_nonpresent %}

    No CAA (Certification Authority Authorization) records.

    {% endif %} @@ -152,7 +160,7 @@
  • {{txt}}
  • {% endfor %} - {% elif not r.nxdomain %} + {% elif show_nonpresent %}

    No TXT records.

    {% endif %} @@ -172,7 +180,7 @@ {% endfor %} - {% elif not r.nxdomain %} + {% elif show_nonpresent %}

    No SRV records.

    SRV or Service records usually live on their own subdomains like {{ helper::dig(extra=extra, name="_xmpp-client._tcp."~data.query) }}. {% endif %} diff --git a/templates/dig.txt b/templates/dig.txt index 38be133..5d5a136 100644 --- a/templates/dig.txt +++ b/templates/dig.txt @@ -2,7 +2,8 @@ {% block path %}dig/{{ data.query | urlencode_strict }}{% endblock %} -{% block content -%} +{% set r = data.result.records %} +{%- block content -%} # dig {{data.query}} via {{ data.result.used_dns_resolver }} {% if data.result.idn -%} @@ -25,7 +26,16 @@ Your IDN would decode to {% set r = data.result.records -%} ## DNS Records -{% if r.nxdomain %} +{% if r.unkown_resolver %} +{%- set show_nonpresent = false %} +The resolver you chose is not one of the available ones. +=> {{ extra.base_url }}/dns_resolver +{% elif r.invalid_name %} +{%- set show_nonpresent = false %} +This domain name does not conform to the dns specification (std3) rules and was therefore not resolved. +=> https://www.rfc-editor.org/info/std3 +{% elif r.nxdomain %} +{%- set show_nonpresent = false %} Our DNS-Server claims that this domain doesn't exist, there shouldn't be any results. {%- elif r.timeout -%} There was at least one timeout error while resolving this domain, the results below are incomplete. @@ -61,7 +71,7 @@ A (IPv4) records: {% for address in r.a -%} * {{ address }} {% endfor %} -{%- elif not r.nxdomain %} +{%- elif show_nonpresent %} No A (IPv4) Records. {% endif -%} @@ -70,7 +80,7 @@ AAAA (IPv6) records: {% for address in r.aaaa -%} * {{ address }} {% endfor %} -{%- elif not r.nxdomain %} +{%- elif show_nonpresent %} No AAAA (IPv6) Records. {% endif -%} @@ -81,7 +91,7 @@ MX (Mail Exchange) records: {% for mx in r.mx | sort(attribute="preference") | reverse -%} * {{ mx.preference }} {{ mx.exchange }} {% endfor %} -{%- elif not r.nxdomain %} +{%- elif show_nonpresent %} No MX (Mail Exchange) records. {% endif %} @@ -96,7 +106,7 @@ SOA (Source Of Authority) records: * expire: {{soa.expire / 3600 | round(precision=2)}}h * minimum: {{soa.minimum / 60 | round(precision=2)}}m TTL {% endfor %} -{%- elif not r.nxdomain %} +{%- elif show_nonpresent %} No SOA (Source Of Authority) records. {% endif %} @@ -105,7 +115,7 @@ NS (Name Server) records: {% for ns in r.ns -%} * {{ns}} {% endfor %} -{%- elif not r.nxdomain %} +{%- elif show_nonpresent %} No NS (Name Server) records. {% endif %} @@ -114,7 +124,7 @@ CAA (Certification Authority Authorization) records: {% for caa in r.caa -%} * {{caa}} {% endfor %} -{%- elif not r.nxdomain %} +{%- elif show_nonpresent %} No CAA (Certification Authority Authorization) records. {% endif %} @@ -123,7 +133,7 @@ TXT records: {% for txt in r.txt -%} * {{txt}} {% endfor %} -{%- elif not r.nxdomain %} +{%- elif show_nonpresent %} No TXT records. {% endif %} @@ -135,7 +145,7 @@ SRV records: * Port: {{srv.port}} * Target: {{srv.target}} {% endfor %} -{%- elif not r.nxdomain %} +{%- elif show_nonpresent %} No SRV records. SRV or Service records usually live on their own subdomains like {{ "_xmpp-client._tcp."~data.query }}.