diff --git a/main.go b/main.go index 07ece2b..3509fb2 100644 --- a/main.go +++ b/main.go @@ -98,6 +98,7 @@ func dnsStampToURL(s string) (string, error) { // TODO: This might be a source of problems...we might want to be using parsedStamp.ServerAddrStr u.Host = parsedStamp.ProviderName + u.Path = parsedStamp.Path log.Tracef("DNS stamp parsed into URL as %s", u.String()) return u.String(), nil diff --git a/main_test.go b/main_test.go index c775a53..3ecb16f 100644 --- a/main_test.go +++ b/main_test.go @@ -543,3 +543,34 @@ func TestMainQueryTypeFlag(t *testing.T) { assert.Nil(t, err) assert.Regexp(t, regexp.MustCompile(`cloudflare.com. .* HTTPS 1 .*`), out.String()) } + +func TestMainDnsstampDoH(t *testing.T) { + out, err := run( + "@sdns://AgcAAAAAAAAADjEwNC4xNi4yNDguMjQ5ABJjbG91ZGZsYXJlLWRucy5jb20A", // cloudflare-dns.com + "--all", + ) + + assert.Nil(t, err) + assert.Contains(t, out.String(), "from https://cloudflare-dns.com:443/dns-query") +} + +func TestMainDnsstampDoHPath(t *testing.T) { + _, err := run( + "@sdns://AgcAAAAAAAAADjEwNC4xNi4yNDguMjQ5ABJjbG91ZGZsYXJlLWRucy5jb20FL3Rlc3Q", // cloudflare-dns.com/test + "--all", + ) + + // use err here because the query will result in a 404 + assert.Contains(t, err.Error(), "from https://cloudflare-dns.com:443/test") +} + +func TestMainDnsstampInvalid(t *testing.T) { + _, err := run( + "@sdns://invalid", + "--all", + ) + + assert.NotNil(t, err) + assert.Contains(t, err.Error(), "converting DNS stamp to URL: illegal base64 data") +} +