forked from CorentinTh/it-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new tool): DNS query (over HTTPS)
Fix part of CorentinTh#831
- Loading branch information
Showing
4 changed files
with
139 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters