bug 1466860 - upgrade DOH code to draft-12 level r=mcmanus a=lizzard
authorDaniel Stenberg <daniel@haxx.se>
Wed, 08 Aug 2018 15:01:05 +0000
changeset 478426 e8db9f7d2225366699c4c2c73d1d4ab465700253
parent 478425 a5178a7b390f89c751889b3c571bf2c6c8828559
child 478427 7bcf460f41d7a40d20ef268b5e158c0dd23edf76
push id9664
push userarchaeopteryx@coole-files.de
push dateWed, 15 Aug 2018 08:30:27 +0000
treeherdermozilla-beta@e8db9f7d2225 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, lizzard
bugs1466860
milestone62.0
bug 1466860 - upgrade DOH code to draft-12 level r=mcmanus a=lizzard MozReview-Commit-ID: FSVh7qUbBig Differential Revision: https://phabricator.services.mozilla.com/D2828
netwerk/dns/TRR.cpp
testing/xpcshell/moz-http2/moz-http2.js
--- a/netwerk/dns/TRR.cpp
+++ b/netwerk/dns/TRR.cpp
@@ -174,17 +174,17 @@ TRR::SendHTTPRequest()
     /* For GET requests, the outgoing packet needs to be Base64url-encoded and
        then appended to the end of the URI. */
     rv = Base64URLEncode(tmp.Length(), reinterpret_cast<const unsigned char *>(tmp.get()),
                          Base64URLEncodePaddingPolicy::Omit, body);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsAutoCString uri;
     gTRRService->GetURI(uri);
-    uri.Append(NS_LITERAL_CSTRING("?ct&dns="));
+    uri.Append(NS_LITERAL_CSTRING("?dns="));
     uri.Append(body);
     rv = NS_NewURI(getter_AddRefs(dnsURI), uri);
   } else {
     rv = DohEncode(body);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsAutoCString uri;
     gTRRService->GetURI(uri);
@@ -211,17 +211,17 @@ TRR::SendHTTPRequest()
   }
 
   nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
   if (!httpChannel) {
     return NS_ERROR_UNEXPECTED;
   }
 
   rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
-                                     NS_LITERAL_CSTRING("application/dns-udpwireformat"),
+                                     NS_LITERAL_CSTRING("application/dns-message"),
                                      false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString cred;
   gTRRService->GetCredentials(cred);
   if (!cred.IsEmpty()){
     rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Authorization"), cred, false);
     NS_ENSURE_SUCCESS(rv, rv);
@@ -253,24 +253,24 @@ TRR::SendHTTPRequest()
       return NS_ERROR_UNEXPECTED;
     }
     uint32_t streamLength = body.Length();
     nsCOMPtr<nsIInputStream> uploadStream;
     rv = NS_NewCStringInputStream(getter_AddRefs(uploadStream), std::move(body));
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = uploadChannel->ExplicitSetUploadStream(uploadStream,
-                                                NS_LITERAL_CSTRING("application/dns-udpwireformat"),
+                                                NS_LITERAL_CSTRING("application/dns-message"),
                                                 streamLength,
                                                 NS_LITERAL_CSTRING("POST"), false);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // set the *default* response content type
-  if (NS_FAILED(httpChannel->SetContentType(NS_LITERAL_CSTRING("application/dns-udpwireformat")))) {
+  if (NS_FAILED(httpChannel->SetContentType(NS_LITERAL_CSTRING("application/dns-message")))) {
     LOG(("TRR::SendHTTPRequest: couldn't set content-type!\n"));
   }
   if (NS_SUCCEEDED(httpChannel->AsyncOpen2(this))) {
     NS_NewTimerWithCallback(getter_AddRefs(mTimeout),
                             this, gTRRService->GetRequestTimeout(),
                             nsITimer::TYPE_ONE_SHOT);
     return NS_OK;
   }
@@ -924,19 +924,18 @@ TRR::OnStopRequest(nsIRequest *aRequest,
     nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest);
     if (!httpChannel) {
       return NS_ERROR_UNEXPECTED;
     }
     nsresult rv = NS_OK;
     nsAutoCString contentType;
     httpChannel->GetContentType(contentType);
     if (contentType.Length() &&
-        !contentType.LowerCaseEqualsLiteral("application/dns-udpwireformat")) {
-      // try and parse missing content-types, but otherwise require udpwireformat
-      LOG(("TRR:OnStopRequest %p %s %d should fail due to content type %s\n",
+        !contentType.LowerCaseEqualsLiteral("application/dns-message")) {
+      LOG(("TRR:OnStopRequest %p %s %d wrong content type %s\n",
            this, mHost.get(), mType, contentType.get()));
       FailData(NS_ERROR_UNEXPECTED);
       return NS_OK;
     }
 
     uint32_t httpStatus;
     rv = httpChannel->GetResponseStatus(&httpStatus);
     if (NS_SUCCEEDED(rv) && httpStatus == 200) {
--- a/testing/xpcshell/moz-http2/moz-http2.js
+++ b/testing/xpcshell/moz-http2/moz-http2.js
@@ -537,17 +537,17 @@ function handleRequest(req, res) {
       // ... this sends a CNAME back to pointing-elsewhere.example.com
       content = new Buffer("00000100000100010000000005636E616D65076578616D706C6503636F6D0000050001C00C0005000100000037002012706F696E74696E672D656C73657768657265076578616D706C6503636F6D00", "hex");
       cname_confirm++;
     }
     else {
       // ... this sends an A 99.88.77.66 entry back for pointing-elsewhere.example.com
       content = new Buffer("00000100000100010000000012706F696E74696E672D656C73657768657265076578616D706C6503636F6D0000010001C00C0001000100000037000463584D42", "hex");
     }
-    res.setHeader('Content-Type', 'application/dns-udpwireformat');
+    res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");
     return;
 
   }
   else if (u.pathname === "/dns-cname-a") {
@@ -578,69 +578,69 @@ function handleRequest(req, res) {
                          "0468657265" + // here
                          "076578616D706C6503636F6D00" + // .example.com
                          "0001" + // type (A)
                          "0001" + // class
                          "00000037" + // TTL
                          "0004" + // RDLENGTH
                          "09080706", // IPv4 address
                          "hex");
-    res.setHeader('Content-Type', 'application/dns-udpwireformat');
+    res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");
     return;
 
   }
   else if (u.pathname === "/dns-cname-loop") {
     // asking for cname.example.com
     var content;
     // ... this always sends a CNAME back to pointing-elsewhere.example.com. Loop time!
     content = new Buffer("00000100000100010000000005636E616D65076578616D706C6503636F6D0000050001C00C0005000100000037002012706F696E74696E672D656C73657768657265076578616D706C65C01A00", "hex");
-    res.setHeader('Content-Type', 'application/dns-udpwireformat');
+    res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");
     return;
 
   }
 
   // for use with test_trr.js
-  else if (u.path === "/dns-get?ct&dns=AAABAAABAAAAAAAAA2dldAdleGFtcGxlA2NvbQAAAQAB") {
+  else if (u.path === "/dns-get?dns=AAABAAABAAAAAAAAA2dldAdleGFtcGxlA2NvbQAAAQAB") {
     // the query string asks for an A entry for get.example.com
     // get.example.com has A entry 1.2.3.4
     var content= new Buffer("00000100000100010000000003676574076578616D706C6503636F6D0000010001C00C0001000100000037000401020304", "hex");
-    res.setHeader('Content-Type', 'application/dns-udpwireformat');
+    res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");
     ns_confirm = 0; // back to first reply for dns-confirm
     cname_confirm = 0; // back to first reply for dns-cname
     return;
   }
   // for use with test_trr.js
   else if (u.pathname === "/dns") {
     // bar.example.com has A entry 127.0.0.1
     var content= new Buffer("00000100000100010000000003626172076578616D706C6503636F6D0000010001C00C000100010000003700047F000001", "hex");
-    res.setHeader('Content-Type', 'application/dns-udpwireformat');
+    res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     // pass back a cookie here, check it in /dns-auth
     res.setHeader('Set-Cookie', 'trackyou=yes; path=/; max-age=100000;');
     res.writeHead(200);
     res.write(content);
     res.end("");
     return;
   }
   else if (u.pathname === "/dns-ns") {
     // confirm.example.com has NS entry ns.example.com
     var content= new Buffer("00000100000100010000000007636F6E6669726D076578616D706C6503636F6D0000020001C00C00020001000000370012026E73076578616D706C6503636F6D010A00", "hex");
-    res.setHeader('Content-Type', 'application/dns-udpwireformat');
+    res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");
     return;
   }
   else if (u.pathname === '/dns-750ms') {
     // it's just meant to be this slow - the test doesn't care about the actual response
@@ -659,67 +659,67 @@ function handleRequest(req, res) {
       // for both and expect the client to reject the wrong one
       var content= new Buffer("000001000001000100000000" + "073130622d313030" +
                               "076578616D706C6503636F6D00001C0001C00C001C00010000003700100001000000000000000000000000FFFF", "hex");
       ns_confirm++;
     } else {
       // everything else is just wrong
       return;
     }
-    res.setHeader('Content-Type', 'application/dns-udpwireformat');
+    res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");
     return;
   }
   // for use with test_trr.js
   else if (u.pathname === "/dns-aaaa") {
     // aaaa.example.com has AAAA entry 2020:2020::2020
     var content= new Buffer("0000010000010001000000000461616161076578616D706C6503636F6D00001C0001C00C001C000100000037001020202020000000000000000000002020", "hex");
-    res.setHeader('Content-Type', 'application/dns-udpwireformat');
+    res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");
     return;
   }
   else if (u.pathname === "/dns-rfc1918") {
     // rfc1918.example.com has A entry 192.168.0.1
     var content= new Buffer("0000010000010001000000000772666331393138076578616D706C6503636F6D0000010001C00C00010001000000370004C0A80001", "hex");
-    res.setHeader('Content-Type', 'application/dns-udpwireformat');
+    res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");
     return;
   }
   // for use with test_trr.js
   else if (u.pathname === "/dns-push") {
     // first.example.com has A entry 127.0.0.1
     var content= new Buffer("000001000001000100000000056669727374076578616D706C6503636F6D0000010001C00C000100010000003700047F000001", "hex");
     // push.example.com has AAAA entry 2018::2018
     var pcontent= new Buffer("0000010000010001000000000470757368076578616D706C6503636F6D00001C0001C00C001C000100000037001020180000000000000000000000002018", "hex");
     push = res.push({
       hostname: 'foo.example.com:' + serverPort,
       port: serverPort,
-      path: '/dns-pushed-response?ct&dns=AAAAAAABAAAAAAAABHB1c2gHZXhhbXBsZQNjb20AABwAAQ',
+      path: '/dns-pushed-response?dns=AAAAAAABAAAAAAAABHB1c2gHZXhhbXBsZQNjb20AABwAAQ',
       method: 'GET',
       headers: {
-        'accept' : 'application/dns-udpwireformat'
+        'accept' : 'application/dns-message'
       }
     });
     push.writeHead(200, {
-      'content-type': 'application/dns-udpwireformat',
+      'content-type': 'application/dns-message',
       'pushed' : 'yes',
       'content-length' : pcontent.length,
       'X-Connection-Http2': 'yes'
     });
     push.end(pcontent);
-    res.setHeader('Content-Type', 'application/dns-udpwireformat');
+    res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");
     return;
   }
   // for use with test_trr.js
   else if (u.pathname === "/dns-auth") {
@@ -734,17 +734,17 @@ function handleRequest(req, res) {
     }
     if (req.headers['authorization'] != "user:password") {
       res.writeHead(401);
       res.end("bad boy!");
       return;
     }
     // bar.example.com has A entry 127.0.0.1
     var content= new Buffer("00000100000100010000000003626172076578616D706C6503636F6D0000010001C00C000100010000003700047F000001", "hex");
-    res.setHeader('Content-Type', 'application/dns-udpwireformat');
+    res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");
     return;
   }
 
   else if (u.pathname === "/.well-known/http-opportunistic") {