Skip to content

Commit

Permalink
Merge pull request #104 from Primexz/fix-dnsstamp-path
Browse files Browse the repository at this point in the history
fix: add url path from dnsstamp
  • Loading branch information
natesales authored Jan 15, 2025
2 parents 1e2cb0f + d5c11d2 commit 46ce32b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit 46ce32b

Please sign in to comment.