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

DoH resolver implementation #1

Merged
merged 9 commits into from
Apr 12, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
vyzo committed Apr 8, 2021
commit 46ccfe2e705ea8479d7654f7c1044d1e509f1e4d
30 changes: 30 additions & 0 deletions resolver_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package doh

import (
"context"
"testing"
)

func TestLookupIPAddr(t *testing.T) {
Copy link
Member

@lidel lidel Apr 9, 2021

Choose a reason for hiding this comment

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

Would be good to have an explicit check that confirms this returns both ipv4 AND ipv6 (libp2p.io has both, so good candidate)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure, let me do that/

r := NewResolver("https://cloudflare-dns.com/dns-query")

ips, err := r.LookupIPAddr(context.Background(), "ewr-1.bootstrap.libp2p.io")
vyzo marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
t.Fatal(err)
}
if len(ips) == 0 {
t.Fatal("got no IPs")
}
}

func TestLookupTXT(t *testing.T) {
r := NewResolver("https://cloudflare-dns.com/dns-query")

txt, err := r.LookupTXT(context.Background(), "_dnsaddr.bootstrap.libp2p.io")
if err != nil {
t.Fatal(err)
}
if len(txt) == 0 {
t.Fatal("got no TXT entries")
}
}