Skip to content

Commit

Permalink
fix not loading dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
maaaathis committed Jul 9, 2023
1 parent 99a321f commit 2fb9705
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
4 changes: 3 additions & 1 deletion app/lookup/[domain]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const LookupDomain = async ({ params: { domain } }) => {
return (
<>
<div className="grid gap-4 md:grid-cols-4">
{whoisResult['Created Date'] || whoisResult['Updated Date'] || whoisResult['Expiry Date'] ? (
{whoisResult['Created Date'] ||
whoisResult['Updated Date'] ||
whoisResult['Expiry Date'] ? (
<div className="h-full md:col-span-2">
<div className="h-full rounded-xl bg-slate-100 px-8 py-5 dark:bg-slate-950 md:flex">
<div>
Expand Down
36 changes: 6 additions & 30 deletions utils/DnsLookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ class DnsLookup {
}
}

static async resolveNameservers(
domain: string,
fromParent = false
): Promise<string[]> {
static async fetchRecords(domain: string, recordType: RecordType) {
// TODO Reduce duplicate NS lookups

let nameservers: string[] = [];
let nsDomain = domain;
while (true) {
Expand All @@ -105,25 +104,13 @@ class DnsLookup {
}
}

if (fromParent) {
if (recordType === 'DS') {
// DS records are stored at the parent domain
nsDomain = nsDomain.replace(/^[^.]+\./, '');
nameservers = await dns.resolveNs(nsDomain);
}

const addresses = await dns.resolve4(nameservers[0]);
if (addresses.length === 0) {
throw new Error('No addresses found for nameserver');
}

return addresses;
}

static async fetchRecords(
domain: string,
recordType: RecordType,
nameservers: string[]
) {
const packetBuffer = dnsPacket.encode({
type: 'query',
id: 1,
Expand All @@ -132,7 +119,7 @@ class DnsLookup {
});

const socket = dgram.createSocket('udp4');
socket.send(packetBuffer, 0, packetBuffer.length, 53, nameservers[0]);
socket.send(packetBuffer, 0, packetBuffer.length, 53, addresses[0]);

return await new Promise<RawRecord[]>((resolve, reject) => {
socket.on('message', (message: Buffer) => {
Expand Down Expand Up @@ -166,19 +153,8 @@ class DnsLookup {
}

static async resolveAllRecords(domain: string): Promise<ResolvedRecords> {
const [nameservers, parentNameservers] = await Promise.all([
DnsLookup.resolveNameservers(domain),
DnsLookup.resolveNameservers(domain, true),
]);

const results = await Promise.all(
RECORD_TYPES.map((type) =>
DnsLookup.fetchRecords(
domain,
type,
type === 'DS' ? parentNameservers : nameservers
)
)
RECORD_TYPES.map((type) => DnsLookup.fetchRecords(domain, type))
);

return RECORD_TYPES.reduce(
Expand Down

1 comment on commit 2fb9705

@vercel
Copy link

@vercel vercel bot commented on 2fb9705 Jul 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

digger – ./

digger-maathis.vercel.app
digger.vercel.app
digger-git-main-maathis.vercel.app
digga.dev

Please sign in to comment.