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(minipipeline): sort A before AAAA #1509

Merged
merged 3 commits into from
Feb 12, 2024
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
8 changes: 8 additions & 0 deletions internal/minipipeline/sorting.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ func SortDNSLookupResults(inputs []*model.ArchivalDNSLookupResult) (outputs []*m
return false
}

// we want A entries to appear before AAAA entries
if left.QueryType < right.QueryType {
return true
}
if left.QueryType > right.QueryType {
return false
}

// we want entries that are successful to appear first
fsget := func(value *string) string {
if value == nil {
Expand Down
28 changes: 28 additions & 0 deletions internal/minipipeline/sorting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,27 @@ func TestSortDNSLookupResults(t *testing.T) {
ResolverAddress: "1.1.1.1:53",
TransactionID: 5,
},
{
Engine: "udp",
Failure: nil,
QueryType: "AAAA",
ResolverAddress: "1.1.1.1:53",
TransactionID: 5,
},
{
Engine: "udp",
Failure: newfailurestring("dns_no_answer"),
QueryType: "AAAA",
ResolverAddress: "8.8.8.8:53",
TransactionID: 3,
},
{
Engine: "udp",
Failure: nil,
QueryType: "AAAA",
ResolverAddress: "8.8.8.8:53",
TransactionID: 3,
},
{
Engine: "udp",
Failure: nil,
Expand Down Expand Up @@ -124,6 +138,13 @@ func TestSortDNSLookupResults(t *testing.T) {
ResolverAddress: "8.8.8.8:53",
TransactionID: 3,
},
{
Engine: "udp",
Failure: nil,
QueryType: "AAAA",
ResolverAddress: "8.8.8.8:53",
TransactionID: 3,
},
{
Engine: "udp",
Failure: newfailurestring("dns_no_answer"),
Expand All @@ -138,6 +159,13 @@ func TestSortDNSLookupResults(t *testing.T) {
ResolverAddress: "1.1.1.1:53",
TransactionID: 5,
},
{
Engine: "udp",
Failure: nil,
QueryType: "AAAA",
ResolverAddress: "1.1.1.1:53",
TransactionID: 5,
},
{
Engine: "udp",
Failure: newfailurestring("dns_no_answer"),
Expand Down
Loading
Loading