mirror of https://github.com/hashicorp/consul
Removed a copy pasted irrelevant comment, and other code review feedback
parent
f9db387097
commit
794d1afe44
|
@ -502,7 +502,6 @@ func (r *Router) FindServerAddrs(datacenter string) ([]string, error) {
|
|||
}
|
||||
|
||||
var ret []string
|
||||
// Try each manager until we get a server.
|
||||
for _, manager := range managers {
|
||||
if manager.IsOffline() {
|
||||
continue
|
||||
|
|
22
agent/dns.go
22
agent/dns.go
|
@ -372,7 +372,7 @@ PARSE:
|
|||
INVALID:
|
||||
d.logger.Printf("[WARN] dns: QName invalid: %s", qName)
|
||||
d.addSOA(d.domain, resp)
|
||||
d.addNSAndARecordsForDomain(resp)
|
||||
d.addAuthority(resp)
|
||||
resp.SetRcode(req, dns.RcodeNameError)
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,7 @@ RPC:
|
|||
// If we have no address, return not found!
|
||||
if out.NodeServices == nil {
|
||||
d.addSOA(d.domain, resp)
|
||||
d.addNSAndARecordsForDomain(resp)
|
||||
d.addAuthority(resp)
|
||||
resp.SetRcode(req, dns.RcodeNameError)
|
||||
return
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ RPC:
|
|||
}
|
||||
|
||||
// Add NS record and A record
|
||||
d.addNSAndARecordsForDomain(resp)
|
||||
d.addAuthority(resp)
|
||||
}
|
||||
|
||||
// formatNodeRecord takes a Node and returns an A, AAAA, or CNAME record
|
||||
|
@ -646,7 +646,7 @@ RPC:
|
|||
// If we have no nodes, return not found!
|
||||
if len(out.Nodes) == 0 {
|
||||
d.addSOA(d.domain, resp)
|
||||
d.addNSAndARecordsForDomain(resp)
|
||||
d.addAuthority(resp)
|
||||
resp.SetRcode(req, dns.RcodeNameError)
|
||||
return
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ RPC:
|
|||
}
|
||||
|
||||
// Add NS and A records
|
||||
d.addNSAndARecordsForDomain(resp)
|
||||
d.addAuthority(resp)
|
||||
|
||||
// If the network is not TCP, restrict the number of responses
|
||||
if network != "tcp" {
|
||||
|
@ -682,8 +682,8 @@ RPC:
|
|||
}
|
||||
}
|
||||
|
||||
// addNSAndARecordsForDomain uses the agent's advertise address to
|
||||
func (d *DNSServer) addNSAndARecordsForDomain(msg *dns.Msg) {
|
||||
// addAuthority adds NS records and corresponding A records with the IP addresses of servers
|
||||
func (d *DNSServer) addAuthority(msg *dns.Msg) {
|
||||
serverAddrs := d.agent.delegate.ServerAddrs()
|
||||
for _, addr := range serverAddrs {
|
||||
ipAddrStr := strings.Split(addr, ":")[0]
|
||||
|
@ -701,7 +701,7 @@ func (d *DNSServer) addNSAndARecordsForDomain(msg *dns.Msg) {
|
|||
}
|
||||
msg.Ns = append(msg.Ns, ns)
|
||||
|
||||
//add an A record for the NS record
|
||||
// add an A record for the NS record
|
||||
a := &dns.A{
|
||||
Hdr: dns.RR_Header{
|
||||
Name: nsName,
|
||||
|
@ -753,7 +753,7 @@ RPC:
|
|||
// here since the RPC layer loses the type information.
|
||||
if err.Error() == consul.ErrQueryNotFound.Error() {
|
||||
d.addSOA(d.domain, resp)
|
||||
d.addNSAndARecordsForDomain(resp)
|
||||
d.addAuthority(resp)
|
||||
resp.SetRcode(req, dns.RcodeNameError)
|
||||
return
|
||||
}
|
||||
|
@ -796,7 +796,7 @@ RPC:
|
|||
// If we have no nodes, return not found!
|
||||
if len(out.Nodes) == 0 {
|
||||
d.addSOA(d.domain, resp)
|
||||
d.addNSAndARecordsForDomain(resp)
|
||||
d.addAuthority(resp)
|
||||
resp.SetRcode(req, dns.RcodeNameError)
|
||||
return
|
||||
}
|
||||
|
@ -821,7 +821,7 @@ RPC:
|
|||
|
||||
// If the answer is empty and the response isn't truncated, return not found
|
||||
if len(resp.Answer) == 0 && !resp.Truncated {
|
||||
d.addNSAndARecordsForDomain(resp)
|
||||
d.addAuthority(resp)
|
||||
d.addSOA(d.domain, resp)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue