Browse Source

Add IPv6 Reverse DNS Lookup test.

To be honest I'm not fond of Golden Bytes tests like this, but
not so much as to want to rewrite the whole test. The DNS byte
format is essentially immutable at this point, the encoded bytes
aren't going to change. The rest of the test assumptions about
hostnames might, but we can fix that when it comes.

Signed-off-by: Denton Gentry <[email protected]>
Denton Gentry 5 years ago
parent
commit
df64b7abf8
1 changed files with 38 additions and 0 deletions
  1. 38 0
      wgengine/tsdns/tsdns_test.go

+ 38 - 0
wgengine/tsdns/tsdns_test.go

@@ -593,6 +593,42 @@ var ptrResponse = []byte{
 	0x05, 0x74, 0x65, 0x73, 0x74, 0x31, 0x03, 0x69, 0x70, 0x6e, 0x03, 0x64, 0x65, 0x76, 0x00,
 }
 
+var ptrResponse6 = []byte{
+	0x00, 0x00, // transaction id: 0
+	0x84, 0x00, // flags: response, authoritative, no error
+	0x00, 0x01, // one question
+	0x00, 0x01, // one answer
+	0x00, 0x00, 0x00, 0x00, // no authority or additional RRs
+	// Question: f.0.e.0.d.0.c.0.b.0.a.0.9.0.8.0.7.0.6.0.5.0.4.0.3.0.2.0.1.0.0.0.ip6.arpa
+	0x01, 0x66, 0x01, 0x30, 0x01, 0x65, 0x01, 0x30,
+	0x01, 0x64, 0x01, 0x30, 0x01, 0x63, 0x01, 0x30,
+	0x01, 0x62, 0x01, 0x30, 0x01, 0x61, 0x01, 0x30,
+	0x01, 0x39, 0x01, 0x30, 0x01, 0x38, 0x01, 0x30,
+	0x01, 0x37, 0x01, 0x30, 0x01, 0x36, 0x01, 0x30,
+	0x01, 0x35, 0x01, 0x30, 0x01, 0x34, 0x01, 0x30,
+	0x01, 0x33, 0x01, 0x30, 0x01, 0x32, 0x01, 0x30,
+	0x01, 0x31, 0x01, 0x30, 0x01, 0x30, 0x01, 0x30,
+	0x03, 0x69, 0x70, 0x36,
+	0x04, 0x61, 0x72, 0x70, 0x61, 0x00,
+	0x00, 0x0c, 0x00, 0x01, // type PTR, class IN6
+	// Answer: f.0.e.0.d.0.c.0.b.0.a.0.9.0.8.0.7.0.6.0.5.0.4.0.3.0.2.0.1.0.0.0.ip6.arpa
+	0x01, 0x66, 0x01, 0x30, 0x01, 0x65, 0x01, 0x30,
+	0x01, 0x64, 0x01, 0x30, 0x01, 0x63, 0x01, 0x30,
+	0x01, 0x62, 0x01, 0x30, 0x01, 0x61, 0x01, 0x30,
+	0x01, 0x39, 0x01, 0x30, 0x01, 0x38, 0x01, 0x30,
+	0x01, 0x37, 0x01, 0x30, 0x01, 0x36, 0x01, 0x30,
+	0x01, 0x35, 0x01, 0x30, 0x01, 0x34, 0x01, 0x30,
+	0x01, 0x33, 0x01, 0x30, 0x01, 0x32, 0x01, 0x30,
+	0x01, 0x31, 0x01, 0x30, 0x01, 0x30, 0x01, 0x30,
+	0x03, 0x69, 0x70, 0x36,
+	0x04, 0x61, 0x72, 0x70, 0x61, 0x00,
+	0x00, 0x0c, 0x00, 0x01, // type PTR, class IN
+	0x00, 0x00, 0x02, 0x58, // TTL: 600
+	0x00, 0x0f, // length: 15 bytes
+	// PTR: test2.ipn.dev
+	0x05, 0x74, 0x65, 0x73, 0x74, 0x32, 0x03, 0x69, 0x70, 0x6e, 0x03, 0x64, 0x65, 0x76, 0x00,
+}
+
 var nxdomainResponse = []byte{
 	0x00, 0x00, // transaction id: 0
 	0x84, 0x03, // flags: response, authoritative, error: nxdomain
@@ -636,6 +672,8 @@ func TestFull(t *testing.T) {
 		{"no-ipv6", dnspacket("test1.ipn.dev.", dns.TypeAAAA), emptyResponse},
 		{"upper", dnspacket("TEST1.IPN.DEV.", dns.TypeA), ipv4UppercaseResponse},
 		{"ptr", dnspacket("4.3.2.1.in-addr.arpa.", dns.TypePTR), ptrResponse},
+		{"ptr", dnspacket("f.0.e.0.d.0.c.0.b.0.a.0.9.0.8.0.7.0.6.0.5.0.4.0.3.0.2.0.1.0.0.0.ip6.arpa.",
+			dns.TypePTR), ptrResponse6},
 		{"nxdomain", dnspacket("test3.ipn.dev.", dns.TypeA), nxdomainResponse},
 	}