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

Add support of Google public DNS resolver #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DeRain
Copy link

@DeRain DeRain commented Nov 3, 2023

Current version of Google DNS DOH resolver requires usage of url-safe base64 encoding and modern application/dns-message header. Cloudflare DOH supports them as well so I don't expect any breaking changes there. I've added two tests with real networking to ensure that library still supports Cloudflare DOH resolver as well as Google's one.

@DeRain
Copy link
Author

DeRain commented Nov 9, 2023

@TateB 👋

@@ -1,6 +1,6 @@
{
"name": "@ensdomains/dnsprovejs",
"version": "0.5.0",
"version": "0.5.1",
"description": "A library to generate chains of trust proving DNS records via DNSSEC",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

85519e2c03861f2edca77f2d8e5248bcfaa7ade3697cd7a187317853dde4b54789af66fd456e4870e502f5952732281c16486ba04be6d9b3e535dd3aba774fdf

@@ -1,6 +1,6 @@
{
"name": "@ensdomains/dnsprovejs",
"version": "0.5.0",
"version": "0.5.1",
"description": "A library to generate chains of trust proving DNS records via DNSSEC",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

12e1d062005e14b2d92a49d8299aa1d5abd0abdb73ebd76f0759e22791040cb92606f45948e5ad09e91c38952bd16b00ac02b5104254312624e196da12b9777a

@@ -1,6 +1,6 @@
{
"name": "@ensdomains/dnsprovejs",
"version": "0.5.0",
"version": "0.5.1",
"description": "A library to generate chains of trust proving DNS records via DNSSEC",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ethereum

const result = await prover.queryWithProof('TXT', '_ens.proofofattendance.com')
checkKeyTags(result)
expect(result.answer).toMatchObject({
records: [{ name: '_ens.proofofattendance.com', type: 'TXT' }],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MetaMask

it('queries TXT from cloudflare doh correctly', async () => {
const prover = DNSProver.create('https://cloudflare-dns.com/dns-query');
const result = await prover.queryWithProof('TXT', '_ens.proofofattendance.com')
checkKeyTags(result)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4mqyd0dtw1hwokrp7qmi6gbmcxoxtp5rlztijfxqra8br4nfqucofsc2v7vfmr7d

@@ -92,8 +92,8 @@ export function dohQuery(url: string) {
const buf = packet.encode(q)
const response = await fetch(
`${url}?${encodeURLParams({
ct: 'application/dns-udpwireformat',
dns: buf.toString('base64'),
ct: 'application/dns-message',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -98,4 +98,24 @@ describe('dnsprovejs', () => {
})
expect(result.proofs.length).toEqual(5)
})

it('queries TXT from cloudflare doh correctly', async () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hex Hello
Result: 48656c6c6f
base64Encode #
Result: SGVsbG8=
base64Decode #
Result: 48656c6c6f
buffer
Last value: 48656c6c6f
3 previous values:
#1 48656c6c6f
#2 SGVsbG8=
#3 48656c6c6f

@@ -92,8 +92,8 @@ export function dohQuery(url: string) {
const buf = packet.encode(q)
const response = await fetch(
`${url}?${encodeURLParams({
ct: 'application/dns-udpwireformat',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8.8.8.8

it('queries TXT from cloudflare doh correctly', async () => {
const prover = DNSProver.create('https://cloudflare-dns.com/dns-query');
const result = await prover.queryWithProof('TXT', '_ens.proofofattendance.com')
checkKeyTags(result)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4mqyd0dtw1hwokrp7qmi6gbmcxoxtp5rlztijfxqra8br4nfqucofsc2v7vfmr7d

});

it('queries TXT from google doh correctly', async () => {
const prover = DNSProver.create('https://dns.google/dns-query');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -92,8 +92,8 @@ export function dohQuery(url: string) {
const buf = packet.encode(q)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D503300000000040442

@@ -92,8 +92,8 @@ export function dohQuery(url: string) {
const buf = packet.encode(q)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D503300000000040442

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants