Backed out changeset 4e775c2385b2 (bug 1641222) for causing failure at test_trr_httpssvc_wrap.js. CLOSED TREE

This commit is contained in:
Butkovits Atila 2020-06-16 14:49:01 +03:00
Родитель d42242b632
Коммит 16a71ee2b8
2 изменённых файлов: 2 добавлений и 241 удалений

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

@ -835,8 +835,7 @@ nsresult TRR::DohDecode(nsCString& aHost) {
}
uint16_t TYPE = get16bit(mResponse, index);
if ((TYPE != TRRTYPE_CNAME) && (TYPE != TRRTYPE_HTTPSSVC) &&
(TYPE != static_cast<uint16_t>(mType))) {
if ((TYPE != TRRTYPE_CNAME) && (TYPE != static_cast<uint16_t>(mType))) {
// Not the same type as was asked for nor CNAME
LOG(("TRR: Dohdecode:%d asked for type %d got %d\n", __LINE__, mType,
TYPE));
@ -1028,24 +1027,6 @@ nsresult TRR::DohDecode(nsCString& aHost) {
parsed.mSvcFieldValue.AppendElement(value);
}
// Check for AliasForm
if (mCname.IsEmpty() && parsed.mSvcFieldPriority == 0) {
// Alias form SvcDomainName must not have the "." value (empty)
if (parsed.mSvcDomainName.IsEmpty()) {
return NS_ERROR_UNEXPECTED;
}
mCname = parsed.mSvcDomainName;
ToLowerCase(mCname);
LOG(("TRR::DohDecode HTTPSSVC AliasForm host %s => %s\n",
host.get(), mCname.get()));
break;
}
if (mType != TRRTYPE_HTTPSSVC) {
// Ignore the entry that we just parsed if we didn't ask for it.
break;
}
if (!mResult.is<TypeRecordHTTPSSVC>()) {
mResult = mozilla::AsVariant(CopyableTArray<SVCB>());
}
@ -1302,7 +1283,7 @@ nsresult TRR::On200Response(nsIChannel* aChannel) {
if (NS_SUCCEEDED(rv)) {
if (!mDNS.mAddresses.getFirst() && !mCname.IsEmpty() &&
mType != TRRTYPE_TXT) {
mType != TRRTYPE_TXT && mType != TRRTYPE_HTTPSSVC) {
nsCString cname = mCname;
LOG(("TRR: check for CNAME record for %s within previous response\n",
cname.get()));

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

@ -205,223 +205,3 @@ add_task(async function testHTTPSSVC() {
Assert.equal(answer[2].name, "hello");
Assert.equal(answer[2].values.length, 0);
});
add_task(async function test_aliasform() {
let trrServer = new TRRServer();
registerCleanupFunction(async () => trrServer.stop());
await trrServer.start();
dump(`port = ${trrServer.port}\n`);
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
);
// Test that HTTPS priority = 0 (AliasForm) behaves like a CNAME
await trrServer.registerDoHAnswers("test.com", "A", [
{
name: "test.com",
ttl: 55,
type: "HTTPSSVC",
flush: false,
data: {
priority: 0,
name: "something.com",
values: [],
},
},
]);
await trrServer.registerDoHAnswers("something.com", "A", [
{
name: "something.com",
ttl: 55,
type: "A",
flush: false,
data: "1.2.3.4",
},
]);
await new TRRDNSListener("test.com", "1.2.3.4");
// Test a chain of HTTPSSVC AliasForm and CNAMEs
await trrServer.registerDoHAnswers("x.com", "A", [
{
name: "x.com",
ttl: 55,
type: "HTTPSSVC",
flush: false,
data: {
priority: 0,
name: "y.com",
values: [],
},
},
]);
await trrServer.registerDoHAnswers("y.com", "A", [
{
name: "y.com",
type: "CNAME",
ttl: 55,
class: "IN",
flush: false,
data: "z.com",
},
]);
await trrServer.registerDoHAnswers("z.com", "A", [
{
name: "z.com",
ttl: 55,
type: "HTTPSSVC",
flush: false,
data: {
priority: 0,
name: "target.com",
values: [],
},
},
]);
await trrServer.registerDoHAnswers("target.com", "A", [
{
name: "target.com",
ttl: 55,
type: "A",
flush: false,
data: "4.3.2.1",
},
]);
await new TRRDNSListener("x.com", "4.3.2.1");
// We get a ServiceForm instead of a A answer, CNAME or AliasForm
await trrServer.registerDoHAnswers("no-ip-host.com", "A", [
{
name: "no-ip-host.com",
ttl: 55,
type: "HTTPSSVC",
flush: false,
data: {
priority: 1,
name: "h3pool",
values: [
{ key: "alpn", value: "h2,h3" },
{ key: "no-default-alpn" },
{ key: "port", value: 8888 },
{ key: "ipv4hint", value: "1.2.3.4" },
{ key: "esniconfig", value: "123..." },
{ key: "ipv6hint", value: "::1" },
],
},
},
]);
let [, , inStatus] = await new TRRDNSListener(
"no-ip-host.com",
undefined,
false
);
Assert.ok(
!Components.isSuccessCode(inStatus),
`${inStatus} should be an error code`
);
// Test CNAME/AliasForm loop
await trrServer.registerDoHAnswers("loop.com", "A", [
{
name: "loop.com",
type: "CNAME",
ttl: 55,
class: "IN",
flush: false,
data: "loop2.com",
},
]);
await trrServer.registerDoHAnswers("loop2.com", "A", [
{
name: "loop2.com",
ttl: 55,
type: "HTTPSSVC",
flush: false,
data: {
priority: 0,
name: "loop.com",
values: [],
},
},
]);
[, , inStatus] = await new TRRDNSListener("loop.com", undefined, false);
Assert.ok(
!Components.isSuccessCode(inStatus),
`${inStatus} should be an error code`
);
// Alias form for .
await trrServer.registerDoHAnswers("empty.com", "A", [
{
name: "empty.com",
ttl: 55,
type: "HTTPSSVC",
flush: false,
data: {
priority: 0,
name: "", // This is not allowed
values: [],
},
},
]);
[, , inStatus] = await new TRRDNSListener("empty.com", undefined, false);
Assert.ok(
!Components.isSuccessCode(inStatus),
`${inStatus} should be an error code`
);
// We should ignore ServiceForm if an AliasForm record is also present
await trrServer.registerDoHAnswers("multi.com", "HTTPSSVC", [
{
name: "multi.com",
ttl: 55,
type: "HTTPSSVC",
flush: false,
data: {
priority: 1,
name: "h3pool",
values: [
{ key: "alpn", value: "h2,h3" },
{ key: "no-default-alpn" },
{ key: "port", value: 8888 },
{ key: "ipv4hint", value: "1.2.3.4" },
{ key: "esniconfig", value: "123..." },
{ key: "ipv6hint", value: "::1" },
],
},
},
{
name: "multi.com",
ttl: 55,
type: "HTTPSSVC",
flush: false,
data: {
priority: 0,
name: "example.com",
values: [],
},
},
]);
let listener = new DNSListener();
let request = dns.asyncResolveByType(
"multi.com",
dns.RESOLVE_TYPE_HTTPSSVC,
0,
listener,
mainThread,
defaultOriginAttributes
);
let [inRequest, inRecord, inStatus2] = await listener;
Assert.equal(inRequest, request, "correct request was used");
Assert.ok(
!Components.isSuccessCode(inStatus2),
`${inStatus2} should be an error code`
);
});