Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update codebase #20

Merged
merged 2 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
}
body {
@apply bg-background text-foreground;
font-feature-settings: 'rlig' 1, 'calt' 1;
font-feature-settings:
'rlig' 1,
'calt' 1;
}
}
26 changes: 21 additions & 5 deletions app/lookup/[domain]/certs/error.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
'use client';

const CertsError = () => (
<div className="flex items-center justify-center">
<p className="my-8">An error occurred!</p>
</div>
);
import { type FC, useEffect } from 'react';

type CertsErrorProps = {
error: Error & { digest?: string };
reset: () => void;
};

const CertsError: FC<CertsErrorProps> = ({ error }) => {
useEffect(() => {
console.error(error);
}, [error]);

return (
<div className="mt-12 flex flex-col items-center gap-2">
<h2>Something went wrong!</h2>
<p className="mt-2 text-center text-sm text-muted-foreground">
Digest: {error.digest}
</p>
</div>
);
};

export default CertsError;
22 changes: 19 additions & 3 deletions app/lookup/[domain]/certs/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,23 @@ export const preferredRegion = 'lhr1';
const CertsResultsPage: FC<CertsResultsPageProps> = async ({
params: { domain },
}) => {
const certs = await lookupCerts(domain);
const certRequests = [lookupCerts(domain)];

const hasParentDomain = domain.split('.').filter(Boolean).length > 2;
if (hasParentDomain) {
const parentDomain = domain.split('.').slice(1).join('.');
certRequests.push(lookupCerts(`*.${parentDomain}`));
}

const certs = await Promise.all(certRequests).then((responses) =>
responses
.flat()
.sort(
(a, b) =>
new Date(b.entry_timestamp).getTime() -
new Date(a.entry_timestamp).getTime()
)
);

if (!certs.length) {
return (
Expand All @@ -65,7 +81,7 @@ const CertsResultsPage: FC<CertsResultsPageProps> = async ({
return (
<Table>
<TableHeader>
<TableRow>
<TableRow className="hover:bg-transparent">
<TableHead className="pl-0">Logged At</TableHead>
<TableHead>Not Before</TableHead>
<TableHead>Not After</TableHead>
Expand All @@ -76,7 +92,7 @@ const CertsResultsPage: FC<CertsResultsPageProps> = async ({
</TableHeader>
<TableBody>
{certs.map((cert) => (
<TableRow key={cert.id}>
<TableRow key={cert.id} className="hover:bg-transparent">
<TableCell className="pl-0">{cert.entry_timestamp}</TableCell>
<TableCell>{cert.not_before}</TableCell>
<TableCell>{cert.not_after}</TableCell>
Expand Down
25 changes: 20 additions & 5 deletions app/lookup/[domain]/dns/error.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
'use client';

const DNSError = () => (
<div className="flex items-center justify-center">
<p className="my-8">An error occurred!</p>
</div>
);
import { type FC, useEffect } from 'react';

type DNSErrorProps = {
error: Error & { digest?: string };
reset: () => void;
};

const DNSError: FC<DNSErrorProps> = ({ error }) => {
useEffect(() => {
console.error(error);
}, [error]);

return (
<div className="mt-12 flex flex-col items-center gap-2">
<h2>Something went wrong!</h2>
<p className="mt-2 text-center text-sm text-muted-foreground">
Digest: {error.digest}
</p>
</div>
);
};
export default DNSError;
3 changes: 2 additions & 1 deletion app/lookup/[domain]/dns/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ type LookupDomainProps = {
export const fetchCache = 'default-no-store';

const LookupDomain: FC<LookupDomainProps> = async ({ params: { domain } }) => {
const records = await DnsLookup.resolveAllRecords(domain);
const lookup = new DnsLookup();
const records = await lookup.resolveAllRecords(domain);

if ((await isAvailable(domain)) != 'registered') {
return <DomainNotRegistered />;
Expand Down
28 changes: 22 additions & 6 deletions app/lookup/[domain]/error.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
'use client';

const LookupDomainError = () => (
<div className="flex justify-center">
<p>Failed loading results!</p>
</div>
);
import { type FC, useEffect } from 'react';

export default LookupDomainError;
type DomainErrorProps = {
error: Error & { digest?: string };
reset: () => void;
};

const DomainError: FC<DomainErrorProps> = ({ error }) => {
useEffect(() => {
console.error(error);
}, [error]);

return (
<div className="mt-12 flex flex-col items-center gap-2">
<h2>Something went wrong!</h2>
<p className="mt-2 text-center text-sm text-muted-foreground">
Digest: {error.digest}
</p>
</div>
);
};

export default DomainError;
18 changes: 14 additions & 4 deletions app/lookup/[domain]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ export const generateMetadata = ({
params: { domain },
}: LookupLayoutProps): Metadata => ({
title: `Results for ${domain} - digga`,
openGraph: {
type: 'website',
title: `Results for ${domain} - digga`,
description: `Find DNS records, WHOIS data, SSL/TLS certificate history and more for ${domain}`,
url: process.env.SITE_URL && `${process.env.SITE_URL}/lookup/${domain}`,
},
alternates: {
canonical:
process.env.SITE_URL && `${process.env.SITE_URL}/lookup/${domain}`,
},
});

const LookupLayout: FC<LookupLayoutProps> = ({
Expand All @@ -34,15 +44,15 @@ const LookupLayout: FC<LookupLayoutProps> = ({
</div>

<div className="container">
<h1 className="mb-2 text-4xl font-bold">
Results for{' '}
<h1 className="mb-2">
<span className="block text-muted-foreground">Results for</span>
<a
className="block text-4xl font-bold"
href={`https://${domain}`}
target="_blank"
className="font-extrabold underline-offset-2 hover:underline"
rel="noreferrer"
>
{domain} <ExternalLinkIcon className="inline-block no-underline" />
{domain} <ExternalLinkIcon className="inline-block" />
</a>
</h1>

Expand Down
77 changes: 77 additions & 0 deletions app/lookup/[domain]/opengraph-image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { ImageResponse } from 'next/server';

export const runtime = 'edge';
export const contentType = 'image/png';

const interRegularFontP = fetch(
new URL('https://fonts.bunny.net/inter/files/inter-latin-400-normal.woff')
).then((res) => res.arrayBuffer());

const interBoldFontP = fetch(
new URL('https://fonts.bunny.net/inter/files/inter-latin-700-normal.woff')
).then((res) => res.arrayBuffer());

export const handler = async ({ params }: { params: { domain: string } }) => {
const [interRegularFont, interBoldFont] = await Promise.all([
interRegularFontP,
interBoldFontP,
]);

return new ImageResponse(
(
<div
style={{
display: 'flex',
width: '100%',
height: '100%',
flexDirection: 'column',
justifyContent: 'center',
gap: 16,
backgroundColor: '#fff',
padding: 48,
}}
>
<span
style={{
fontSize: 32,
color: '#000',
}}
>
digga
</span>
<span style={{ fontSize: 48, fontWeight: 700 }}>
Results for {params.domain}
</span>
<span
style={{
color: 'gray',
fontSize: 32,
marginTop: 32,
}}
>
DNS records, WHOIS data, SSL/TLS certificates & more
</span>
</div>
),
{
width: 1200,
height: 630,
fonts: [
{
name: 'Inter',
data: interRegularFont,
style: 'normal',
weight: 400,
},
{
name: 'Inter',
data: interBoldFont,
style: 'normal',
weight: 700,
},
],
}
);
};

export default handler;
5 changes: 3 additions & 2 deletions app/lookup/[domain]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import DnsLookup from '@/utils/DnsLookup';
export const fetchCache = 'default-no-store';

const LookupDomain = async ({ params: { domain } }) => {
const mxRecords = await DnsLookup.fetchRecords(domain, 'MX');
const aRecords = await DnsLookup.fetchRecords(domain, 'A');
const lookup = new DnsLookup();
const mxRecords = await lookup.fetchRecords(domain, 'MX');
const aRecords = await lookup.fetchRecords(domain, 'A');

const whoisResult = whoiser.firstResult(
await whoiser(domain, {
Expand Down
25 changes: 20 additions & 5 deletions app/lookup/[domain]/whois/error.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
'use client';

const WhoisError = () => (
<div className="flex items-center justify-center">
<p className="my-8">An error occurred!</p>
</div>
);
import { type FC, useEffect } from 'react';

type WhoisErrorProps = {
error: Error & { digest?: string };
reset: () => void;
};

const WhoisError: FC<WhoisErrorProps> = ({ error }) => {
useEffect(() => {
console.error(error);
}, [error]);

return (
<div className="mt-12 flex flex-col items-center gap-2">
<h2>Something went wrong!</h2>
<p className="mt-2 text-center text-sm text-muted-foreground">
Digest: {error.digest}
</p>
</div>
);
};
export default WhoisError;
75 changes: 75 additions & 0 deletions app/opengraph-image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { ImageResponse } from 'next/server';

export const runtime = 'edge';
export const contentType = 'image/png';

const interRegularFontP = fetch(
new URL('https://fonts.bunny.net/inter/files/inter-latin-400-normal.woff')
).then((res) => res.arrayBuffer());

const interBoldFontP = fetch(
new URL('https://fonts.bunny.net/inter/files/inter-latin-700-normal.woff')
).then((res) => res.arrayBuffer());

export const handler = async () => {
const [interRegularFont, interBoldFont] = await Promise.all([
interRegularFontP,
interBoldFontP,
]);

return new ImageResponse(
(
<div
style={{
display: 'flex',
width: '100%',
height: '100%',
flexDirection: 'column',
justifyContent: 'center',
gap: 16,
backgroundColor: '#fff',
padding: 48,
}}
>
<span
style={{
fontSize: 48,
color: '#000',
fontWeight: 700,
}}
>
digga
</span>
<span
style={{
color: 'gray',
fontSize: 32,
marginTop: 32,
}}
>
DNS records, WHOIS data, SSL/TLS certificates & more
</span>
</div>
),
{
width: 1200,
height: 630,
fonts: [
{
name: 'Inter',
data: interRegularFont,
style: 'normal',
weight: 400,
},
{
name: 'Inter',
data: interBoldFont,
style: 'normal',
weight: 700,
},
],
}
);
};

export default handler;
3 changes: 3 additions & 0 deletions app/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
User-agent: *
Allow: /
Host: https://digga.dev
Loading