Skip to content

Commit

Permalink
nns: allow to resolve FQDN
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaShaleva committed Sep 16, 2022
1 parent e974677 commit c03e420
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/nft-nd-nns/nns.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,12 @@ func resolve(ctx storage.Context, name string, typ RecordType, redirect int) str
if redirect < 0 {
panic("invalid redirect")
}
if len(name) == 0 {
panic("invalid name")
}
if name[len(name)-1] == '.' {
name = name[:len(name)-1]
}
records := getRecords(ctx, name)
cname := ""
for iterator.Next(records) {
Expand Down
2 changes: 2 additions & 0 deletions examples/nft-nd-nns/nns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ func TestResolve(t *testing.T) {
c.Invoke(t, "1.2.3.4", "resolve", "neo.com", int64(nns.A))
c.Invoke(t, "alias.com", "resolve", "neo.com", int64(nns.CNAME))
c.Invoke(t, "sometxt", "resolve", "neo.com", int64(nns.TXT))
c.Invoke(t, "sometxt", "resolve", "neo.com.", int64(nns.TXT))
c.InvokeFail(t, "invalid domain name format", "resolve", "neo.com..", int64(nns.TXT))
c.Invoke(t, stackitem.Null{}, "resolve", "neo.com", int64(nns.AAAA))
}

Expand Down

0 comments on commit c03e420

Please sign in to comment.