parent
e97467726c
commit
c03e420355
2 changed files with 8 additions and 0 deletions
|
@ -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) {
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue