Skip to content

Commit

Permalink
fix: no records behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
gnuletik committed Sep 16, 2024
1 parent b907b38 commit 54f4eb9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ func (c *Client) queryMultiple(host string, requestTypes []uint16, resolver Reso
}
}
// Finished retry loop at limit, bail out
if i == c.options.MaxRetries {
if i == c.options.MaxRetries && err != nil {
err = ErrRetriesExceeded
break
}
Expand Down
17 changes: 17 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/miekg/dns"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -147,6 +148,22 @@ func TestRetries(t *testing.T) {
require.True(t, err == ErrRetriesExceeded)
}

func TestNoRecords(t *testing.T) {
client, err := New([]string{"8.8.8.8:53", "1.1.1.1:53"}, 5)
require.NoError(t, err)

// Test various query types
res, err := client.QueryMultiple("donotexist.scanme.sh", []uint16{
dns.TypeA,
dns.TypeAAAA,
})
require.NoError(t, err)
require.NotNil(t, res)

assert.Empty(t, res.A)
assert.Empty(t, res.AAAA)
}

func TestTrace(t *testing.T) {
client, _ := New([]string{"8.8.8.8:53", "1.1.1.1:53"}, 5)

Expand Down

0 comments on commit 54f4eb9

Please sign in to comment.