mirror of
https://github.com/coredns/coredns.git
synced 2025-11-02 02:03:13 -05:00
@@ -19,6 +19,7 @@ import (
|
||||
type Traffic struct {
|
||||
c *xds.Client
|
||||
id string
|
||||
health bool
|
||||
origins []string
|
||||
|
||||
Next plugin.Handler
|
||||
@@ -41,7 +42,7 @@ func (t *Traffic) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
|
||||
m.SetReply(r)
|
||||
m.Authoritative = true
|
||||
|
||||
sockaddr, ok := t.c.Select(cluster)
|
||||
sockaddr, ok := t.c.Select(cluster, t.health)
|
||||
if !ok {
|
||||
// ok the cluster (which has potentially extra labels), doesn't exist, but we may have a query for endpoint-0.<cluster>.
|
||||
// check if we have 2 labels and that the first equals endpoint-0.
|
||||
@@ -55,7 +56,7 @@ func (t *Traffic) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
|
||||
if strings.HasPrefix(labels[0], "endpoint-") {
|
||||
// recheck if the cluster exist.
|
||||
cluster = labels[1]
|
||||
sockaddr, ok = t.c.Select(cluster)
|
||||
sockaddr, ok = t.c.Select(cluster, t.health)
|
||||
if !ok {
|
||||
m.Ns = soa(state.Zone)
|
||||
m.Rcode = dns.RcodeNameError
|
||||
@@ -88,7 +89,7 @@ func (t *Traffic) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
|
||||
}
|
||||
m.Answer = []dns.RR{&dns.AAAA{Hdr: dns.RR_Header{Name: state.QName(), Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: 5}, AAAA: sockaddr.Address()}}
|
||||
case dns.TypeSRV:
|
||||
sockaddrs, _ := t.c.All(cluster)
|
||||
sockaddrs, _ := t.c.All(cluster, t.health)
|
||||
for i, sa := range sockaddrs {
|
||||
target := fmt.Sprintf("endpoint-%d.%s.%s", i, cluster, state.Zone)
|
||||
|
||||
@@ -133,7 +134,7 @@ func (t *Traffic) serveEndpoint(ctx context.Context, state request.Request, endp
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
sockaddrs, _ := t.c.All(cluster)
|
||||
sockaddrs, _ := t.c.All(cluster, t.health)
|
||||
if len(sockaddrs) < nr {
|
||||
m.Ns = soa(state.Zone)
|
||||
m.Rcode = dns.RcodeNameError
|
||||
|
||||
Reference in New Issue
Block a user