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

feat(new tool): DNS query (over HTTPS) #1371

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"cronstrue": "^2.26.0",
"crypto-js": "^4.1.1",
"date-fns": "^2.29.3",
"dns-query": "^0.11.2",
"dompurify": "^3.0.6",
"email-normalizer": "^1.0.0",
"emojilib": "^3.0.10",
Expand Down
71 changes: 68 additions & 3 deletions pnpm-lock.yaml

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

68 changes: 68 additions & 0 deletions src/tools/dns-queries/dns-queries.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<script setup lang="ts">
import { combineTXT, query, wellknown } from 'dns-query';
import types from './dns.records.types.json';

const type = ref('A');
const name = ref('google.com');
const answers = ref<string[]>([]);

async function queryDNS() {
const endpoints = await wellknown.endpoints('doh');
try {
const response = await query({
question: { type: type.value, name: name.value },
}, {
endpoints,
});
if (type.value === 'TXT') {
answers.value = (response.answers || []).map(answer => `${answer.name} ${answer.type} ${combineTXT(answer.data as Uint8Array[])} (TTL=${answer.ttl})`);
}
else {
answers.value = (response.answers || []).map(answer => `${answer.name} ${answer.type} ${answer.data} (TTL=${answer.ttl})`);
}
}
catch (error: any) {
answers.value = [error.toString()];
}
}
</script>

<template>
<div>
<c-input-text
v-model:value="name"
label="Name"
label-position="left"
placeholder="Name to query"
mb-2
/>
<c-select
v-model:value="type"
searchable
label="DNS record type:"
label-position="left"
:options="Object.values(types).map(kv => ({ value: kv.value, label: `${kv.value}: ${kv.label}` }))"
mb-2
/>

<div flex justify-center>
<c-button
@click="queryDNS"
>
Send DNS query
</c-button>
</div>

<n-divider />

<c-card title="Query results">
<textarea-copyable
v-for="(answer, index) in answers"
:key="index"
:value="answer"
word-wrap
mb-2
/>
</c-card>
</div>
</template>
49 changes: 49 additions & 0 deletions src/tools/dns-queries/dns.records.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[
{ "value": "A", "label": "Address record" },
{ "value": "AAAA", "label": "IPv6 address record" },
{ "value": "AFSDB", "label": "AFS database record" },
{ "value": "APL", "label": "Address Prefix List" },
{ "value": "CAA", "label": "Certification Authority Authorization" },
{ "value": "CDNSKEY", "label": "CDNSKEY" },
{ "value": "CDS", "label": "Child DS" },
{ "value": "CERT", "label": "Certificate record" },
{ "value": "CNAME", "label": "Canonical name record" },
{ "value": "CSYNC", "label": "Child-to-Parent Synchronization" },
{ "value": "DHCID", "label": "DHCP identifier" },
{ "value": "DLV", "label": "DNSSEC Lookaside Validation record" },
{ "value": "DNAME", "label": "Delegation name record" },
{ "value": "DNSKEY", "label": "DNS Key record" },
{ "value": "DS", "label": "Delegation signer" },
{ "value": "EUI48", "label": "MAC address (EUI-48)" },
{ "value": "EUI64", "label": "MAC address (EUI-64)" },
{ "value": "HINFO", "label": "Host Information" },
{ "value": "HIP", "label": "Host Identity Protocol" },
{ "value": "HTTPS", "label": "HTTPS Binding" },
{ "value": "IPSECKEY", "label": "IPsec Key" },
{ "value": "KEY", "label": "Key record" },
{ "value": "KX", "label": "Key Exchanger record" },
{ "value": "LOC", "label": "Location record" },
{ "value": "MX", "label": "Mail exchange record" },
{ "value": "NAPTR", "label": "Naming Authority Pointer" },
{ "value": "NS", "label": "Name server record" },
{ "value": "NSEC", "label": "Next Secure record" },
{ "value": "NSEC3", "label": "Next Secure record version 3" },
{ "value": "NSEC3PARAM", "label": "NSEC3 parameters" },
{ "value": "OPENPGPKEY", "label": "OpenPGP public key record" },
{ "value": "PTR", "label": "PTR Resource Record" },
{ "value": "RP", "label": "Responsible Person" },
{ "value": "RRSIG", "label": "DNSSEC signature" },
{ "value": "SIG", "label": "Signature" },
{ "value": "SMIMEA", "label": "S/MIME cert association" },
{ "value": "SOA", "label": "Start of [a zone of] authority record" },
{ "value": "SRV", "label": "Service locator" },
{ "value": "SSHFP", "label": "SSH Public Key Fingerprint" },
{ "value": "SVCB", "label": "Service Binding" },
{ "value": "TA", "label": "DNSSEC Trust Authorities" },
{ "value": "TKEY", "label": "Transaction Key record" },
{ "value": "TLSA", "label": "TLSA certificate association" },
{ "value": "TSIG", "label": "Transaction Signature" },
{ "value": "TXT", "label": "Text record" },
{ "value": "URI", "label": "Uniform Resource Identifier" },
{ "value": "ZONEMD", "label": "Message Digests for DNS Zones" }
]
12 changes: 12 additions & 0 deletions src/tools/dns-queries/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { World } from '@vicons/tabler';
import { defineTool } from '../tool';

export const tool = defineTool({
name: 'DNS Queries',
path: '/dns-queries',
description: 'Perform DNS Queries (over HTTPS)',
keywords: ['dns', 'nslookup', 'queries'],
component: () => import('./dns-queries.vue'),
icon: World,
createdAt: new Date('2024-08-15'),
});
11 changes: 10 additions & 1 deletion src/tools/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { tool as base64FileConverter } from './base64-file-converter';
import { tool as base64StringConverter } from './base64-string-converter';
import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as dnsQueries } from './dns-queries';
import { tool as emailNormalizer } from './email-normalizer';

import { tool as asciiTextDrawer } from './ascii-text-drawer';
Expand Down Expand Up @@ -164,7 +165,15 @@ export const toolsByCategory: ToolCategory[] = [
},
{
name: 'Network',
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
components: [
ipv4SubnetCalculator,
ipv4AddressConverter,
ipv4RangeExpander,
macAddressLookup,
macAddressGenerator,
ipv6UlaGenerator,
dnsQueries,
],
},
{
name: 'Math',
Expand Down
Loading