Skip to content

Commit 2f0df43

Browse files
committed
Merge branch 'feat/dns-query' into chore/all-my-stuffs
2 parents fbcfdbc + 8c03359 commit 2f0df43

File tree

6 files changed

+208
-4
lines changed

6 files changed

+208
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"currency-codes-ts": "^3.0.0",
7171
"currency-exchanger-js": "^1.0.4",
7272
"date-fns": "^2.29.3",
73+
"dns-query": "^0.11.2",
7374
"dompurify": "^3.0.6",
7475
"email-bounce-parser-browser": "^1.1",
7576
"email-normalizer": "^1.0.0",

pnpm-lock.yaml

Lines changed: 68 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/dns-queries/dns-queries.vue

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<script setup lang="ts">
2+
import { combineTXT, query, wellknown } from 'dns-query';
3+
import types from './dns.records.types.json';
4+
5+
const type = ref('A');
6+
const name = ref('google.com');
7+
const answers = ref<string[]>([]);
8+
9+
async function queryDNS() {
10+
const endpoints = await wellknown.endpoints('doh');
11+
try {
12+
const response = await query({
13+
question: { type: type.value, name: name.value },
14+
}, {
15+
endpoints,
16+
});
17+
if (type.value === 'TXT') {
18+
answers.value = (response.answers || []).map(answer => `${answer.name} ${answer.type} ${combineTXT(answer.data as Uint8Array[])} (TTL=${answer.ttl})`);
19+
}
20+
else {
21+
answers.value = (response.answers || []).map(answer => `${answer.name} ${answer.type} ${answer.data} (TTL=${answer.ttl})`);
22+
}
23+
}
24+
catch (error: any) {
25+
answers.value = [error.toString()];
26+
}
27+
}
28+
</script>
29+
30+
<template>
31+
<div>
32+
<c-input-text
33+
v-model:value="name"
34+
label="Name"
35+
label-position="left"
36+
placeholder="Name to query"
37+
mb-2
38+
/>
39+
<c-select
40+
v-model:value="type"
41+
searchable
42+
label="DNS record type:"
43+
label-position="left"
44+
:options="Object.values(types).map(kv => ({ value: kv.value, label: `${kv.value}: ${kv.label}` }))"
45+
mb-2
46+
/>
47+
48+
<div flex justify-center>
49+
<c-button
50+
@click="queryDNS"
51+
>
52+
Send DNS query
53+
</c-button>
54+
</div>
55+
56+
<n-divider />
57+
58+
<c-card title="Query results">
59+
<textarea-copyable
60+
v-for="(answer, index) in answers"
61+
:key="index"
62+
:value="answer"
63+
word-wrap
64+
mb-2
65+
/>
66+
</c-card>
67+
</div>
68+
</template>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[
2+
{ "value": "A", "label": "Address record" },
3+
{ "value": "AAAA", "label": "IPv6 address record" },
4+
{ "value": "AFSDB", "label": "AFS database record" },
5+
{ "value": "APL", "label": "Address Prefix List" },
6+
{ "value": "CAA", "label": "Certification Authority Authorization" },
7+
{ "value": "CDNSKEY", "label": "CDNSKEY" },
8+
{ "value": "CDS", "label": "Child DS" },
9+
{ "value": "CERT", "label": "Certificate record" },
10+
{ "value": "CNAME", "label": "Canonical name record" },
11+
{ "value": "CSYNC", "label": "Child-to-Parent Synchronization" },
12+
{ "value": "DHCID", "label": "DHCP identifier" },
13+
{ "value": "DLV", "label": "DNSSEC Lookaside Validation record" },
14+
{ "value": "DNAME", "label": "Delegation name record" },
15+
{ "value": "DNSKEY", "label": "DNS Key record" },
16+
{ "value": "DS", "label": "Delegation signer" },
17+
{ "value": "EUI48", "label": "MAC address (EUI-48)" },
18+
{ "value": "EUI64", "label": "MAC address (EUI-64)" },
19+
{ "value": "HINFO", "label": "Host Information" },
20+
{ "value": "HIP", "label": "Host Identity Protocol" },
21+
{ "value": "HTTPS", "label": "HTTPS Binding" },
22+
{ "value": "IPSECKEY", "label": "IPsec Key" },
23+
{ "value": "KEY", "label": "Key record" },
24+
{ "value": "KX", "label": "Key Exchanger record" },
25+
{ "value": "LOC", "label": "Location record" },
26+
{ "value": "MX", "label": "Mail exchange record" },
27+
{ "value": "NAPTR", "label": "Naming Authority Pointer" },
28+
{ "value": "NS", "label": "Name server record" },
29+
{ "value": "NSEC", "label": "Next Secure record" },
30+
{ "value": "NSEC3", "label": "Next Secure record version 3" },
31+
{ "value": "NSEC3PARAM", "label": "NSEC3 parameters" },
32+
{ "value": "OPENPGPKEY", "label": "OpenPGP public key record" },
33+
{ "value": "PTR", "label": "PTR Resource Record" },
34+
{ "value": "RP", "label": "Responsible Person" },
35+
{ "value": "RRSIG", "label": "DNSSEC signature" },
36+
{ "value": "SIG", "label": "Signature" },
37+
{ "value": "SMIMEA", "label": "S/MIME cert association" },
38+
{ "value": "SOA", "label": "Start of [a zone of] authority record" },
39+
{ "value": "SRV", "label": "Service locator" },
40+
{ "value": "SSHFP", "label": "SSH Public Key Fingerprint" },
41+
{ "value": "SVCB", "label": "Service Binding" },
42+
{ "value": "TA", "label": "DNSSEC Trust Authorities" },
43+
{ "value": "TKEY", "label": "Transaction Key record" },
44+
{ "value": "TLSA", "label": "TLSA certificate association" },
45+
{ "value": "TSIG", "label": "Transaction Signature" },
46+
{ "value": "TXT", "label": "Text record" },
47+
{ "value": "URI", "label": "Uniform Resource Identifier" },
48+
{ "value": "ZONEMD", "label": "Message Digests for DNS Zones" }
49+
]

src/tools/dns-queries/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { World } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'DNS Queries',
6+
path: '/dns-queries',
7+
description: 'Perform DNS Queries (over HTTPS)',
8+
keywords: ['dns', 'nslookup', 'queries'],
9+
component: () => import('./dns-queries.vue'),
10+
icon: World,
11+
createdAt: new Date('2024-08-15'),
12+
});

src/tools/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { tool as base64FileConverter } from './base64-file-converter';
22
import { tool as base64StringConverter } from './base64-string-converter';
33
import { tool as basicAuthGenerator } from './basic-auth-generator';
4+
import { tool as dnsQueries } from './dns-queries';
45
import { tool as emailNormalizer } from './email-normalizer';
56
import { tool as bounceParser } from './bounce-parser';
67
import { tool as codeHighlighter } from './code-highlighter';
@@ -211,7 +212,15 @@ export const toolsByCategory: ToolCategory[] = [
211212
},
212213
{
213214
name: 'Network',
214-
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
215+
components: [
216+
ipv4SubnetCalculator,
217+
ipv4AddressConverter,
218+
ipv4RangeExpander,
219+
macAddressLookup,
220+
macAddressGenerator,
221+
ipv6UlaGenerator,
222+
dnsQueries,
223+
],
215224
},
216225
{
217226
name: 'Math',

0 commit comments

Comments
 (0)