mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-30 05:56:54 -05:00
check domain name
This commit is contained in:
parent
fae47083c2
commit
2aa0c08709
@ -196,6 +196,14 @@ func toNetIP(ips []net.Address) []net.IP {
|
||||
}
|
||||
|
||||
func (s *Server) lookupIPInternal(domain string, option IPOption) ([]net.IP, error) {
|
||||
if len(domain) == 0 {
|
||||
return nil, newError("empty domain name")
|
||||
}
|
||||
|
||||
if domain[len(domain)-1] == '.' {
|
||||
domain = domain[:len(domain)-1]
|
||||
}
|
||||
|
||||
ips := s.lookupStatic(domain, option, 0)
|
||||
if ips != nil && ips[0].Family().IsIP() {
|
||||
return toNetIP(ips), nil
|
||||
|
@ -216,18 +216,18 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string,
|
||||
RCode: dnsmessage.RCodeSuccess,
|
||||
Response: true,
|
||||
})
|
||||
builder.StartAnswers()
|
||||
common.Must(builder.StartAnswers())
|
||||
|
||||
rHeader := dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(domain), Class: dnsmessage.ClassINET, TTL: 600}
|
||||
for _, ip := range ips {
|
||||
if len(ip) == net.IPv4len {
|
||||
var r dnsmessage.AResource
|
||||
copy(r.A[:], ip)
|
||||
builder.AResource(rHeader, r)
|
||||
common.Must(builder.AResource(rHeader, r))
|
||||
} else {
|
||||
var r dnsmessage.AAAAResource
|
||||
copy(r.AAAA[:], ip)
|
||||
builder.AAAAResource(rHeader, r)
|
||||
common.Must(builder.AAAAResource(rHeader, r))
|
||||
}
|
||||
}
|
||||
msgBytes, err := builder.Finish()
|
||||
|
Loading…
Reference in New Issue
Block a user