Bug 1539819 - P4: Some adjustments to pass trr test r=dragana,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D68881
This commit is contained in:
Kershaw Chang 2020-05-18 20:18:13 +00:00
Родитель 5732714230
Коммит f576a6f9bf
11 изменённых файлов: 53 добавлений и 11 удалений

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

@ -359,11 +359,15 @@ ChildDNSService::GetDNSCacheEntries(
}
NS_IMETHODIMP
ChildDNSService::ClearCache(bool aTrrToo) { return NS_ERROR_NOT_AVAILABLE; }
ChildDNSService::ClearCache(bool aTrrToo) {
Unused << mTRRServiceParent->SendClearDNSCache(aTrrToo);
return NS_OK;
}
NS_IMETHODIMP
ChildDNSService::ReloadParentalControlEnabled() {
return NS_ERROR_NOT_AVAILABLE;
mTRRServiceParent->UpdateParentalControlEnabled();
return NS_OK;
}
NS_IMETHODIMP

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

@ -50,6 +50,8 @@ class ChildDNSRecord : public nsIDNSRecord {
nsTArray<NetAddr> mAddresses;
uint32_t mCurrent; // addr iterator
uint16_t mFlags;
double mTrrFetchDuration;
double mTrrFetchDurationNetworkOnly;
};
NS_IMPL_ISUPPORTS(ChildDNSRecord, nsIDNSRecord)
@ -57,6 +59,8 @@ NS_IMPL_ISUPPORTS(ChildDNSRecord, nsIDNSRecord)
ChildDNSRecord::ChildDNSRecord(const DNSRecord& reply, uint16_t flags)
: mCurrent(0), mFlags(flags) {
mCanonicalName = reply.canonicalName();
mTrrFetchDuration = reply.trrFetchDuration();
mTrrFetchDurationNetworkOnly = reply.trrFetchDurationNetworkOnly();
// A shame IPDL gives us no way to grab ownership of array: so copy it.
const nsTArray<NetAddr>& addrs = reply.addrs();
@ -85,14 +89,14 @@ ChildDNSRecord::IsTRR(bool* retval) {
NS_IMETHODIMP
ChildDNSRecord::GetTrrFetchDuration(double* aTime) {
*aTime = 0;
return NS_ERROR_NOT_AVAILABLE;
*aTime = mTrrFetchDuration;
return NS_OK;
}
NS_IMETHODIMP
ChildDNSRecord::GetTrrFetchDurationNetworkOnly(double* aTime) {
*aTime = 0;
return NS_ERROR_NOT_AVAILABLE;
*aTime = mTrrFetchDurationNetworkOnly;
return NS_OK;
}
NS_IMETHODIMP

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

@ -125,8 +125,15 @@ DNSRequestHandler::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
array.AppendElement(addr);
}
SendLookupCompletedHelper(mIPCActor,
DNSRequestResponse(DNSRecord(cname, array)));
double trrFetchDuration;
rec->GetTrrFetchDuration(&trrFetchDuration);
double trrFetchDurationNetworkOnly;
rec->GetTrrFetchDurationNetworkOnly(&trrFetchDurationNetworkOnly);
SendLookupCompletedHelper(
mIPCActor, DNSRequestResponse(DNSRecord(cname, array, trrFetchDuration,
trrFetchDurationNetworkOnly)));
} else {
SendLookupCompletedHelper(mIPCActor, DNSRequestResponse(status));
}

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

@ -20,6 +20,8 @@ struct DNSRecord
{
nsCString canonicalName;
NetAddr[] addrs;
double trrFetchDuration;
double trrFetchDurationNetworkOnly;
};
union DNSRequestResponse

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

@ -21,7 +21,8 @@ child:
async UpdatePlatformDNSInformation(nsCString[] aSuffixList,
bool aPlatformDisabledTRR);
async InitTRRBLStorage(DataStorageEntry aEntry, FileDescriptor aWriteFd);
async UpdateParentalControlEnabled(bool aEnabled);
async ClearDNSCache(bool aTrrToo);
};
} //namespace net

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

@ -58,5 +58,17 @@ mozilla::ipc::IPCResult TRRServiceChild::RecvInitTRRBLStorage(
return IPC_OK();
}
mozilla::ipc::IPCResult TRRServiceChild::RecvUpdateParentalControlEnabled(
const bool& aEnabled) {
gTRRService->mParentalControlEnabled = aEnabled;
return IPC_OK();
}
mozilla::ipc::IPCResult TRRServiceChild::RecvClearDNSCache(
const bool& aTrrToo) {
Unused << sDNSService->ClearCache(aTrrToo);
return IPC_OK();
}
} // namespace net
} // namespace mozilla

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

@ -31,6 +31,9 @@ class TRRServiceChild : public PTRRServiceChild {
nsTArray<nsCString>&& aDNSSuffixList, const bool& aPlatformDisabledTRR);
mozilla::ipc::IPCResult RecvInitTRRBLStorage(
const psm::DataStorageEntry& aEntry, const FileDescriptor& aWriteFd);
mozilla::ipc::IPCResult RecvUpdateParentalControlEnabled(
const bool& aEnabled);
mozilla::ipc::IPCResult RecvClearDNSCache(const bool& aTrrToo);
private:
virtual ~TRRServiceChild() = default;

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

@ -117,5 +117,10 @@ TRRServiceParent::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
void TRRServiceParent::UpdateParentalControlEnabled() {
bool enabled = TRRService::GetParentalControlEnabledInternal();
Unused << SendUpdateParentalControlEnabled(enabled);
}
} // namespace net
} // namespace mozilla

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

@ -24,6 +24,7 @@ class TRRServiceParent : public nsIObserver,
explicit TRRServiceParent() : mTRRBLStorageInited(false) {}
void Init();
void UpdateParentalControlEnabled();
private:
virtual ~TRRServiceParent() = default;

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

@ -1350,7 +1350,8 @@ nsDNSService::ClearCache(bool aTrrToo) {
NS_IMETHODIMP
nsDNSService::ReloadParentalControlEnabled() {
if (mTrrService) {
mTrrService->GetParentalControlEnabledInternal();
mTrrService->mParentalControlEnabled =
TRRService::GetParentalControlEnabledInternal();
}
return NS_OK;
}

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

@ -1462,13 +1462,15 @@ add_task(async function test_async_resolve_with_trr_server_5() {
dns.clearCache(true);
Services.prefs.setIntPref("network.trr.mode", 5); // TRR-user-disabled
// When dns is resolved in socket process, we can't set |expectEarlyFail| to true.
let inSocketProcess = mozinfo.socketprocess_networking;
let [_] = await new DNSListener(
"bar_with_trr3.example.com",
undefined,
false,
undefined,
`https://foo.example.com:${h2Port}/doh?responseIP=3.3.3.3`,
true
!inSocketProcess
);
// Call normal AsyncOpen, it will return result from the native resolver.