Skip to content

Full Toolkit for Next-Level Domain Analysis

Add insights to record subvalues 🤓

Felix Wotschofskyb1877b1b899e
diff --git a/app/lookup/[domain]/(dns)/_components/dns-table.tsx b/app/lookup/[domain]/(dns)/_components/dns-table.tsx
index a88ff8b..4063f40 100644
--- a/app/lookup/[domain]/(dns)/_components/dns-table.tsx
+++ b/app/lookup/[domain]/(dns)/_components/dns-table.tsx
@@ -12,14 +12,15 @@ import {
import type { ResolvedRecords } from '@/lib/resolvers/base';
import { RecordRow } from './record-row';
+import type { SubvalueInfo } from './record-subvalues';
import { StackedRecord } from './stacked-record';
type DnsTableProps = {
records: ResolvedRecords;
- ipsInfo: Record<string, string>;
+ subvalues: Record<string, SubvalueInfo[]>;
};
-export const DnsTable: FC<DnsTableProps> = ({ records, ipsInfo }) => (
+export const DnsTable: FC<DnsTableProps> = ({ records, subvalues }) => (
<>
{Object.keys(records).map((recordType) => {
const value = records[recordType];
@@ -45,7 +46,7 @@ export const DnsTable: FC<DnsTableProps> = ({ records, ipsInfo }) => (
name={v.name}
TTL={v.TTL}
value={v.data}
- subvalue={ipsInfo[v.data]}
+ subvalues={subvalues[v.data]}
/>
</Fragment>
))}
@@ -70,7 +71,7 @@ export const DnsTable: FC<DnsTableProps> = ({ records, ipsInfo }) => (
name={v.name}
TTL={v.TTL}
value={v.data}
- subvalue={ipsInfo[v.data]}
+ subvalues={subvalues[v.data]}
/>
))}
</TableBody>
diff --git a/app/lookup/[domain]/(dns)/_components/record-row.tsx b/app/lookup/[domain]/(dns)/_components/record-row.tsx
index c43397e..4976ade 100644
--- a/app/lookup/[domain]/(dns)/_components/record-row.tsx
+++ b/app/lookup/[domain]/(dns)/_components/record-row.tsx
@@ -7,6 +7,7 @@ import { cn } from '@/lib/utils';
import { DomainLink } from '../../_components/domain-link';
import { IpLink } from '../../_components/ip-link';
+import { RecordSubvalues, type SubvalueInfo } from './record-subvalues';
const DOMAIN_REGEX = /([a-zA-Z0-9-_]+\.)+[a-z]+\.?/gi;
const IPV4_REGEX = /(\d{1,3}\.){3}\d{1,3}/g;
@@ -17,14 +18,14 @@ type RecordRowProps = {
name: string;
TTL: number;
value: string;
- subvalue?: string;
+ subvalues?: SubvalueInfo[];
};
export const RecordRow: FC<RecordRowProps> = ({
name,
TTL,
value,
- subvalue,
+ subvalues,
}) => {
let interpolatedValue: ReactNode[] | string | null = value;
@@ -64,13 +65,9 @@ export const RecordRow: FC<RecordRowProps> = ({
<TableRow className="hover:bg-transparent">
<TableCell className="pl-0">{name}</TableCell>
<TableCell>{TTL}</TableCell>
- <TableCell className={cn('pr-0', { ['py-1']: subvalue })}>
+ <TableCell className={cn('pr-0', { ['py-1']: subvalues })}>
{interpolatedValue}
- {subvalue && (
- <span className="mt-1 block text-xs text-muted-foreground">
- {subvalue}
- </span>
- )}
+ {subvalues && <RecordSubvalues subvalues={subvalues} />}
</TableCell>
</TableRow>
);
diff --git a/app/lookup/[domain]/(dns)/_components/record-subvalues.tsx b/app/lookup/[domain]/(dns)/_components/record-subvalues.tsx
new file mode 100644
index 0000000..ae1f73c
--- /dev/null
+++ b/app/lookup/[domain]/(dns)/_components/record-subvalues.tsx
@@ -0,0 +1,32 @@
+import type { FC } from 'react';
+
+export type SubvalueInfo = {
+ description: string;
+ url?: string;
+};
+
+type RecordSubvaluesProps = {
+ subvalues: SubvalueInfo[];
+};
+
+export const RecordSubvalues: FC<RecordSubvaluesProps> = ({ subvalues }) => (
+ <span className="mt-1 block break-words text-xs text-muted-foreground">
+ {subvalues.map((s, i) => (
+ <>
+ {i > 0 && ' / '}
+ {s.url ? (
+ <a
+ href={s.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="underline decoration-dotted"
+ >
+ {s.description}
+ </a>
+ ) : (
+ s.description
+ )}
+ </>
+ ))}
+ </span>
+);
diff --git a/app/lookup/[domain]/(dns)/_components/stacked-record.tsx b/app/lookup/[domain]/(dns)/_components/stacked-record.tsx
index 3b71d57..0826ca3 100644
--- a/app/lookup/[domain]/(dns)/_components/stacked-record.tsx
+++ b/app/lookup/[domain]/(dns)/_components/stacked-record.tsx
@@ -3,6 +3,7 @@ import reactStringReplace from 'react-string-replace';
import { DomainLink } from '../../_components/domain-link';
import { IpLink } from '../../_components/ip-link';
+import { RecordSubvalues, type SubvalueInfo } from './record-subvalues';
const DOMAIN_REGEX = /([a-zA-Z0-9-_]+\.)+[a-z]+\.?/gi;
const IPV4_REGEX = /(\d{1,3}\.){3}\d{1,3}/g;
@@ -13,14 +14,14 @@ type StackedRecordProps = {
name: string;
TTL: number;
value: string;
- subvalue?: string;
+ subvalues?: SubvalueInfo[];
};
export const StackedRecord: FC<StackedRecordProps> = ({
name,
TTL,
value,
- subvalue,
+ subvalues,
}) => {
let interpolatedValue: ReactNode[] | string | null = value;
@@ -63,11 +64,7 @@ export const StackedRecord: FC<StackedRecordProps> = ({
<span>{TTL}</span>
</div>
<p className="break-words">{interpolatedValue}</p>
- {subvalue && (
- <span className="mt-1 block break-words text-xs text-muted-foreground">
- {subvalue}
- </span>
- )}
+ {subvalues && <RecordSubvalues subvalues={subvalues} />}
</div>
);
};
diff --git a/app/lookup/[domain]/(dns)/page.tsx b/app/lookup/[domain]/(dns)/page.tsx
index 3bcc6be..a810430 100644
--- a/app/lookup/[domain]/(dns)/page.tsx
+++ b/app/lookup/[domain]/(dns)/page.tsx
@@ -2,14 +2,17 @@ import type { Metadata } from 'next';
import { redirect, RedirectType } from 'next/navigation';
import type { FC } from 'react';
+import { RECORD_INSIGHTS } from '@/lib/data';
import { hostLookupLoader } from '@/lib/ips';
import { AuthoritativeResolver } from '@/lib/resolvers/authoritative';
+import type { ResolvedRecords } from '@/lib/resolvers/base';
import { CloudflareDoHResolver } from '@/lib/resolvers/cloudflare';
import { GoogleDoHResolver } from '@/lib/resolvers/google';
import { InternalDoHResolver } from '@/lib/resolvers/internal';
import { DnsTable } from './_components/dns-table';
import { LocationSelector } from './_components/location-selector';
+import type { SubvalueInfo } from './_components/record-subvalues';
import { ResolverSelector } from './_components/resolver-selector';
const getResolver = (
@@ -37,15 +40,54 @@ const getResolver = (
}
};
-const getIpsInfo = async (ips: string[]): Promise<Record<string, string>> => {
+const getIpsInfo = async (ips: string[]): Promise<Record<string, string[]>> => {
const hosts = await hostLookupLoader.loadMany(ips);
return Object.fromEntries(
ips
.map((ip, index) => [ip, hosts[index]])
- .filter(([, host]) => typeof host === 'string')
+ .filter(([, hosts]) => Array.isArray(hosts))
);
};
+const getSubvalues = async (records: ResolvedRecords) => {
+ const allSubvalues: Record<string, SubvalueInfo[]> = {};
+
+ const ips = records.A.map((r) => r.data).concat(
+ records.AAAA.map((r) => r.data)
+ );
+ const ipsInfo = await getIpsInfo(ips);
+
+ const flatRecords = Object.values(records).flat();
+ for (const record of flatRecords) {
+ const subvalues: SubvalueInfo[] = [];
+
+ const normalizedRecord = record.data.endsWith('.')
+ ? record.data.slice(0, -1)
+ : record.data;
+
+ const possibleInsights = RECORD_INSIGHTS[record.type];
+ for (const insight of possibleInsights) {
+ if (insight.test.test(normalizedRecord)) {
+ subvalues.push(insight);
+ }
+ }
+
+ if (record.data in ipsInfo) {
+ subvalues.push(
+ ...ipsInfo[record.data].map((h) => ({
+ description: h,
+ }))
+ );
+ }
+
+ if (subvalues.length > 0) {
+ allSubvalues[record.data] = subvalues;
+ }
+ }
+
+ return allSubvalues;
+};
+
type LookupDomainProps = {
params: {
domain: string;
@@ -90,9 +132,7 @@ const LookupDomain: FC<LookupDomainProps> = async ({
const resolver = getResolver(resolverName, locationName);
const records = await resolver.resolveAllRecords(domain);
- const ipsInfo = await getIpsInfo(
- records.A.map((r) => r.data).concat(records.AAAA.map((r) => r.data))
- );
+ const subvalues = await getSubvalues(records);
const hasResults =
Object.values(records)
@@ -110,7 +150,7 @@ const LookupDomain: FC<LookupDomainProps> = async ({
</div>
{hasResults ? (
- <DnsTable records={records} ipsInfo={ipsInfo} />
+ <DnsTable records={records} subvalues={subvalues} />
) : (
<p className="mt-24 text-center text-muted-foreground">
No DNS records found!
diff --git a/lib/data.ts b/lib/data.ts
index 6008be9..787cce9 100644
--- a/lib/data.ts
+++ b/lib/data.ts
@@ -1,3 +1,5 @@
+import type { RecordType } from './resolvers/base';
+
export const REGIONS: Record<
string,
{ name: string; lat: number; lng: number }
@@ -33,3 +35,178 @@ export const EXAMPLE_DOMAINS = [
'twitter.com',
'discord.com',
];
+
+type RecordInsights = {
+ [key in RecordType]: Array<{
+ test: RegExp;
+ description: string;
+ url: string;
+ }>;
+};
+
+export const RECORD_INSIGHTS: RecordInsights = {
+ A: [
+ {
+ // 35.71.142.77 or 52.223.52.2
+ test: /^(?:35\.71\.142\.77|52\.223\.52\.2)$/,
+ description: 'Framer',
+ url: 'https://www.framer.com',
+ },
+ {
+ // 75.2.70.75 or 99.83.190.102
+ test: /^(?:75\.2\.70\.75|99\.83\.190\.102)$/,
+ description: 'Webflow',
+ url: 'https://www.webflow.com',
+ },
+ ],
+ AAAA: [],
+ CAA: [],
+ CNAME: [
+ {
+ test: /\.(akadns|akamai|akamaiedge|edgekey|edgesuite)\.net$/,
+ description: 'Akamai',
+ url: 'https://www.akamai.com',
+ },
+ {
+ test: /\.cloudfront\.net$/,
+ description: 'Amazon CloudFront',
+ url: 'https://aws.amazon.com/cloudfront/',
+ },
+ {
+ test: /\.elb\.[a-z]+-[a-z]+-\d+\.amazonaws\.com$/,
+ description: 'AWS Elastic Load Balancing',
+ url: 'https://aws.amazon.com/elasticloadbalancing/',
+ },
+ {
+ test: /\.cdn\.cloudflare\.net$/,
+ description: 'Cloudflare',
+ url: 'https://www.cloudflare.com',
+ },
+ {
+ test: /\.map\.fastly.net$/,
+ description: 'Fastly',
+ url: 'https://www.fastly.com',
+ },
+ {
+ test: /sites\.framer\.app\./,
+ description: 'Framer',
+ url: 'https://www.framer.com',
+ },
+ {
+ test: /\.github\.io$/,
+ description: 'GitHub Pages',
+ url: 'https://pages.github.com',
+ },
+ {
+ test: /^ghs\.googlehosted\.com$/,
+ description: 'Google Cloud',
+ url: 'https://cloud.google.com',
+ },
+ {
+ test: /\.netlify\.app$/,
+ description: 'Netlify',
+ url: 'https://www.netlify.com',
+ },
+ {
+ test: /^proxy-ssl\.webflow\.com\./,
+ description: 'Webflow',
+ url: 'https://www.webflow.com',
+ },
+ ],
+ DNSKEY: [],
+ DS: [],
+ MX: [
+ {
+ test: /\.mxrecord\.(mx|io)$/,
+ description: 'Cloudflare Area 1',
+ url: 'https://developers.cloudflare.com/email-security/',
+ },
+ {
+ test: /in\d\-smtp.messagingengine\.com$/,
+ description: 'Fastmail',
+ url: 'https://www.fastmail.com/',
+ },
+ {
+ test: /(aspmx\.l\.google|aspmx\d\.googlemail)\.com$/,
+ description: 'Google Workspace',
+ url: 'https://workspace.google.com',
+ },
+ {
+ test: /work-mx\.app\.hey\.com$/,
+ description: 'HEY',
+ url: 'https://www.hey.com/',
+ },
+ {
+ test: /mail\.protection\.outlook\.com$/,
+ description: 'Microsoft 365',
+ url: 'https://www.microsoft.com/microsoft-365',
+ },
+ {
+ test: /eforward\d\.registrar-servers\.com$/,
+ description: 'Namecheap Forwarding',
+ url: 'https://www.namecheap.com',
+ },
+ {
+ test: /\.pphosted\.com$/,
+ description: 'Proofpoint',
+ url: 'https://www.proofpoint.com',
+ },
+ ],
+ NAPTR: [],
+ NS: [
+ {
+ test: /^ns-\d{1,4}\.awsdns-\d{1,2}\.(com|net|org|co\.uk)$/,
+ description: 'Amazon Route 53',
+ url: 'https://aws.amazon.com/route53/',
+ },
+ {
+ test: /^(coco|kiki)\.bunny\.net$/,
+ description: 'Bunny DNS',
+ url: 'https://bunny.net/dns/',
+ },
+ {
+ test: /^[a-z]+\.ns\.cloudflare\.com$/,
+ description: 'Cloudflare',
+ url: 'https://www.cloudflare.com',
+ },
+ {
+ test: /^ns\d\.messagingengine\.com$/,
+ description: 'Fastmail',
+ url: 'https://www.fastmail.com/',
+ },
+ {
+ test: /^ns\d{2}\.domaincontrol\.com$/,
+ description: 'GoDaddy',
+ url: 'https://www.godaddy.com',
+ },
+ {
+ test: /^ns\d-\d{1,2}\.azure-dns\.(com|info|net|org)$/,
+ description: 'Microsoft Azure DNS',
+ url: 'https://azure.microsoft.com/services/dns/',
+ },
+ {
+ test: /^dns\d\.registrar-servers\.com$/,
+ description: 'Namecheap',
+ url: 'https://www.namecheap.com',
+ },
+ {
+ test: /^dns\d\.p\d{2}\.nsone\.net$/,
+ description: 'NS1',
+ url: 'https://ns1.com',
+ },
+ {
+ test: /\.ultradns\.(biz|com|net|org)$/,
+ description: 'Vercara UltraDNS',
+ url: 'https://vercara.com/authoritative-dns',
+ },
+ {
+ test: /^.+\.vercel-dns\.com$/,
+ description: 'Vercel',
+ url: 'https://vercel.com',
+ },
+ ],
+ PTR: [],
+ SOA: [],
+ SRV: [],
+ TXT: [],
+};
diff --git a/lib/ips.ts b/lib/ips.ts
index 9bb071f..160fa88 100644
--- a/lib/ips.ts
+++ b/lib/ips.ts
@@ -42,10 +42,10 @@ export const hostLookupLoader = new DataLoader(
const data = await getIpDetails(normalIp);
if (data.org === data.isp) {
- return data.org;
+ return [data.org];
}
- return `${data.org} / ${data.isp}`;
+ return [data.org, data.isp].filter(Boolean);
})
),
{