From c03e420355e8ead3ce73b07ffbbf235430a97441 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 5 Sep 2022 17:31:00 +0300 Subject: [PATCH] nns: allow to resolve FQDN Port https://github.com/nspcc-dev/neofs-contract/pull/139/commits/4041924a75a7d292b2e42b83f5795d7cb961bcba. --- examples/nft-nd-nns/nns.go | 6 ++++++ examples/nft-nd-nns/nns_test.go | 2 ++ 2 files changed, 8 insertions(+) diff --git a/examples/nft-nd-nns/nns.go b/examples/nft-nd-nns/nns.go index 529f24f88..e50abc9db 100644 --- a/examples/nft-nd-nns/nns.go +++ b/examples/nft-nd-nns/nns.go @@ -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) { diff --git a/examples/nft-nd-nns/nns_test.go b/examples/nft-nd-nns/nns_test.go index 38c10f9af..426899675 100644 --- a/examples/nft-nd-nns/nns_test.go +++ b/examples/nft-nd-nns/nns_test.go @@ -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)) }