dns: move ttl closer to usage

This commit is contained in:
Frank Schroeder 2017-08-21 10:48:01 +02:00 committed by Frank Schröder
parent 642fcd4611
commit 70be1ab635
1 changed files with 10 additions and 10 deletions

View File

@ -711,16 +711,6 @@ RPC:
}
}
// Determine the TTL
var ttl time.Duration
if d.config.ServiceTTL != nil {
var ok bool
ttl, ok = d.config.ServiceTTL[service]
if !ok {
ttl = d.config.ServiceTTL["*"]
}
}
// Filter out any service nodes due to health checks
out.Nodes = out.Nodes.Filter(d.config.OnlyPassing)
@ -734,6 +724,16 @@ RPC:
// Perform a random shuffle
out.Nodes.Shuffle()
// Determine the TTL
var ttl time.Duration
if d.config.ServiceTTL != nil {
var ok bool
ttl, ok = d.config.ServiceTTL[service]
if !ok {
ttl = d.config.ServiceTTL["*"]
}
}
// Add various responses depending on the request
qType := req.Question[0].Qtype
if qType == dns.TypeSRV {