aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar Yong Tang <yong.tang.github@outlook.com> 2018-03-13 15:10:07 -0700
committerGravatar GitHub <noreply@github.com> 2018-03-13 15:10:07 -0700
commit55824516bd97d4e5348eeb8d8287b300d4caa6d1 (patch)
tree41ad17815d4809771f47f53a6704058dc52b597c /plugin
parente5beb9dbfc9611b12dee88e7914251f5b94908cf (diff)
downloadcoredns-55824516bd97d4e5348eeb8d8287b300d4caa6d1.tar.gz
coredns-55824516bd97d4e5348eeb8d8287b300d4caa6d1.tar.zst
coredns-55824516bd97d4e5348eeb8d8287b300d4caa6d1.zip
Add PTR record support for Route53 plugin (#1606)
This fix adds PTR record support for Route53 plugin This fix fixes 1595 Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'plugin')
-rw-r--r--plugin/route53/route53.go15
-rw-r--r--plugin/route53/route53_test.go11
2 files changed, 26 insertions, 0 deletions
diff --git a/plugin/route53/route53.go b/plugin/route53/route53.go
index 0554887a6..c40c56db3 100644
--- a/plugin/route53/route53.go
+++ b/plugin/route53/route53.go
@@ -50,6 +50,8 @@ func (rr Route53) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
answers = a(qname, output.ResourceRecordSets)
case dns.TypeAAAA:
answers = aaaa(qname, output.ResourceRecordSets)
+ case dns.TypePTR:
+ answers = ptr(qname, output.ResourceRecordSets)
}
if len(answers) == 0 {
@@ -93,5 +95,18 @@ func aaaa(zone string, rrss []*route53.ResourceRecordSet) []dns.RR {
return answers
}
+func ptr(zone string, rrss []*route53.ResourceRecordSet) []dns.RR {
+ answers := []dns.RR{}
+ for _, rrs := range rrss {
+ for _, rr := range rrs.ResourceRecords {
+ r := new(dns.PTR)
+ r.Hdr = dns.RR_Header{Name: zone, Rrtype: dns.TypePTR, Class: dns.ClassINET, Ttl: uint32(aws.Int64Value(rrs.TTL))}
+ r.Ptr = aws.StringValue(rr.Value)
+ answers = append(answers, r)
+ }
+ }
+ return answers
+}
+
// Name implements the Handler interface.
func (rr Route53) Name() string { return "route53" }
diff --git a/plugin/route53/route53_test.go b/plugin/route53/route53_test.go
index ed118a945..a543231c1 100644
--- a/plugin/route53/route53_test.go
+++ b/plugin/route53/route53_test.go
@@ -24,6 +24,8 @@ func (mockedRoute53) ListResourceRecordSets(input *route53.ListResourceRecordSet
value = "10.2.3.4"
case "AAAA":
value = "2001:db8:85a3::8a2e:370:7334"
+ case "PTR":
+ value = "ptr.example.org"
}
return &route53.ListResourceRecordSetsOutput{
ResourceRecordSets: []*route53.ResourceRecordSet{
@@ -66,6 +68,13 @@ func TestRoute53(t *testing.T) {
expectedReply: []string{"2001:db8:85a3::8a2e:370:7334"},
expectedErr: nil,
},
+ {
+ qname: "example.org",
+ qtype: dns.TypePTR,
+ expectedCode: dns.RcodeSuccess,
+ expectedReply: []string{"ptr.example.org"},
+ expectedErr: nil,
+ },
}
ctx := context.TODO()
@@ -91,6 +100,8 @@ func TestRoute53(t *testing.T) {
actual = rec.Msg.Answer[i].(*dns.A).A.String()
case dns.TypeAAAA:
actual = rec.Msg.Answer[i].(*dns.AAAA).AAAA.String()
+ case dns.TypePTR:
+ actual = rec.Msg.Answer[i].(*dns.PTR).Ptr
}
if actual != expected {
t.Errorf("Test %d: Expected answer %s, but got %s", i, expected, actual)