nns: allow to resolve FQDN

Port 4041924a75.
This commit is contained in:
Anna Shaleva 2022-09-05 17:31:00 +03:00
parent e97467726c
commit c03e420355
2 changed files with 8 additions and 0 deletions

View file

@ -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) {

View file

@ -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))
}