Bug 1851038 - Make TRRServer extend NodeHTTP2Server r=necko-reviewers,kershaw

It became apparent that TRRServer was forwarding adb ports but not releasing
them at the end of the test, possibly leading to port exhaustion when running
Android tests.
Since NodeHTTP2Server already implements this correctly, it makes sense to
simply make TRRServer extend NodeHTTP2Server and just implement the bits that
are different.

Differential Revision: https://phabricator.services.mozilla.com/D187260
This commit is contained in:
Valentin Gosu 2023-09-01 11:03:31 +00:00
Родитель fa0318972d
Коммит 12c531e8fb
34 изменённых файлов: 129 добавлений и 219 удалений

Просмотреть файл

@ -7,7 +7,13 @@
/* import-globals-from head_cache.js */
/* import-globals-from head_cookies.js */
/* import-globals-from head_channels.js */
/* import-globals-from head_trr.js */
const { NodeServer } = ChromeUtils.importESModule(
"resource://testing-common/httpd.sys.mjs"
);
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
/* globals require, __dirname, global, Buffer, process */

Просмотреть файл

@ -7,16 +7,10 @@
/* import-globals-from head_cache.js */
/* import-globals-from head_cookies.js */
/* import-globals-from head_channels.js */
/* import-globals-from head_servers.js */
/* globals require, __dirname, global, Buffer, process */
const { NodeServer } = ChromeUtils.importESModule(
"resource://testing-common/httpd.sys.mjs"
);
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
/// Sets the TRR related prefs and adds the certificate we use for the HTTP2
/// server.
function trr_test_setup() {
@ -247,90 +241,6 @@ class TRRDNSListener {
}
}
/// Implements a basic HTTP2 server
class TRRServerCode {
static async startServer(port) {
const fs = require("fs");
const options = {
key: fs.readFileSync(__dirname + "/http2-cert.key"),
cert: fs.readFileSync(__dirname + "/http2-cert.pem"),
};
const url = require("url");
global.path_handlers = {};
global.handler = (req, resp) => {
const path = req.headers[global.http2.constants.HTTP2_HEADER_PATH];
let u = url.parse(req.url, true);
let handler = global.path_handlers[u.pathname];
if (handler) {
handler(req, resp, u);
return;
}
// Didn't find a handler for this path.
let response = `<h1> 404 Path not found: ${path}</h1>`;
resp.setHeader("Content-Type", "text/html");
resp.setHeader("Content-Length", response.length);
resp.writeHead(404);
resp.end(response);
};
// key: string "name/type"
// value: array [answer1, answer2]
global.dns_query_answers = {};
// key: domain
// value: a map containing {key: type, value: number of requests}
global.dns_query_counts = {};
global.http2 = require("http2");
global.server = global.http2.createSecureServer(options, global.handler);
await global.server.listen(port);
global.dnsPacket = require(`${__dirname}/../dns-packet`);
global.ip = require(`${__dirname}/../node_ip`);
let serverPort = global.server.address().port;
if (process.env.MOZ_ANDROID_DATA_DIR) {
// When creating a server on Android we must make sure that the port
// is forwarded from the host machine to the emulator.
let adb_path = "adb";
if (process.env.MOZ_FETCHES_DIR) {
adb_path = `${process.env.MOZ_FETCHES_DIR}/android-sdk-linux/platform-tools/adb`;
}
await new Promise(resolve => {
const { exec } = require("child_process");
exec(
`${adb_path} reverse tcp:${serverPort} tcp:${serverPort}`,
(error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
}
// console.log(`stdout: ${stdout}`);
resolve();
}
);
});
}
return serverPort;
}
static getRequestCount(domain, type) {
if (!global.dns_query_counts[domain]) {
return 0;
}
return global.dns_query_counts[domain][type] || 0;
}
}
/// This is the default handler for /dns-query
/// It implements basic functionality for parsing the DoH packet, then
/// queries global.dns_query_answers for available answers for the DNS query.
@ -426,39 +336,35 @@ function trrQueryHandler(req, resp, url) {
}
}
function getRequestCount(domain, type) {
if (!global.dns_query_counts[domain]) {
return 0;
}
return global.dns_query_counts[domain][type] || 0;
}
// A convenient wrapper around NodeServer
class TRRServer {
class TRRServer extends NodeHTTP2Server {
/// Starts the server
/// @port - default 0
/// when provided, will attempt to listen on that port.
async start(port = 0) {
this.processId = await NodeServer.fork();
await super.start(port);
await this.execute(`( () => {
// key: string "name/type"
// value: array [answer1, answer2]
global.dns_query_answers = {};
await this.execute(TRRServerCode);
this.port = await this.execute(`TRRServerCode.startServer(${port})`);
// key: domain
// value: a map containing {key: type, value: number of requests}
global.dns_query_counts = {};
global.dnsPacket = require(\`\${__dirname}/../dns-packet\`);
global.ip = require(\`\${__dirname}/../node_ip\`);
global.http2 = require("http2");
})()`);
await this.registerPathHandler("/dns-query", trrQueryHandler);
}
/// Executes a command in the context of the node server
async execute(command) {
return NodeServer.execute(this.processId, command);
}
/// Stops the server
async stop() {
if (this.processId) {
await NodeServer.kill(this.processId);
this.processId = undefined;
}
}
/// @path : string - the path on the server that we're handling. ex: /path
/// @handler : function(req, resp, url) - function that processes request and
/// emits a response.
async registerPathHandler(path, handler) {
return this.execute(
`global.path_handlers["${path}"] = ${handler.toString()}`
);
await this.execute(getRequestCount);
}
/// @name : string - name we're providing answers for. eg: foo.example.com
@ -484,9 +390,7 @@ class TRRServer {
}
async requestCount(domain, type) {
return this.execute(
`TRRServerCode.getRequestCount("${domain}", "${type}")`
);
return this.execute(`getRequestCount("${domain}", "${type}")`);
}
}

Просмотреть файл

@ -83,7 +83,7 @@ add_task(async function test_setup() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await registerDoHAnswers(true, true);

Просмотреть файл

@ -88,7 +88,7 @@ async function registerDoHAnswers(host, ipv4Answers, ipv6Answers, httpsRecord) {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers(host, "HTTPS", {

Просмотреть файл

@ -192,7 +192,7 @@ add_task(async function testFastfallback() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
@ -281,7 +281,7 @@ add_task(async function testFastfallback1() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
@ -371,7 +371,7 @@ add_task(async function testFastfallbackWithEchConfig() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
@ -476,7 +476,7 @@ add_task(async function testFastfallbackWithpartialEchConfig() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
@ -558,7 +558,7 @@ add_task(async function testFastfallbackWithoutEchConfig() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
@ -629,7 +629,7 @@ add_task(async function testH3FallbackWithMultipleTransactions() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
@ -700,7 +700,7 @@ add_task(async function testTwoFastFallbackTimers() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
@ -795,7 +795,7 @@ add_task(async function testH3FastFallbackWithMultipleTransactions() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
@ -857,7 +857,7 @@ add_task(async function testFastfallbackToTheSameRecord() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);

Просмотреть файл

@ -78,7 +78,7 @@ add_task(async function testHttp3ServerAsReverseProxy() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.h3_example.com", "HTTPS", {

Просмотреть файл

@ -60,7 +60,7 @@ add_task(async function testEchConfigEnabled() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.dns.echconfig.enabled", false);
@ -160,7 +160,7 @@ add_task(async function testTwoRecordsHaveEchConfig() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.foo.com", "HTTPS", {
@ -259,7 +259,7 @@ add_task(async function testTwoRecordsHaveEchConfig1() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.foo.com", "HTTPS", {
@ -365,7 +365,7 @@ add_task(async function testOneRecordsHasEchConfig() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.foo.com", "HTTPS", {
@ -460,7 +460,7 @@ add_task(async function testHttp3AndHttp2Pref() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.foo.com", "HTTPS", {

Просмотреть файл

@ -58,7 +58,7 @@ add_task(async function testSortedAlpnH3() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.support_version1", true);
await trrServer.registerDoHAnswers("test.alpn.com", "HTTPS", {
@ -178,7 +178,7 @@ add_task(async function testSortedAlpnH2() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.alpn_2.com", "HTTPS", {
answers: [

Просмотреть файл

@ -155,7 +155,7 @@ async function testWrapper(alpnAdvertisement) {
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
// Only the last record is valid to use.

Просмотреть файл

@ -49,7 +49,7 @@ add_task(async function testStoreIPHint() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.IPHint.com", "HTTPS", {
@ -262,7 +262,7 @@ add_task(async function testIPHintWithFreshDNS() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
// To make sure NS_HTTP_REFRESH_DNS not be cleared.
Services.prefs.setBoolPref("network.dns.disablePrefetch", true);

Просмотреть файл

@ -21,7 +21,7 @@ add_task(async function testPriorityAndECHConfig() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.priority.com", "HTTPS", {

Просмотреть файл

@ -181,7 +181,7 @@ add_task(async function testConnectWithECH() {
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
// Only the last record is valid to use.
@ -260,7 +260,7 @@ add_task(async function testEchRetry() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
// Only the last record is valid to use.
@ -345,7 +345,7 @@ async function H3ECHTest(
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.dns.port_prefixed_qname_https_rr", true);

Просмотреть файл

@ -76,7 +76,7 @@ add_task(async function testRetryWithoutECH() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref(
"network.dns.echconfig.fallback_to_origin_when_all_failed",

Просмотреть файл

@ -71,7 +71,7 @@ add_task(async function setupTRRServer() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
// Only the last record is valid to use.

Просмотреть файл

@ -32,10 +32,10 @@ registerCleanupFunction(async () => {
});
add_task(async function setup_server() {
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
let chan = makeChan(`https://localhost:${trrServer.port}/test?bla=some`);
dump(`port = ${trrServer.port()}\n`);
let chan = makeChan(`https://localhost:${trrServer.port()}/test?bla=some`);
let [, resp] = await channelOpenPromise(chan);
equal(resp, "<h1> 404 Path not found: /test?bla=some</h1>");
equal(resp, "<h1> 404 Path not found: /test</h1>");
});
add_task(async function test_parse_additional_section() {
@ -43,7 +43,7 @@ add_task(async function test_parse_additional_section() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("something.foo", "A", {
@ -306,7 +306,7 @@ add_task(async function test_additional_cached_record_override() {
Services.prefs.setIntPref("network.trr.mode", 2);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await new TRRDNSListener("else.foo", { expectedAnswer: "127.0.0.1" });

Просмотреть файл

@ -20,11 +20,11 @@ add_task(async function start_trr_server() {
await trrServer.stop();
});
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
dump(`port = ${trrServer.port()}\n`);
Services.prefs.setBoolPref("network.trr.skip-AAAA-when-not-supported", false);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRFIRST);
});

Просмотреть файл

@ -20,12 +20,12 @@ add_task(async function checkBlocklisting() {
await trrServer.stop();
});
await trrServer.start();
info(`port = ${trrServer.port}\n`);
info(`port = ${trrServer.port()}\n`);
Services.dns.clearCache(true);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRFIRST);

Просмотреть файл

@ -16,11 +16,11 @@ add_task(async function start_trr_server() {
await trrServer.stop();
});
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
dump(`port = ${trrServer.port()}\n`);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRFIRST);
});

Просмотреть файл

@ -32,16 +32,16 @@ add_task(async function test_trr_casing() {
await trrServer.stop();
});
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
let chan = makeChan(`https://localhost:${trrServer.port}/test?bla=some`);
dump(`port = ${trrServer.port()}\n`);
let chan = makeChan(`https://localhost:${trrServer.port()}/test?bla=some`);
let [, resp] = await channelOpenPromise(chan);
equal(resp, "<h1> 404 Path not found: /test?bla=some</h1>");
equal(resp, "<h1> 404 Path not found: /test</h1>");
Services.dns.clearCache(true);
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
// This CNAME response goes to B.example.com (uppercased)

Просмотреть файл

@ -34,16 +34,16 @@ add_setup(async function setup() {
await trrServer.stop();
});
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
let chan = makeChan(`https://localhost:${trrServer.port}/test?bla=some`);
dump(`port = ${trrServer.port()}\n`);
let chan = makeChan(`https://localhost:${trrServer.port()}/test?bla=some`);
let [, resp] = await channelOpenPromise(chan);
equal(resp, "<h1> 404 Path not found: /test?bla=some</h1>");
equal(resp, "<h1> 404 Path not found: /test</h1>");
Services.dns.clearCache(true);
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
});

Просмотреть файл

@ -47,7 +47,7 @@ add_task(async function start_trr_server() {
await trrServer.stop();
});
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
dump(`port = ${trrServer.port()}\n`);
await trrServer.registerDoHAnswers(`faily.com`, "NS", {
answers: [
@ -151,7 +151,7 @@ add_task(async function confirm_ok() {
});
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRFIRST);
equal(
@ -360,7 +360,7 @@ add_task(async function test_uri_pref_change() {
equal(Services.dns.currentTrrConfirmationState, CONFIRM_OK);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query?changed`
`https://foo.example.com:${trrServer.port()}/dns-query?changed`
);
equal(Services.dns.currentTrrConfirmationState, CONFIRM_TRYING_OK);
await waitForConfirmationState(CONFIRM_OK, 1000);
@ -377,7 +377,7 @@ add_task(async function test_autodetected_uri() {
);
defaultPrefBranch.setCharPref(
"network.trr.default_provider_uri",
`https://foo.example.com:${trrServer.port}/dns-query?changed`
`https://foo.example.com:${trrServer.port()}/dns-query?changed`
);
// For setDetectedTrrURI to work we must pretend we are using the default.
Services.prefs.clearUserPref("network.trr.uri");
@ -387,7 +387,7 @@ add_task(async function test_autodetected_uri() {
"NS"
);
Services.dns.setDetectedTrrURI(
`https://foo.example.com:${trrServer.port}/dns-query?changed2`
`https://foo.example.com:${trrServer.port()}/dns-query?changed2`
);
equal(Services.dns.currentTrrConfirmationState, CONFIRM_TRYING_OK);
await waitForConfirmationState(CONFIRM_OK, 1000);

Просмотреть файл

@ -16,11 +16,11 @@ add_setup(async function start_trr_server() {
await trrServer.stop();
});
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
dump(`port = ${trrServer.port()}\n`);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRONLY);
});

Просмотреть файл

@ -33,11 +33,11 @@ add_task(async function intermittent_dns_mode3() {
await trrServer.stop();
});
await trrServer.start();
info(`port = ${trrServer.port}\n`);
info(`port = ${trrServer.port()}\n`);
Services.dns.clearCache(true);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRONLY);
await trrServer.registerDoHAnswers("example.com", "A", {
@ -78,7 +78,7 @@ add_task(async function intermittent_dns_mode2() {
await trrServer.stop();
});
await trrServer.start();
info(`port = ${trrServer.port}\n`);
info(`port = ${trrServer.port()}\n`);
Services.dns.clearCache(true);
Services.prefs.setIntPref(
@ -87,7 +87,7 @@ add_task(async function intermittent_dns_mode2() {
);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRFIRST);
await trrServer.registerDoHAnswers("example.com", "A", {

Просмотреть файл

@ -33,16 +33,16 @@ add_task(async function setup() {
await trrServer.stop();
});
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
let chan = makeChan(`https://localhost:${trrServer.port}/test?bla=some`);
dump(`port = ${trrServer.port()}\n`);
let chan = makeChan(`https://localhost:${trrServer.port()}/test?bla=some`);
let [, resp] = await channelOpenPromise(chan);
equal(resp, "<h1> 404 Path not found: /test?bla=some</h1>");
equal(resp, "<h1> 404 Path not found: /test</h1>");
Services.dns.clearCache(true);
Services.prefs.setIntPref("network.trr.mode", 2);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
});

Просмотреть файл

@ -99,7 +99,7 @@ add_task(async function testFallbackToTheLastRecord() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
// Only the last record is valid to use.
@ -187,7 +187,7 @@ add_task(async function testFallbackToTheOrigin() {
);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
// All records are not able to use to connect, so we fallback to the origin
@ -271,7 +271,7 @@ add_task(async function testAllRecordsFailed() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref(
"network.dns.echconfig.fallback_to_origin_when_all_failed",
@ -344,7 +344,7 @@ add_task(async function testFallbackToTheOrigin2() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.example.com", "HTTPS", {
@ -409,7 +409,7 @@ add_task(async function testFallbackToTheOrigin3() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("vulnerable.com", "A", {
@ -484,7 +484,7 @@ add_task(async function testResetExclusionList() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref(
"network.dns.httpssvc.reset_exclustion_list",
@ -570,7 +570,7 @@ add_task(async function testH3Connection() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
@ -630,7 +630,7 @@ add_task(async function testFastfallbackToH2() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
// Use a short timeout to make sure the fast fallback timer will be triggered.
@ -723,7 +723,7 @@ add_task(async function testFailedH3Connection() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
Services.prefs.setIntPref(
@ -770,7 +770,7 @@ add_task(async function testHttp3ExcludedList() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
Services.prefs.setIntPref(
@ -843,7 +843,7 @@ add_task(async function testAllRecordsInHttp3ExcludedList() {
Services.prefs.setBoolPref("network.dns.http3_echconfig.enabled", true);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
Services.prefs.setIntPref(
@ -979,7 +979,7 @@ add_task(async function testUpgradeNotUsingHTTPSRR() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.ws.com", "HTTPS", {
@ -1050,7 +1050,7 @@ add_task(async function testFallbackToH2WithEchConfig() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
Services.prefs.setIntPref(

Просмотреть файл

@ -141,16 +141,16 @@ add_task(async function testHTTPSSVC() {
add_task(async function test_aliasform() {
trrServer = new TRRServer();
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
dump(`port = ${trrServer.port()}\n`);
if (inChildProcess()) {
do_send_remote_message("mode3-port", trrServer.port);
do_send_remote_message("mode3-port", trrServer.port());
await do_await_remote_message("mode3-port-done");
} else {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
}

Просмотреть файл

@ -57,10 +57,10 @@ add_task(async function test_add_nat64_prefix_to_trr() {
await trrServer.stop();
});
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
let chan = makeChan(`https://localhost:${trrServer.port}/test?bla=some`);
dump(`port = ${trrServer.port()}\n`);
let chan = makeChan(`https://localhost:${trrServer.port()}/test?bla=some`);
let [, resp] = await channelOpenPromise(chan);
equal(resp, "<h1> 404 Path not found: /test?bla=some</h1>");
equal(resp, "<h1> 404 Path not found: /test</h1>");
Services.dns.clearCache(true);
override.addIPOverride("ipv4only.arpa", "fe80::9b2b:c000:00aa");
Services.prefs.setCharPref(
@ -79,7 +79,7 @@ add_task(async function test_add_nat64_prefix_to_trr() {
Services.prefs.setIntPref("network.trr.mode", 2);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("xyz.foo", "A", {

Просмотреть файл

@ -25,7 +25,7 @@ add_setup(async function setup() {
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRONLY);

Просмотреть файл

@ -72,7 +72,7 @@ add_task(async function test_trr_proxy_auth() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.proxy.com", "A", {
@ -106,7 +106,7 @@ add_task(async function test_trr_proxy_auth() {
channel.notificationCallbacks = new Requestor();
if (
channel.URI.spec.startsWith(
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
)
) {
authTriggered = true;

Просмотреть файл

@ -18,12 +18,12 @@ add_task(async function checkBlocklisting() {
await trrServer.stop();
});
await trrServer.start();
info(`port = ${trrServer.port}\n`);
info(`port = ${trrServer.port()}\n`);
Services.dns.clearCache(true);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRFIRST);

Просмотреть файл

@ -16,11 +16,11 @@ add_task(async function setup() {
await trrServer.stop();
});
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
dump(`port = ${trrServer.port()}\n`);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRFIRST);
});

Просмотреть файл

@ -182,7 +182,7 @@ add_task(async function testFallback() {
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await trrServer.registerDoHAnswers("test.fallback.com", "A", {

Просмотреть файл

@ -1,6 +1,6 @@
[DEFAULT]
head = head_channels.js head_cache.js head_cache2.js head_cookies.js head_trr.js head_http3.js head_servers.js head_telemetry.js head_websocket.js head_webtransport.js
head = head_channels.js head_cache.js head_cache2.js head_cookies.js head_servers.js head_trr.js head_http3.js head_telemetry.js head_websocket.js head_webtransport.js
support-files =
http2-ca.pem
proxy-ca.pem
@ -190,7 +190,7 @@ skip-if = bits != 32
[test_udpsocket_offline.js]
[test_doomentry.js]
[test_dooh.js]
head = head_channels.js head_cache.js head_cookies.js head_trr.js head_http3.js trr_common.js
head = head_channels.js head_cache.js head_cookies.js head_servers.js head_trr.js head_http3.js trr_common.js
run-sequentially = node server exceptions dont replay well
skip-if = socketprocess_networking
[test_cacheflags.js]
@ -339,7 +339,7 @@ fail-if = os == "android"
# http2 unit tests require us to have node available to run the spdy and http2 server
[test_http2.js]
run-sequentially = node server exceptions dont replay well
head = head_channels.js head_cache.js head_cookies.js head_trr.js head_http3.js http2_test_common.js
head = head_channels.js head_cache.js head_cookies.js head_servers.js head_trr.js head_http3.js http2_test_common.js
[test_altsvc.js]
run-sequentially = node server exceptions dont replay well
[test_speculative_connect.js]
@ -441,7 +441,7 @@ skip-if = (os == "android" && processor == "x86_64")
[test_header_Server_Timing.js]
run-sequentially = node server exceptions dont replay well
[test_trr.js]
head = head_channels.js head_cache.js head_cookies.js head_trr.js head_http3.js trr_common.js
head = head_channels.js head_cache.js head_cookies.js head_servers.js head_trr.js head_http3.js trr_common.js
run-sequentially = very high failure rate in parallel
skip-if =
os == "win" && os_version == "6.1" # Skip on Azure - frequent failure
@ -679,7 +679,7 @@ skip-if =
skip-if =
os == 'win' && msix # https://bugzilla.mozilla.org/show_bug.cgi?id=1807931
[test_trr_with_proxy.js]
head = head_channels.js head_cache.js head_cookies.js head_trr.js trr_common.js
head = head_channels.js head_cache.js head_cookies.js head_servers.js head_trr.js trr_common.js
skip-if =
os == "android"
socketprocess_networking # Bug 1808233
@ -741,7 +741,7 @@ run-sequentially = node server exceptions dont replay well
[test_orb_empty_header.js]
[test_http2_with_proxy.js]
run-sequentially = node server exceptions dont replay well
head = head_channels.js head_cache.js head_cookies.js head_trr.js head_http3.js http2_test_common.js head_servers.js
head = head_channels.js head_cache.js head_cookies.js head_servers.js head_trr.js head_http3.js http2_test_common.js
[test_coaleasing_h2_and_h3_connection.js]
skip-if =
os == 'android'
@ -763,7 +763,7 @@ skip-if =
os == 'win' && msix # https://bugzilla.mozilla.org/show_bug.cgi?id=1808049
run-sequentially = node server exceptions dont replay well
[test_trr_telemetry.js]
head = head_channels.js head_cache.js head_cookies.js head_trr.js head_http3.js trr_common.js
head = head_channels.js head_cache.js head_cookies.js head_servers.js head_trr.js head_http3.js trr_common.js
skip-if =
os == 'android'
socketprocess_networking

Просмотреть файл

@ -1,5 +1,5 @@
[DEFAULT]
head = head_channels_clone.js head_trr_clone.js head_http3_clone.js ../unit/head_servers.js
head = head_channels_clone.js ../unit/head_servers.js head_trr_clone.js head_http3_clone.js
skip-if = socketprocess_networking
# Several tests rely on redirecting to data: URIs, which was allowed for a long
# time but now forbidden. So we enable it just for these tests.