From b37a26b365be5fab76499141bac17d6d2442cda1 Mon Sep 17 00:00:00 2001 From: Aurora Gaffney Date: Wed, 22 Nov 2023 18:04:08 -0600 Subject: [PATCH] fix: store on-chain domain using canonical name --- internal/dns/dns.go | 2 ++ internal/indexer/indexer.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/internal/dns/dns.go b/internal/dns/dns.go index 0819ce9..f9f2d57 100644 --- a/internal/dns/dns.go +++ b/internal/dns/dns.go @@ -292,6 +292,8 @@ func findNameserversForDomain( // Check on-chain domains first for startLabelIdx := 0; startLabelIdx < len(queryLabels); startLabelIdx++ { lookupDomainName := strings.Join(queryLabels[startLabelIdx:], ".") + // Convert to canonical form for consistency + lookupDomainName = dns.CanonicalName(lookupDomainName) nameservers, err := state.GetState().LookupDomain(lookupDomainName) if err != nil { return "", nil, err diff --git a/internal/indexer/indexer.go b/internal/indexer/indexer.go index 45e7806..5e55484 100644 --- a/internal/indexer/indexer.go +++ b/internal/indexer/indexer.go @@ -23,6 +23,7 @@ import ( input_chainsync "github.com/blinklabs-io/snek/input/chainsync" output_embedded "github.com/blinklabs-io/snek/output/embedded" "github.com/blinklabs-io/snek/pipeline" + "github.com/miekg/dns" ) type Domain struct { @@ -169,6 +170,8 @@ func (i *Indexer) handleEvent(evt event.Event) error { continue } domainName := string(dnsDomain.Origin) + // Convert to canonical form for consistency + domainName = dns.CanonicalName(domainName) nameServers := map[string]string{} for _, record := range dnsDomain.Records { // NOTE: we're losing information here, but we need to revamp the storage