observablehq.com
Open in
urlscan Pro
2606:4700:10::6816:14dc
Public Scan
URL:
https://observablehq.com/@panningforbacon/dns-lookup-in-javascript
Submission: On May 08 via manual from GB — Scanned from GB
Submission: On May 08 via manual from GB — Scanned from GB
Form analysis
0 forms found in the DOMText Content
Why Observable Product Use cases Resources Pricing SearchSign inSign up Steve Fork Public Edited Mar 15 1 Like Insert cell Insert cell Insert cell Insert cell Insert cell Insert cell Insert cell doh_nameserver_url = `https://1.1.1.1/dns-query`; Insert cell resolver = { const { DohResolver } = await require('https://cdn.jsdelivr.net/npm/dohjs@latest/dist/doh.min.js'); return new DohResolver(doh_nameserver_url); } Insert cell queryDnsRecords = async (domainName, recordType = 'A') => { /* guard against missing inputs */ if (!domainName) throw Error(`No DNS domain name provided: "${domainName}"`); if (!recordType) throw Error(`No DNS record type provided: "${recordType}"`); /* run query, catch timeouts/errors */ let res; try { res = await resolver.query(domainName, recordType, 'GET', 'Accept: application/dns-message', 1000); } catch (err) { return err; } /* trap DNS error response codes */ if (res.rcode !== 'NOERROR') { switch (res.rcode) { case 'NXDOMAIN': throw Error("NXDOMAIN: DNS query failed because the domain name queried does not exist"); break; case 'SERVFAIL': throw Error("SERVFAIL: DNS query failed because the answer cannot be given"); break; case 'REFUSED': throw Error("REFUSED: DNS query failed because the server refused to anser due to policy"); break; default: throw Error("DNS query returned an unknown response code"); } } return res.answers; } Insert cell Create interactive documents like this one. Sign up for free Learn new data visualization techniques. Perform complex data analysis. Publish your findings in a compelling document. All in the same tool. Sign up for free More from Observable creators View all Conformal Prediction Herb Susmann Apr 18 Pension Calculator 🧓👴 🚧 draft4 Declan Naughton Apr 25• 1 Πόσο χρονών είσαι, Θεσσαλονίκη; infographeo Feb 20• 3 Hello, Plotteus! Bartosz Prusinowski Feb 28• 30 2 The logistic bifurcation locus Mark McClure Apr 9• 7 How clean is your state’s electricity? Climate Lab•Harry Stevens Apr 12• 35 Data Exploration on "Oscar Data" using SQL This notebook is a fork urvi•URVI JAIN Mar 14• 3 Spotify Beeswarm Plot 2.0 Tanya Shapiro Apr 10• 1 Product * Integrations * Pricing Resources * Customer stories * Community * Documentation Company * Blog * Jobs * Newsletter LinkedInTwitterGitHubYouTube © 2023 Observable, Inc.PrivacyTerms of Service Fork View Export Edit Pin Add comment Select Duplicate Copy link Embed Delete domainName Edit Pin Add comment Copy import Select Duplicate Copy link Embed Delete recordTypes Edit Pin Add comment Copy import Select Duplicate Copy link Embed Delete Edit Pin Add comment Select Duplicate Copy link Embed Delete Edit Pin Add comment Select Duplicate Copy link Embed Delete Edit Pin Add comment Select Duplicate Copy link Embed Delete doh_nameserver_url Unpin Add comment Copy import Select Duplicate Copy link Embed Delete resolver Unpin Add comment Copy import Select Duplicate Copy link Embed Delete queryDnsRecords Unpin Add comment Copy import Select Duplicate Copy link Embed Delete For developers For spreadsheet users For SQL users For data analysts Explore the community Integrations Security Observable Plot Customer stories Try Observable Pharma Finance Technology Education Tutorials Community Docs Blog JavaScript Markdown HTML JavaScript Markdown HTML JavaScript Markdown HTML