1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-17 23:06:30 -05:00

skip answer if it is not A or AAAA record

This commit is contained in:
Darien Raymond 2018-11-22 17:16:44 +01:00
parent 4b6e12815d
commit 9cad27e9bd
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -132,6 +132,9 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, payload *buf.Buf
for { for {
header, err := parser.AnswerHeader() header, err := parser.AnswerHeader()
if err != nil { if err != nil {
if err != dnsmessage.ErrSectionDone {
newError("failed to parse answer section for domain: ", domain).Base(err).WriteToLog()
}
break break
} }
ttl := header.TTL ttl := header.TTL
@ -142,6 +145,7 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, payload *buf.Buf
case dnsmessage.TypeA: case dnsmessage.TypeA:
ans, err := parser.AResource() ans, err := parser.AResource()
if err != nil { if err != nil {
newError("failed to parse A record for domain: ", domain).Base(err).WriteToLog()
break break
} }
ips = append(ips, IPRecord{ ips = append(ips, IPRecord{
@ -151,6 +155,7 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, payload *buf.Buf
case dnsmessage.TypeAAAA: case dnsmessage.TypeAAAA:
ans, err := parser.AAAAResource() ans, err := parser.AAAAResource()
if err != nil { if err != nil {
newError("failed to parse A record for domain: ", domain).Base(err).WriteToLog()
break break
} }
ips = append(ips, IPRecord{ ips = append(ips, IPRecord{
@ -158,6 +163,9 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, payload *buf.Buf
Expire: now.Add(time.Duration(ttl) * time.Second), Expire: now.Add(time.Duration(ttl) * time.Second),
}) })
default: default:
if err := parser.SkipAnswer(); err != nil {
newError("failed to skip answer").Base(err).WriteToLog()
}
} }
} }