From 0c50ea3a9f826031e1ea133b8da5c3308eeed086 Mon Sep 17 00:00:00 2001 From: Primexz Date: Tue, 7 Jan 2025 01:04:21 +0100 Subject: [PATCH 1/3] fix: add url path from dnsstamp --- main.go | 1 + 1 file changed, 1 insertion(+) 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 From 69e27bd22a685d636ab553eda26b19d9b8aa2554 Mon Sep 17 00:00:00 2001 From: Primexz Date: Tue, 7 Jan 2025 08:22:03 +0100 Subject: [PATCH 2/3] test: add basic dnsstamp tests --- main_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/main_test.go b/main_test.go index c775a53..97b8483 100644 --- a/main_test.go +++ b/main_test.go @@ -543,3 +543,24 @@ 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") +} + From d5c11d2141d41776672e7425fbc99b306fdc4d6d Mon Sep 17 00:00:00 2001 From: Primexz Date: Tue, 7 Jan 2025 08:26:33 +0100 Subject: [PATCH 3/3] test: add invalid test --- main_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main_test.go b/main_test.go index 97b8483..3ecb16f 100644 --- a/main_test.go +++ b/main_test.go @@ -564,3 +564,13 @@ func TestMainDnsstampDoHPath(t *testing.T) { 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") +} +