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

fix: add url path from dnsstamp #104

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
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")
}

Loading