weight for SRV records should be at least 1 (#3931)

Automatically submitted.
This commit is contained in:
Yang Bo 2020-06-12 14:01:28 +08:00 committed by GitHub
parent 86df1282cb
commit 4734c0db45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View file

@ -185,6 +185,10 @@ func SRV(ctx context.Context, b ServiceBackend, zone string, state request.Reque
w1 *= float64(serv.Weight)
}
weight := uint16(math.Floor(w1))
// weight should be at least 1
if weight == 0 {
weight = 1
}
what, ip := serv.HostType()

View file

@ -103,6 +103,10 @@ func (e *External) srv(services []msg.Service, state request.Request) (records,
w1 *= float64(s.Weight)
}
weight := uint16(math.Floor(w1))
// weight should be at least 1
if weight == 0 {
weight = 1
}
what, ip := s.HostType()

View file

@ -228,6 +228,11 @@ func calcSRVWeight(numservices int) uint16 {
}
w[serv.Priority] += weight
}
weight := uint16(math.Floor((100.0 / float64(w[0])) * 100))
// weight should be at least 1
if weight == 0 {
weight = 1
}
return uint16(math.Floor((100.0 / float64(w[0])) * 100))
return weight
}