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: store on-chain domain using canonical name #84

Merged
merged 1 commit into from
Nov 23, 2023
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
2 changes: 2 additions & 0 deletions internal/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions internal/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
Loading