Bug 1657582 - Add nsIDNSResolverInfo interface r=necko-reviewers,geckoview-reviewers,snorp,mixedpuppy,extension-reviewers,dragana

This patch adds the nsIDNSResolverInfo interface which is used to hold
information about the resolver to be used in a DNS resolution.

We use this to merge all of the *WithTRRServer resolve functions into one.
Passing a resolver info will use that object when appropriate. No resolver
info means that we default to using the system resolver, or the default TRR
resolver.

This patch also converts the RESOLVE_TYPE_* flags into a cenum and adds
the resolveType as a parameter to asyncResolve thus removing the need
to have asyncResolveByType methods.

Differential Revision: https://phabricator.services.mozilla.com/D86176
This commit is contained in:
Valentin Gosu 2020-08-12 08:25:14 +00:00
parent 7973b79f97
commit e1f98ce23a
41 changed files with 444 additions and 576 deletions

View File

@ -1412,7 +1412,9 @@ var gKeywordURIFixup = {
try {
gDNSService.asyncResolve(
hostName,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null,
onLookupCompleteListener,
Services.tm.mainThread,
contentPrincipal.originAttributes

View File

@ -132,7 +132,9 @@ async function dnsLookup(hostname, resolveCanonicalName = false) {
try {
request = gDNSService.asyncResolve(
hostname,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
dnsFlags,
null,
listener,
null,
{} /* defaultOriginAttributes */

View File

@ -116,10 +116,11 @@ class DNSLookup {
this.retryCount++;
try {
this.usedDomain = this._domain || getRandomSubdomain();
gDNSService.asyncResolveWithTrrServer(
gDNSService.asyncResolve(
this.usedDomain,
this.trrServer,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
Ci.nsIDNSService.RESOLVE_BYPASS_CACHE,
gDNSService.newTRRResolverInfo(this.trrServer),
this,
Services.tm.currentThread,
{}

View File

@ -154,9 +154,9 @@ nsresult nsHTMLDNSPrefetch::Prefetch(
nsCOMPtr<nsICancelable> tmpOutstanding;
nsresult rv = sDNSService->AsyncResolveNative(
NS_ConvertUTF16toUTF8(hostname), flags | nsIDNSService::RESOLVE_SPECULATE,
sDNSListener, nullptr, aPartitionedPrincipalOriginAttributes,
getter_AddRefs(tmpOutstanding));
NS_ConvertUTF16toUTF8(hostname), nsIDNSService::RESOLVE_TYPE_DEFAULT,
flags | nsIDNSService::RESOLVE_SPECULATE, nullptr, sDNSListener, nullptr,
aPartitionedPrincipalOriginAttributes, getter_AddRefs(tmpOutstanding));
if (NS_FAILED(rv)) {
return rv;
}
@ -166,10 +166,11 @@ nsresult nsHTMLDNSPrefetch::Prefetch(
nsAutoCString esniHost;
esniHost.Append("_esni.");
esniHost.Append(NS_ConvertUTF16toUTF8(hostname));
Unused << sDNSService->AsyncResolveByTypeNative(
Unused << sDNSService->AsyncResolveNative(
esniHost, nsIDNSService::RESOLVE_TYPE_TXT,
flags | nsIDNSService::RESOLVE_SPECULATE, sDNSListener, nullptr,
aPartitionedPrincipalOriginAttributes, getter_AddRefs(tmpOutstanding));
flags | nsIDNSService::RESOLVE_SPECULATE, nullptr, sDNSListener,
nullptr, aPartitionedPrincipalOriginAttributes,
getter_AddRefs(tmpOutstanding));
}
return NS_OK;
@ -251,17 +252,19 @@ nsresult nsHTMLDNSPrefetch::CancelPrefetch(
// Forward cancellation to DNS service
nsresult rv = sDNSService->CancelAsyncResolveNative(
NS_ConvertUTF16toUTF8(hostname), flags | nsIDNSService::RESOLVE_SPECULATE,
NS_ConvertUTF16toUTF8(hostname), nsIDNSService::RESOLVE_TYPE_DEFAULT,
flags | nsIDNSService::RESOLVE_SPECULATE,
nullptr, // resolverInfo
sDNSListener, aReason, aPartitionedPrincipalOriginAttributes);
// Cancel fetching ESNI keys if needed.
if (StaticPrefs::network_security_esni_enabled() && isHttps) {
nsAutoCString esniHost;
esniHost.Append("_esni.");
esniHost.Append(NS_ConvertUTF16toUTF8(hostname));
sDNSService->CancelAsyncResolveByTypeNative(
sDNSService->CancelAsyncResolveNative(
esniHost, nsIDNSService::RESOLVE_TYPE_TXT,
flags | nsIDNSService::RESOLVE_SPECULATE, sDNSListener, aReason,
aPartitionedPrincipalOriginAttributes);
flags | nsIDNSService::RESOLVE_SPECULATE, nullptr, sDNSListener,
aReason, aPartitionedPrincipalOriginAttributes);
}
return rv;
}
@ -403,19 +406,21 @@ void nsHTMLDNSPrefetch::nsDeferrals::SubmitQueue() {
nsCOMPtr<nsICancelable> tmpOutstanding;
rv = sDNSService->AsyncResolveNative(
hostName,
hostName, nsIDNSService::RESOLVE_TYPE_DEFAULT,
mEntries[mTail].mFlags | nsIDNSService::RESOLVE_SPECULATE,
sDNSListener, nullptr, oa, getter_AddRefs(tmpOutstanding));
nullptr, sDNSListener, nullptr, oa,
getter_AddRefs(tmpOutstanding));
// Fetch ESNI keys if needed.
if (NS_SUCCEEDED(rv) &&
StaticPrefs::network_security_esni_enabled() && isHttps) {
nsAutoCString esniHost;
esniHost.Append("_esni.");
esniHost.Append(hostName);
sDNSService->AsyncResolveByTypeNative(
sDNSService->AsyncResolveNative(
esniHost, nsIDNSService::RESOLVE_TYPE_TXT,
mEntries[mTail].mFlags | nsIDNSService::RESOLVE_SPECULATE,
sDNSListener, nullptr, oa, getter_AddRefs(tmpOutstanding));
nullptr, sDNSListener, nullptr, oa,
getter_AddRefs(tmpOutstanding));
}
// Tell link that deferred prefetch was requested
if (NS_SUCCEEDED(rv)) link->OnDNSPrefetchRequested();

View File

@ -171,9 +171,10 @@ int NrIceResolver::resolve(nr_resolver_resource* resource,
ABORT(R_BAD_ARGS);
}
if (NS_FAILED(dns_->AsyncResolveNative(nsAutoCString(resource->domain_name),
resolve_flags, pr, sts_thread_, attrs,
getter_AddRefs(pr->request_)))) {
if (NS_FAILED(dns_->AsyncResolveNative(
nsAutoCString(resource->domain_name),
nsIDNSService::RESOLVE_TYPE_DEFAULT, resolve_flags, nullptr, pr,
sts_thread_, attrs, getter_AddRefs(pr->request_)))) {
MOZ_MTLOG(ML_ERROR, "AsyncResolve failed.");
ABORT(R_NOT_FOUND);
}

View File

@ -768,9 +768,9 @@ Dashboard::RequestDNSLookup(const nsACString& aHost,
"nsINetDashboardCallback", aCallback, true);
helper->mEventTarget = GetCurrentEventTarget();
OriginAttributes attrs;
rv = mDnsService->AsyncResolveNative(aHost, 0, helper.get(),
NS_GetCurrentThread(), attrs,
getter_AddRefs(helper->mCancel));
rv = mDnsService->AsyncResolveNative(
aHost, nsIDNSService::RESOLVE_TYPE_DEFAULT, 0, nullptr, helper.get(),
NS_GetCurrentThread(), attrs, getter_AddRefs(helper->mCancel));
return rv;
}

View File

@ -130,16 +130,18 @@ NetworkConnectivityService::RecheckDNS() {
Preferences::GetCString("network.connectivity-service.DNSv4.domain", host);
rv = dns->AsyncResolveNative(
host,
host, nsIDNSService::RESOLVE_TYPE_DEFAULT,
nsIDNSService::RESOLVE_DISABLE_IPV6 | nsIDNSService::RESOLVE_DISABLE_TRR,
this, NS_GetCurrentThread(), attrs, getter_AddRefs(mDNSv4Request));
nullptr, this, NS_GetCurrentThread(), attrs,
getter_AddRefs(mDNSv4Request));
NS_ENSURE_SUCCESS(rv, rv);
Preferences::GetCString("network.connectivity-service.DNSv6.domain", host);
rv = dns->AsyncResolveNative(
host,
host, nsIDNSService::RESOLVE_TYPE_DEFAULT,
nsIDNSService::RESOLVE_DISABLE_IPV4 | nsIDNSService::RESOLVE_DISABLE_TRR,
this, NS_GetCurrentThread(), attrs, getter_AddRefs(mDNSv6Request));
nullptr, this, NS_GetCurrentThread(), attrs,
getter_AddRefs(mDNSv6Request));
return rv;
}

View File

@ -1187,11 +1187,12 @@ bool Predictor::RunPredictions(nsIURI* referrer,
uri->GetAsciiHost(hostname);
PREDICTOR_LOG((" doing preresolve %s", hostname.get()));
nsCOMPtr<nsICancelable> tmpCancelable;
mDnsService->AsyncResolveNative(hostname,
(nsIDNSService::RESOLVE_PRIORITY_MEDIUM |
nsIDNSService::RESOLVE_SPECULATE),
mDNSListener, nullptr, originAttributes,
getter_AddRefs(tmpCancelable));
mDnsService->AsyncResolveNative(
hostname, nsIDNSService::RESOLVE_TYPE_DEFAULT,
(nsIDNSService::RESOLVE_PRIORITY_MEDIUM |
nsIDNSService::RESOLVE_SPECULATE),
nullptr, mDNSListener, nullptr, originAttributes,
getter_AddRefs(tmpCancelable));
// Fetch esni keys if needed.
if (StaticPrefs::network_security_esni_enabled() &&
@ -1199,12 +1200,12 @@ bool Predictor::RunPredictions(nsIURI* referrer,
nsAutoCString esniHost;
esniHost.Append("_esni.");
esniHost.Append(hostname);
mDnsService->AsyncResolveByTypeNative(
esniHost, nsIDNSService::RESOLVE_TYPE_TXT,
(nsIDNSService::RESOLVE_PRIORITY_MEDIUM |
nsIDNSService::RESOLVE_SPECULATE),
mDNSListener, nullptr, originAttributes,
getter_AddRefs(tmpCancelable));
mDnsService->AsyncResolveNative(esniHost, nsIDNSService::RESOLVE_TYPE_TXT,
(nsIDNSService::RESOLVE_PRIORITY_MEDIUM |
nsIDNSService::RESOLVE_SPECULATE),
nullptr, mDNSListener, nullptr,
originAttributes,
getter_AddRefs(tmpCancelable));
}
predicted = true;

View File

@ -448,9 +448,10 @@ bool ProxyAutoConfig::ResolveAddress(const nsCString& aHostName,
nsIDNSService::RESOLVE_PRIORITY_MEDIUM |
nsIDNSService::GetFlagsFromTRRMode(nsIRequest::TRR_DISABLED_MODE);
if (NS_FAILED(dns->AsyncResolveNative(aHostName, flags, helper,
GetCurrentEventTarget(), attrs,
getter_AddRefs(helper->mRequest)))) {
if (NS_FAILED(dns->AsyncResolveNative(
aHostName, nsIDNSService::RESOLVE_TYPE_DEFAULT, flags, nullptr,
helper, GetCurrentEventTarget(), attrs,
getter_AddRefs(helper->mRequest)))) {
return false;
}

View File

@ -76,7 +76,8 @@ nsresult nsDNSPrefetch::Prefetch(uint32_t flags) {
flags |= nsIDNSService::GetFlagsFromTRRMode(mTRRMode);
nsresult rv = sDNSService->AsyncResolveNative(
mHostname, flags | nsIDNSService::RESOLVE_SPECULATE, this, target,
mHostname, nsIDNSService::RESOLVE_TYPE_DEFAULT,
flags | nsIDNSService::RESOLVE_SPECULATE, nullptr, this, target,
mOriginAttributes, getter_AddRefs(tmpOutstanding));
if (NS_FAILED(rv)) {
return rv;
@ -87,10 +88,10 @@ nsresult nsDNSPrefetch::Prefetch(uint32_t flags) {
nsAutoCString esniHost;
esniHost.Append("_esni.");
esniHost.Append(mHostname);
sDNSService->AsyncResolveByTypeNative(
esniHost, nsIDNSService::RESOLVE_TYPE_TXT,
flags | nsIDNSService::RESOLVE_SPECULATE, this, target,
mOriginAttributes, getter_AddRefs(tmpOutstanding));
sDNSService->AsyncResolveNative(esniHost, nsIDNSService::RESOLVE_TYPE_TXT,
flags | nsIDNSService::RESOLVE_SPECULATE,
nullptr, this, target, mOriginAttributes,
getter_AddRefs(tmpOutstanding));
}
return NS_OK;
}

View File

@ -1064,9 +1064,10 @@ nsresult nsSocketTransport::ResolveHost() {
SOCKET_LOG(("nsSocketTransport %p origin %s doing dns for %s\n", this,
mOriginHost.get(), SocketHost().get()));
}
rv = dns->AsyncResolveNative(SocketHost(), dnsFlags, this,
mSocketTransportService, mOriginAttributes,
getter_AddRefs(mDNSRequest));
rv =
dns->AsyncResolveNative(SocketHost(), nsIDNSService::RESOLVE_TYPE_DEFAULT,
dnsFlags, nullptr, this, mSocketTransportService,
mOriginAttributes, getter_AddRefs(mDNSRequest));
mEsniQueried = false;
if (mSocketTransportService->IsEsniEnabled() && NS_SUCCEEDED(rv) &&
!(mConnectionFlags & (DONT_TRY_ESNI | BE_CONSERVATIVE))) {
@ -1084,10 +1085,10 @@ nsresult nsSocketTransport::ResolveHost() {
// This might end up being the SocketHost
// see https://github.com/ekr/draft-rescorla-tls-esni/issues/61
esniHost.Append(SocketHost());
rv = dns->AsyncResolveByTypeNative(
esniHost, nsIDNSService::RESOLVE_TYPE_TXT, dnsFlags, this,
mSocketTransportService, mOriginAttributes,
getter_AddRefs(mDNSTxtRequest));
rv = dns->AsyncResolveNative(esniHost, nsIDNSService::RESOLVE_TYPE_TXT,
dnsFlags, nullptr, this,
mSocketTransportService, mOriginAttributes,
getter_AddRefs(mDNSTxtRequest));
if (NS_FAILED(rv)) {
SOCKET_LOG((" dns request by type failed."));
mDNSTxtRequest = nullptr;

View File

@ -58,7 +58,8 @@ static nsresult ResolveHost(const nsACString& host,
}
nsCOMPtr<nsICancelable> tmpOutstanding;
return dns->AsyncResolveNative(host, 0, listener, nullptr, aOriginAttributes,
return dns->AsyncResolveNative(host, nsIDNSService::RESOLVE_TYPE_DEFAULT, 0,
nullptr, listener, nullptr, aOriginAttributes,
getter_AddRefs(tmpOutstanding));
}

View File

@ -20,6 +20,7 @@
#include "mozilla/net/TRRServiceParent.h"
#include "nsServiceManagerUtils.h"
#include "prsystem.h"
#include "DNSResolverInfo.h"
namespace mozilla {
namespace net {
@ -98,9 +99,10 @@ void ChildDNSService::GetDNSRecordHashKey(
}
nsresult ChildDNSService::AsyncResolveInternal(
const nsACString& hostname, const nsACString& aTrrServer, uint16_t type,
uint32_t flags, nsIDNSListener* listener, nsIEventTarget* target_,
const OriginAttributes& aOriginAttributes, nsICancelable** result) {
const nsACString& hostname, uint16_t type, uint32_t flags,
nsIDNSResolverInfo* aResolver, nsIDNSListener* listener,
nsIEventTarget* target_, const OriginAttributes& aOriginAttributes,
nsICancelable** result) {
if (XRE_IsContentProcess()) {
NS_ENSURE_TRUE(gNeckoChild != nullptr, NS_ERROR_FAILURE);
}
@ -129,8 +131,9 @@ nsresult ChildDNSService::AsyncResolveInternal(
listener = new DNSListenerProxy(listener, target);
}
RefPtr<DNSRequestSender> sender = new DNSRequestSender(
hostname, aTrrServer, type, aOriginAttributes, flags, listener, target);
RefPtr<DNSRequestSender> sender =
new DNSRequestSender(hostname, DNSResolverInfo::URL(aResolver), type,
aOriginAttributes, flags, listener, target);
RefPtr<DNSRequestActor> dnsReq;
if (resolveDNSInSocketProcess) {
dnsReq = new DNSRequestParent(sender);
@ -141,8 +144,8 @@ nsresult ChildDNSService::AsyncResolveInternal(
{
MutexAutoLock lock(mPendingRequestsLock);
nsCString key;
GetDNSRecordHashKey(hostname, aTrrServer, type, aOriginAttributes, flags,
originalListenerAddr, key);
GetDNSRecordHashKey(hostname, DNSResolverInfo::URL(aResolver), type,
aOriginAttributes, flags, originalListenerAddr, key);
auto entry = mPendingRequests.LookupForAdd(key);
if (entry) {
entry.Data()->AppendElement(sender);
@ -162,8 +165,8 @@ nsresult ChildDNSService::AsyncResolveInternal(
}
nsresult ChildDNSService::CancelAsyncResolveInternal(
const nsACString& aHostname, const nsACString& aTrrServer, uint16_t aType,
uint32_t aFlags, nsIDNSListener* aListener, nsresult aReason,
const nsACString& aHostname, uint16_t aType, uint32_t aFlags,
nsIDNSResolverInfo* aResolver, nsIDNSListener* aListener, nsresult aReason,
const OriginAttributes& aOriginAttributes) {
if (mDisablePrefetch && (aFlags & RESOLVE_SPECULATE)) {
return NS_ERROR_DNS_LOOKUP_QUEUE_FULL;
@ -173,8 +176,8 @@ nsresult ChildDNSService::CancelAsyncResolveInternal(
nsTArray<RefPtr<DNSRequestSender>>* hashEntry;
nsCString key;
uintptr_t listenerAddr = reinterpret_cast<uintptr_t>(aListener);
GetDNSRecordHashKey(aHostname, aTrrServer, aType, aOriginAttributes, aFlags,
listenerAddr, key);
GetDNSRecordHashKey(aHostname, DNSResolverInfo::URL(aResolver), aType,
aOriginAttributes, aFlags, listenerAddr, key);
if (mPendingRequests.Get(key, &hashEntry)) {
// We cancel just one.
hashEntry->ElementAt(0)->Cancel(aReason);
@ -188,7 +191,9 @@ nsresult ChildDNSService::CancelAsyncResolveInternal(
//-----------------------------------------------------------------------------
NS_IMETHODIMP
ChildDNSService::AsyncResolve(const nsACString& hostname, uint32_t flags,
ChildDNSService::AsyncResolve(const nsACString& hostname,
nsIDNSService::ResolveType aType, uint32_t flags,
nsIDNSResolverInfo* aResolver,
nsIDNSListener* listener, nsIEventTarget* target_,
JS::HandleValue aOriginAttributes, JSContext* aCx,
uint8_t aArgc, nsICancelable** result) {
@ -200,83 +205,34 @@ ChildDNSService::AsyncResolve(const nsACString& hostname, uint32_t flags,
}
}
return AsyncResolveInternal(hostname, EmptyCString(),
nsIDNSService::RESOLVE_TYPE_DEFAULT, flags,
listener, target_, attrs, result);
}
NS_IMETHODIMP
ChildDNSService::AsyncResolveNative(const nsACString& hostname, uint32_t flags,
nsIDNSListener* listener,
nsIEventTarget* target_,
const OriginAttributes& aOriginAttributes,
nsICancelable** result) {
return AsyncResolveInternal(hostname, EmptyCString(),
nsIDNSService::RESOLVE_TYPE_DEFAULT, flags,
listener, target_, aOriginAttributes, result);
}
NS_IMETHODIMP
ChildDNSService::AsyncResolveWithTrrServer(
const nsACString& hostname, const nsACString& trrServer, uint32_t flags,
nsIDNSListener* listener, nsIEventTarget* target_,
JS::HandleValue aOriginAttributes, JSContext* aCx, uint8_t aArgc,
nsICancelable** result) {
OriginAttributes attrs;
if (aArgc == 1) {
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG;
}
}
return AsyncResolveInternal(hostname, trrServer,
nsIDNSService::RESOLVE_TYPE_DEFAULT, flags,
listener, target_, attrs, result);
}
NS_IMETHODIMP
ChildDNSService::AsyncResolveWithTrrServerNative(
const nsACString& hostname, const nsACString& trrServer, uint32_t flags,
nsIDNSListener* listener, nsIEventTarget* target_,
const OriginAttributes& aOriginAttributes, nsICancelable** result) {
return AsyncResolveInternal(hostname, trrServer,
nsIDNSService::RESOLVE_TYPE_DEFAULT, flags,
listener, target_, aOriginAttributes, result);
}
NS_IMETHODIMP
ChildDNSService::AsyncResolveByType(const nsACString& hostname, uint16_t type,
uint32_t flags, nsIDNSListener* listener,
nsIEventTarget* target_,
JS::HandleValue aOriginAttributes,
JSContext* aCx, uint8_t aArgc,
nsICancelable** result) {
OriginAttributes attrs;
if (aArgc == 1) {
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG;
}
}
return AsyncResolveInternal(hostname, EmptyCString(), type, flags, listener,
return AsyncResolveInternal(hostname, aType, flags, aResolver, listener,
target_, attrs, result);
}
NS_IMETHODIMP
ChildDNSService::AsyncResolveByTypeNative(
const nsACString& hostname, uint16_t type, uint32_t flags,
nsIDNSListener* listener, nsIEventTarget* target_,
const OriginAttributes& aOriginAttributes, nsICancelable** result) {
return AsyncResolveInternal(hostname, EmptyCString(), type, flags, listener,
ChildDNSService::AsyncResolveNative(
const nsACString& hostname, nsIDNSService::ResolveType aType,
uint32_t flags, nsIDNSResolverInfo* aResolver, nsIDNSListener* listener,
nsIEventTarget* target_, const OriginAttributes& aOriginAttributes,
nsICancelable** result) {
return AsyncResolveInternal(hostname, aType, flags, aResolver, listener,
target_, aOriginAttributes, result);
}
NS_IMETHODIMP
ChildDNSService::NewTRRResolverInfo(const nsACString& aTrrURL,
nsIDNSResolverInfo** aResolver) {
RefPtr<DNSResolverInfo> res = new DNSResolverInfo(aTrrURL);
res.forget(aResolver);
return NS_OK;
}
NS_IMETHODIMP
ChildDNSService::CancelAsyncResolve(const nsACString& aHostname,
uint32_t aFlags, nsIDNSListener* aListener,
nsresult aReason,
nsIDNSService::ResolveType aType,
uint32_t aFlags,
nsIDNSResolverInfo* aResolver,
nsIDNSListener* aListener, nsresult aReason,
JS::HandleValue aOriginAttributes,
JSContext* aCx, uint8_t aArgc) {
OriginAttributes attrs;
@ -287,73 +243,16 @@ ChildDNSService::CancelAsyncResolve(const nsACString& aHostname,
}
}
return CancelAsyncResolveInternal(aHostname, EmptyCString(),
nsIDNSService::RESOLVE_TYPE_DEFAULT, aFlags,
return CancelAsyncResolveInternal(aHostname, aType, aFlags, aResolver,
aListener, aReason, attrs);
}
NS_IMETHODIMP
ChildDNSService::CancelAsyncResolveNative(
const nsACString& aHostname, uint32_t aFlags, nsIDNSListener* aListener,
const nsACString& aHostname, nsIDNSService::ResolveType aType,
uint32_t aFlags, nsIDNSResolverInfo* aResolver, nsIDNSListener* aListener,
nsresult aReason, const OriginAttributes& aOriginAttributes) {
return CancelAsyncResolveInternal(aHostname, EmptyCString(),
nsIDNSService::RESOLVE_TYPE_DEFAULT, aFlags,
aListener, aReason, aOriginAttributes);
}
NS_IMETHODIMP
ChildDNSService::CancelAsyncResolveWithTrrServer(
const nsACString& aHostname, const nsACString& aTrrServer, uint32_t aFlags,
nsIDNSListener* aListener, nsresult aReason,
JS::HandleValue aOriginAttributes, JSContext* aCx, uint8_t aArgc) {
OriginAttributes attrs;
if (aArgc == 1) {
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG;
}
}
return CancelAsyncResolveInternal(aHostname, aTrrServer,
nsIDNSService::RESOLVE_TYPE_DEFAULT, aFlags,
aListener, aReason, attrs);
}
NS_IMETHODIMP
ChildDNSService::CancelAsyncResolveWithTrrServerNative(
const nsACString& aHostname, const nsACString& aTrrServer, uint32_t aFlags,
nsIDNSListener* aListener, nsresult aReason,
const OriginAttributes& aOriginAttributes) {
return CancelAsyncResolveInternal(aHostname, aTrrServer,
nsIDNSService::RESOLVE_TYPE_DEFAULT, aFlags,
aListener, aReason, aOriginAttributes);
}
NS_IMETHODIMP
ChildDNSService::CancelAsyncResolveByType(const nsACString& aHostname,
uint16_t aType, uint32_t aFlags,
nsIDNSListener* aListener,
nsresult aReason,
JS::HandleValue aOriginAttributes,
JSContext* aCx, uint8_t aArgc) {
OriginAttributes attrs;
if (aArgc == 1) {
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG;
}
}
return CancelAsyncResolveInternal(aHostname, EmptyCString(), aType, aFlags,
aListener, aReason, attrs);
}
NS_IMETHODIMP
ChildDNSService::CancelAsyncResolveByTypeNative(
const nsACString& aHostname, uint16_t aType, uint32_t aFlags,
nsIDNSListener* aListener, nsresult aReason,
const OriginAttributes& aOriginAttributes) {
return CancelAsyncResolveInternal(aHostname, EmptyCString(), aType, aFlags,
return CancelAsyncResolveInternal(aHostname, aType, aFlags, aResolver,
aListener, aReason, aOriginAttributes);
}

View File

@ -42,16 +42,16 @@ class ChildDNSService final : public nsPIDNSService, public nsIObserver {
const nsACString& aHost, const nsACString& aTrrServer, uint16_t aType,
const OriginAttributes& aOriginAttributes, uint32_t aFlags,
uintptr_t aListenerAddr, nsACString& aHashKey);
nsresult AsyncResolveInternal(const nsACString& hostname,
const nsACString& aTrrServer, uint16_t type,
uint32_t flags, nsIDNSListener* listener,
nsresult AsyncResolveInternal(const nsACString& hostname, uint16_t type,
uint32_t flags, nsIDNSResolverInfo* aResolver,
nsIDNSListener* listener,
nsIEventTarget* target_,
const OriginAttributes& aOriginAttributes,
nsICancelable** result);
nsresult CancelAsyncResolveInternal(
const nsACString& aHostname, const nsACString& aTrrServer, uint16_t aType,
uint32_t aFlags, nsIDNSListener* aListener, nsresult aReason,
const OriginAttributes& aOriginAttributes);
const nsACString& aHostname, uint16_t aType, uint32_t aFlags,
nsIDNSResolverInfo* aResolver, nsIDNSListener* aListener,
nsresult aReason, const OriginAttributes& aOriginAttributes);
bool mFirstTime;
bool mDisablePrefetch;

View File

@ -13,6 +13,7 @@
#include "nsIDNSRecord.h"
#include "nsHostResolver.h"
#include "mozilla/Unused.h"
#include "DNSResolverInfo.h"
using namespace mozilla::ipc;
@ -47,18 +48,13 @@ void DNSRequestHandler::DoAsyncResolve(const nsACString& hostname,
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIEventTarget> main = GetMainThreadEventTarget();
nsCOMPtr<nsICancelable> unused;
if (type != nsIDNSService::RESOLVE_TYPE_DEFAULT) {
rv = dns->AsyncResolveByTypeNative(hostname, type, flags, this, main,
originAttributes,
getter_AddRefs(unused));
} else if (trrServer.IsEmpty()) {
rv = dns->AsyncResolveNative(hostname, flags, this, main,
originAttributes, getter_AddRefs(unused));
} else {
rv = dns->AsyncResolveWithTrrServerNative(hostname, trrServer, flags,
this, main, originAttributes,
getter_AddRefs(unused));
RefPtr<DNSResolverInfo> res;
if (!trrServer.IsEmpty()) {
res = new DNSResolverInfo(trrServer);
}
rv = dns->AsyncResolveNative(
hostname, static_cast<nsIDNSService::ResolveType>(type), flags, res,
this, main, originAttributes, getter_AddRefs(unused));
}
if (NS_FAILED(rv) && mIPCActor->CanSend()) {
@ -73,16 +69,13 @@ void DNSRequestHandler::OnRecvCancelDNSRequest(
nsresult rv;
nsCOMPtr<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
if (type != nsIDNSService::RESOLVE_TYPE_DEFAULT) {
rv = dns->CancelAsyncResolveByTypeNative(hostName, type, flags, this,
reason, originAttributes);
} else if (aTrrServer.IsEmpty()) {
rv = dns->CancelAsyncResolveNative(hostName, flags, this, reason,
originAttributes);
} else {
rv = dns->CancelAsyncResolveWithTrrServerNative(
hostName, aTrrServer, flags, this, reason, originAttributes);
RefPtr<DNSResolverInfo> res;
if (!aTrrServer.IsEmpty()) {
res = new DNSResolverInfo(aTrrServer);
}
rv = dns->CancelAsyncResolveNative(
hostName, static_cast<nsIDNSService::ResolveType>(type), flags, res,
this, reason, originAttributes);
}
}

View File

@ -0,0 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DNSResolverInfo.h"
namespace mozilla {
namespace net {
NS_IMPL_ISUPPORTS(DNSResolverInfo, nsIDNSResolverInfo)
NS_IMETHODIMP
DNSResolverInfo::GetURL(nsACString& aURL) {
aURL = mURL;
return NS_OK;
}
} // namespace net
} // namespace mozilla

View File

@ -0,0 +1,34 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_net_DNSResolverInfo_h__
#define mozilla_net_DNSResolverInfo_h__
#include "nsIDNSResolverInfo.h"
namespace mozilla {
namespace net {
class DNSResolverInfo : public nsIDNSResolverInfo {
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIDNSRESOLVERINFO
public:
explicit DNSResolverInfo(const nsACString& aURL) : mURL(aURL){};
static nsCString URL(nsIDNSResolverInfo* aResolver) {
nsCString url;
if (aResolver) {
MOZ_ALWAYS_SUCCEEDS(aResolver->GetURL(url));
}
return url;
}
private:
virtual ~DNSResolverInfo() = default;
nsCString mURL;
};
} // namespace net
} // namespace mozilla
#endif // mozilla_net_DNSResolverInfo_h__

View File

@ -16,6 +16,7 @@ XPIDL_SOURCES += [
'nsIDNSByTypeRecord.idl',
'nsIDNSListener.idl',
'nsIDNSRecord.idl',
'nsIDNSResolverInfo.idl',
'nsIDNSService.idl',
'nsIEffectiveTLDService.idl',
'nsIIDNService.idl',
@ -64,6 +65,7 @@ UNIFIED_SOURCES += [
'DNSListenerProxy.cpp',
'DNSRequestChild.cpp',
'DNSRequestParent.cpp',
'DNSResolverInfo.cpp',
'GetAddrInfo.cpp',
'HTTPSSVC.cpp',
'IDNBlocklistUtils.cpp',

View File

@ -31,6 +31,7 @@
#include "nsQueryObject.h"
#include "nsIObserverService.h"
#include "nsINetworkLinkService.h"
#include "DNSResolverInfo.h"
#include "TRRService.h"
#include "mozilla/Attributes.h"
@ -884,9 +885,10 @@ nsresult nsDNSService::PreprocessHostname(bool aLocalDomain,
}
nsresult nsDNSService::AsyncResolveInternal(
const nsACString& aHostname, const nsACString& aTrrServer, uint16_t type,
uint32_t flags, nsIDNSListener* aListener, nsIEventTarget* target_,
const OriginAttributes& aOriginAttributes, nsICancelable** result) {
const nsACString& aHostname, uint16_t type, uint32_t flags,
nsIDNSResolverInfo* aResolver, nsIDNSListener* aListener,
nsIEventTarget* target_, const OriginAttributes& aOriginAttributes,
nsICancelable** result) {
// grab reference to global host resolver and IDN service. beware
// simultaneous shutdown!!
RefPtr<nsHostResolver> res;
@ -948,19 +950,20 @@ nsresult nsDNSService::AsyncResolveInternal(
(type != RESOLVE_TYPE_DEFAULT) ? 0 : GetAFForLookup(hostname, flags);
MOZ_ASSERT(listener);
RefPtr<nsDNSAsyncRequest> req = new nsDNSAsyncRequest(
res, hostname, aTrrServer, type, aOriginAttributes, listener, flags, af);
RefPtr<nsDNSAsyncRequest> req =
new nsDNSAsyncRequest(res, hostname, DNSResolverInfo::URL(aResolver),
type, aOriginAttributes, listener, flags, af);
if (!req) return NS_ERROR_OUT_OF_MEMORY;
rv = res->ResolveHost(req->mHost, req->mTrrServer, type,
rv = res->ResolveHost(req->mHost, DNSResolverInfo::URL(aResolver), type,
req->mOriginAttributes, flags, af, req);
req.forget(result);
return rv;
}
nsresult nsDNSService::CancelAsyncResolveInternal(
const nsACString& aHostname, const nsACString& aTrrServer, uint16_t aType,
uint32_t aFlags, nsIDNSListener* aListener, nsresult aReason,
const nsACString& aHostname, uint16_t aType, uint32_t aFlags,
nsIDNSResolverInfo* aResolver, nsIDNSListener* aListener, nsresult aReason,
const OriginAttributes& aOriginAttributes) {
// grab reference to global host resolver and IDN service. beware
// simultaneous shutdown!!
@ -988,13 +991,15 @@ nsresult nsDNSService::CancelAsyncResolveInternal(
uint16_t af =
(aType != RESOLVE_TYPE_DEFAULT) ? 0 : GetAFForLookup(hostname, aFlags);
res->CancelAsyncRequest(hostname, aTrrServer, aType, aOriginAttributes,
aFlags, af, aListener, aReason);
res->CancelAsyncRequest(hostname, DNSResolverInfo::URL(aResolver), aType,
aOriginAttributes, aFlags, af, aListener, aReason);
return NS_OK;
}
NS_IMETHODIMP
nsDNSService::AsyncResolve(const nsACString& aHostname, uint32_t flags,
nsDNSService::AsyncResolve(const nsACString& aHostname,
nsIDNSService::ResolveType aType, uint32_t flags,
nsIDNSResolverInfo* aResolver,
nsIDNSListener* listener, nsIEventTarget* target_,
JS::HandleValue aOriginAttributes, JSContext* aCx,
uint8_t aArgc, nsICancelable** result) {
@ -1006,79 +1011,34 @@ nsDNSService::AsyncResolve(const nsACString& aHostname, uint32_t flags,
}
}
return AsyncResolveInternal(aHostname, EmptyCString(), RESOLVE_TYPE_DEFAULT,
flags, listener, target_, attrs, result);
return AsyncResolveInternal(aHostname, aType, flags, aResolver, listener,
target_, attrs, result);
}
NS_IMETHODIMP
nsDNSService::AsyncResolveNative(const nsACString& aHostname, uint32_t flags,
nsDNSService::AsyncResolveNative(const nsACString& aHostname,
nsIDNSService::ResolveType aType,
uint32_t flags, nsIDNSResolverInfo* aResolver,
nsIDNSListener* aListener,
nsIEventTarget* target_,
const OriginAttributes& aOriginAttributes,
nsICancelable** result) {
return AsyncResolveInternal(aHostname, EmptyCString(), RESOLVE_TYPE_DEFAULT,
flags, aListener, target_, aOriginAttributes,
result);
return AsyncResolveInternal(aHostname, aType, flags, aResolver, aListener,
target_, aOriginAttributes, result);
}
NS_IMETHODIMP
nsDNSService::AsyncResolveWithTrrServer(
const nsACString& aHostname, const nsACString& aTrrServer, uint32_t flags,
nsIDNSListener* listener, nsIEventTarget* target_,
JS::HandleValue aOriginAttributes, JSContext* aCx, uint8_t aArgc,
nsICancelable** result) {
OriginAttributes attrs;
if (aArgc == 1) {
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG;
}
}
return AsyncResolveInternal(aHostname, aTrrServer, RESOLVE_TYPE_DEFAULT,
flags, listener, target_, attrs, result);
nsDNSService::NewTRRResolverInfo(const nsACString& aTrrURL,
nsIDNSResolverInfo** aResolver) {
RefPtr<DNSResolverInfo> res = new DNSResolverInfo(aTrrURL);
res.forget(aResolver);
return NS_OK;
}
NS_IMETHODIMP
nsDNSService::AsyncResolveWithTrrServerNative(
const nsACString& aHostname, const nsACString& aTrrServer, uint32_t flags,
nsIDNSListener* aListener, nsIEventTarget* target_,
const OriginAttributes& aOriginAttributes, nsICancelable** result) {
return AsyncResolveInternal(aHostname, aTrrServer, RESOLVE_TYPE_DEFAULT,
flags, aListener, target_, aOriginAttributes,
result);
}
NS_IMETHODIMP
nsDNSService::AsyncResolveByType(const nsACString& aHostname, uint16_t aType,
uint32_t aFlags, nsIDNSListener* aListener,
nsIEventTarget* aTarget_,
JS::HandleValue aOriginAttributes,
JSContext* aCx, uint8_t aArgc,
nsICancelable** aResult) {
OriginAttributes attrs;
if (aArgc == 1) {
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG;
}
}
return AsyncResolveInternal(aHostname, EmptyCString(), aType, aFlags,
aListener, aTarget_, attrs, aResult);
}
NS_IMETHODIMP
nsDNSService::AsyncResolveByTypeNative(
const nsACString& aHostname, uint16_t aType, uint32_t aFlags,
nsIDNSListener* aListener, nsIEventTarget* aTarget_,
const OriginAttributes& aOriginAttributes, nsICancelable** aResult) {
return AsyncResolveInternal(aHostname, EmptyCString(), aType, aFlags,
aListener, aTarget_, aOriginAttributes, aResult);
}
NS_IMETHODIMP
nsDNSService::CancelAsyncResolve(const nsACString& aHostname, uint32_t aFlags,
nsDNSService::CancelAsyncResolve(const nsACString& aHostname,
nsIDNSService::ResolveType aType,
uint32_t aFlags, nsIDNSResolverInfo* aResolver,
nsIDNSListener* aListener, nsresult aReason,
JS::HandleValue aOriginAttributes,
JSContext* aCx, uint8_t aArgc) {
@ -1090,72 +1050,16 @@ nsDNSService::CancelAsyncResolve(const nsACString& aHostname, uint32_t aFlags,
}
}
return CancelAsyncResolveInternal(aHostname, EmptyCString(),
RESOLVE_TYPE_DEFAULT, aFlags, aListener,
aReason, attrs);
}
NS_IMETHODIMP
nsDNSService::CancelAsyncResolveNative(
const nsACString& aHostname, uint32_t aFlags, nsIDNSListener* aListener,
nsresult aReason, const OriginAttributes& aOriginAttributes) {
return CancelAsyncResolveInternal(aHostname, EmptyCString(),
RESOLVE_TYPE_DEFAULT, aFlags, aListener,
aReason, aOriginAttributes);
}
NS_IMETHODIMP
nsDNSService::CancelAsyncResolveWithTrrServer(
const nsACString& aHostname, const nsACString& aTrrServer, uint32_t aFlags,
nsIDNSListener* aListener, nsresult aReason,
JS::HandleValue aOriginAttributes, JSContext* aCx, uint8_t aArgc) {
OriginAttributes attrs;
if (aArgc == 1) {
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG;
}
}
return CancelAsyncResolveInternal(aHostname, aTrrServer, RESOLVE_TYPE_DEFAULT,
aFlags, aListener, aReason, attrs);
}
NS_IMETHODIMP
nsDNSService::CancelAsyncResolveWithTrrServerNative(
const nsACString& aHostname, const nsACString& aTrrServer, uint32_t aFlags,
nsIDNSListener* aListener, nsresult aReason,
const OriginAttributes& aOriginAttributes) {
return CancelAsyncResolveInternal(aHostname, aTrrServer, RESOLVE_TYPE_DEFAULT,
aFlags, aListener, aReason,
aOriginAttributes);
}
NS_IMETHODIMP
nsDNSService::CancelAsyncResolveByType(const nsACString& aHostname,
uint16_t aType, uint32_t aFlags,
nsIDNSListener* aListener,
nsresult aReason,
JS::HandleValue aOriginAttributes,
JSContext* aCx, uint8_t aArgc) {
OriginAttributes attrs;
if (aArgc == 1) {
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG;
}
}
return CancelAsyncResolveInternal(aHostname, EmptyCString(), aType, aFlags,
return CancelAsyncResolveInternal(aHostname, aType, aFlags, aResolver,
aListener, aReason, attrs);
}
NS_IMETHODIMP
nsDNSService::CancelAsyncResolveByTypeNative(
const nsACString& aHostname, uint16_t aType, uint32_t aFlags,
nsIDNSListener* aListener, nsresult aReason,
const OriginAttributes& aOriginAttributes) {
return CancelAsyncResolveInternal(aHostname, EmptyCString(), aType, aFlags,
nsDNSService::CancelAsyncResolveNative(
const nsACString& aHostname, nsIDNSService::ResolveType aType,
uint32_t aFlags, nsIDNSResolverInfo* aResolver, nsIDNSListener* aListener,
nsresult aReason, const OriginAttributes& aOriginAttributes) {
return CancelAsyncResolveInternal(aHostname, aType, aFlags, aResolver,
aListener, aReason, aOriginAttributes);
}

View File

@ -59,15 +59,16 @@ class nsDNSService final : public nsPIDNSService,
nsIIDNService* aIDN, nsACString& aACE);
nsresult AsyncResolveInternal(
const nsACString& aHostname, const nsACString& aTrrServer, uint16_t type,
uint32_t flags, nsIDNSListener* aListener, nsIEventTarget* target_,
const nsACString& aHostname, uint16_t type, uint32_t flags,
nsIDNSResolverInfo* aResolver, nsIDNSListener* aListener,
nsIEventTarget* target_,
const mozilla::OriginAttributes& aOriginAttributes,
nsICancelable** result);
nsresult CancelAsyncResolveInternal(
const nsACString& aHostname, const nsACString& aTrrServer, uint16_t aType,
uint32_t aFlags, nsIDNSListener* aListener, nsresult aReason,
const mozilla::OriginAttributes& aOriginAttributes);
const nsACString& aHostname, uint16_t aType, uint32_t aFlags,
nsIDNSResolverInfo* aResolver, nsIDNSListener* aListener,
nsresult aReason, const mozilla::OriginAttributes& aOriginAttributes);
nsresult ResolveInternal(const nsACString& aHostname, uint32_t flags,
const mozilla::OriginAttributes& aOriginAttributes,

View File

@ -0,0 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
[scriptable, builtinclass, uuid(74db2955-6298-4d82-a3b9-7f9e8ba9e854)]
interface nsIDNSResolverInfo : nsISupports
{
readonly attribute ACString URL;
};

View File

@ -13,6 +13,7 @@ interface nsICancelable;
interface nsIEventTarget;
interface nsIDNSRecord;
interface nsIDNSListener;
interface nsIDNSResolverInfo;
%{C++
#include "nsTArrayForwardDeclare.h"
@ -30,13 +31,28 @@ namespace mozilla { namespace net {
[scriptable, builtinclass, uuid(de5642c6-61fc-4fcf-9a47-03226b0d4e21)]
interface nsIDNSService : nsISupports
{
/**
* These are the dns request types that are currently supported.
* RESOLVE_TYPE_DEFAULT is standard A/AAAA lookup
*/
cenum ResolveType : 16 {
RESOLVE_TYPE_DEFAULT = 0,
RESOLVE_TYPE_TXT = 16,
RESOLVE_TYPE_HTTPSSVC = 65,
};
/**
* kicks off an asynchronous host lookup.
*
* @param aHostName
* the hostname or IP-address-literal to resolve.
* @param aType
* one of RESOLVE_TYPE_*.
* @param aFlags
* a bitwise OR of the RESOLVE_ prefixed constants defined below.
* @param aResolver
* a resolverInfo object that holds information about the resolver
* to be used such as TRR URL. If null we use the default configuration.
* @param aListener
* the listener to be notified when the result is available.
* @param aListenerTarget
@ -54,110 +70,40 @@ interface nsIDNSService : nsISupports
*/
[implicit_jscontext, optional_argc]
nsICancelable asyncResolve(in AUTF8String aHostName,
in nsIDNSService_ResolveType aType,
in unsigned long aFlags,
in nsIDNSResolverInfo aResolver,
in nsIDNSListener aListener,
in nsIEventTarget aListenerTarget,
[optional] in jsval aOriginAttributes);
[notxpcom]
nsresult asyncResolveNative(in AUTF8String aHostName,
in nsIDNSService_ResolveType aType,
in unsigned long aFlags,
in nsIDNSResolverInfo aResolver,
in nsIDNSListener aListener,
in nsIEventTarget aListenerTarget,
in OriginAttributes aOriginAttributes,
out nsICancelable aResult);
/**
* kicks off an asynchronous host lookup with a specific TRR server to be
* used. This request will not be cached.
*
* @param aHostName
* the hostname or IP-address-literal to resolve.
* @param aTrrServer
* the uri of a trr server to be used.
* @param aFlags
* a bitwise OR of the RESOLVE_ prefixed constants defined below.
* @param aListener
* the listener to be notified when the result is available.
* @param aListenerTarget
* optional parameter (may be null). if non-null, this parameter
* specifies the nsIEventTarget of the thread on which the
* listener's onLookupComplete should be called. however, if this
* parameter is null, then onLookupComplete will be called on an
* unspecified thread (possibly recursively).
* @param aOriginAttributes
* the originAttribute for this resolving, the DNS cache will be
* separated according to this originAttributes. This attribute is
* optional to avoid breaking add-ons.
*
* @return An object that can be used to cancel the host lookup.
* Returns a new resolverInfo object containing the URL we pass to it.
*/
[implicit_jscontext, optional_argc]
nsICancelable asyncResolveWithTrrServer(in AUTF8String aHostName,
in AUTF8String aTrrServer,
in unsigned long aFlags,
in nsIDNSListener aListener,
in nsIEventTarget aListenerTarget,
[optional] in jsval aOriginAttributes);
[notxpcom]
nsresult asyncResolveWithTrrServerNative(in AUTF8String aHostName,
in AUTF8String aTrrServer,
in unsigned long aFlags,
in nsIDNSListener aListener,
in nsIEventTarget aListenerTarget,
in OriginAttributes aOriginAttributes,
out nsICancelable aResult);
/**
* kicks off an asynchronous host lookup by type, e.g. TXT.
*
* @param aHostName
* the hostname or IP-address-literal to resolve.
* @param aType
* one of RESOLVE_TYPE_*.
* @param aFlags
* a bitwise OR of the RESOLVE_ prefixed constants defined below
* except RESOLVE_CANONICAL_NAME, RESOLVE_DISABLE_IPV6 and
* RESOLVE_DISABLE_IPV4.
* @param aListener
* the listener to be notified when the result is available.
* @param aListenerTarget
* optional parameter (may be null). if non-null, this parameter
* specifies the nsIEventTarget of the thread on which the
* listener's onLookupComplete should be called. however, if this
* parameter is null, then onLookupComplete will be called on an
* unspecified thread (possibly recursively).
* @param aOriginAttributes
* the originAttribute for this resolving, the DNS cache will be
* separated according to this originAttributes.
*
* @return An object that can be used to cancel the host lookup.
*/
[implicit_jscontext, optional_argc]
nsICancelable asyncResolveByType(in AUTF8String aHostName,
in unsigned short aType,
in unsigned long aFlags,
in nsIDNSListener aListener,
in nsIEventTarget aListenerTarget,
in jsval aOriginAttributes);
[notxpcom]
nsresult asyncResolveByTypeNative(in AUTF8String aHostName,
in unsigned short aType,
in unsigned long aFlags,
in nsIDNSListener aListener,
in nsIEventTarget aListenerTarget,
in OriginAttributes aOriginAttributes,
out nsICancelable aResult);
nsIDNSResolverInfo newTRRResolverInfo(in AUTF8String aTrrURL);
/**
* Attempts to cancel a previously requested async DNS lookup
*
* @param aHostName
* the hostname or IP-address-literal to resolve.
* @param aType
* one of RESOLVE_TYPE_*.
* @param aFlags
* a bitwise OR of the RESOLVE_ prefixed constants defined below.
* @param aResolver
* a resolverInfo object that holds information about the resolver
* to be used such as TRR URL. If null we use the default configuration.
* @param aListener
* the original listener which was to be notified about the host lookup
* result - used to match request information to requestor.
@ -169,90 +115,22 @@ interface nsIDNSService : nsISupports
*/
[implicit_jscontext, optional_argc]
void cancelAsyncResolve(in AUTF8String aHostName,
in nsIDNSService_ResolveType aType,
in unsigned long aFlags,
in nsIDNSResolverInfo aResolver,
in nsIDNSListener aListener,
in nsresult aReason,
[optional] in jsval aOriginAttributes);
[notxpcom]
nsresult cancelAsyncResolveNative(in AUTF8String aHostName,
in nsIDNSService_ResolveType aType,
in unsigned long aFlags,
in nsIDNSResolverInfo aResolver,
in nsIDNSListener aListener,
in nsresult aReason,
in OriginAttributes aOriginAttributes);
/**
* Attempts to cancel a previously requested async DNS lookup
*
* @param aHostName
* the hostname or IP-address-literal to resolve.
* @param aTrrServer
* the uri of a trr server to be used.
* @param aFlags
* a bitwise OR of the RESOLVE_ prefixed constants defined below.
* @param aListener
* the original listener which was to be notified about the host lookup
* result - used to match request information to requestor.
* @param aReason
* nsresult reason for the cancellation
* @param aOriginAttributes
* the originAttribute for this resolving. This attribute is optional
* to avoid breaking add-ons.
*/
[implicit_jscontext, optional_argc]
void cancelAsyncResolveWithTrrServer(in AUTF8String aHostName,
in AUTF8String aTrrServer,
in unsigned long aFlags,
in nsIDNSListener aListener,
in nsresult aReason,
[optional] in jsval aOriginAttributes);
[notxpcom]
nsresult cancelAsyncResolveWithTrrServerNative(in AUTF8String aHostName,
in AUTF8String aTrrServer,
in unsigned long aFlags,
in nsIDNSListener aListener,
in nsresult aReason,
in OriginAttributes aOriginAttributes);
/**
* Attempts to cancel a previously requested async DNS lookup
*
* @param aHostName
* the hostname or IP-address-literal to resolve.
* @param aType
* one of RESOLVE_TYPE_*.
* @param aFlags
* a bitwise OR of the RESOLVE_ prefixed constants defined below
* except RESOLVE_CANONICAL_NAME, RESOLVE_DISABLE_IPV6 and
* RESOLVE_DISABLE_IPV4.
* @param aListener
* the original listener which was to be notified about the host lookup
* result - used to match request information to requestor.
* @param aReason
* nsresult reason for the cancellation
* @param aOriginAttributes
* the originAttribute for this resolving. This attribute is optional
* to avoid breaking add-ons.
*
*/
[implicit_jscontext, optional_argc]
void cancelAsyncResolveByType(in AUTF8String aHostName,
in unsigned short aType,
in unsigned long aFlags,
in nsIDNSListener aListener,
in nsresult aReason,
in jsval aOriginAttributes);
[notxpcom]
nsresult cancelAsyncResolveByTypeNative(in AUTF8String aHostName,
in unsigned short aType,
in unsigned long aFlags,
in nsIDNSListener aListener,
in nsresult aReason,
in OriginAttributes aOriginAttributes);
/**
* called to synchronously resolve a hostname.
*
@ -409,15 +287,6 @@ interface nsIDNSService : nsISupports
* Only to be used for the proxy host resolution.
*/
const unsigned long RESOLVE_IGNORE_SOCKS_DNS = 1 << 13;
/**
* These are the dns request types that are currently supported.
* RESOLVE_TYPE_DEFAULT is standard A/AAAA lookup
* The others (currently only TXT supported) are wireformat types
*/
const unsigned long RESOLVE_TYPE_DEFAULT = 0;
const unsigned long RESOLVE_TYPE_TXT = 16;
const unsigned long RESOLVE_TYPE_HTTPSSVC = 65;
};
%{C++

View File

@ -2734,9 +2734,9 @@ nsresult WebSocketChannel::DoAdmissionDNS() {
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIEventTarget> main = GetMainThreadEventTarget();
MOZ_ASSERT(!mCancelable);
return dns->AsyncResolveNative(hostName, 0, this, main,
mLoadInfo->GetOriginAttributes(),
getter_AddRefs(mCancelable));
return dns->AsyncResolveNative(
hostName, nsIDNSService::RESOLVE_TYPE_DEFAULT, 0, nullptr, this, main,
mLoadInfo->GetOriginAttributes(), getter_AddRefs(mCancelable));
}
nsresult WebSocketChannel::ApplyForAdmission() {

View File

@ -469,7 +469,8 @@ PRStatus nsSOCKSSocketInfo::StartDNS(PRFileDesc* fd) {
mFD = fd;
nsresult rv = dns->AsyncResolveNative(
proxyHost, nsIDNSService::RESOLVE_IGNORE_SOCKS_DNS, this,
proxyHost, nsIDNSService::RESOLVE_TYPE_DEFAULT,
nsIDNSService::RESOLVE_IGNORE_SOCKS_DNS, nullptr, this,
mozilla::GetCurrentEventTarget(), attrs, getter_AddRefs(mLookup));
if (NS_FAILED(rv)) {

View File

@ -107,29 +107,22 @@ class TRRDNSListener {
);
const currentThread = threadManager.currentThread;
if (trrServer == "") {
let resolverInfo =
trrServer == "" ? null : dns.newTRRResolverInfo(trrServer);
try {
this.request = dns.asyncResolve(
name,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
resolverInfo,
this,
currentThread,
{} // defaultOriginAttributes
);
} else {
try {
this.request = dns.asyncResolveWithTrrServer(
name,
trrServer,
0,
this,
currentThread,
{} // defaultOriginAttributes
);
Assert.ok(!expectEarlyFail);
} catch (e) {
Assert.ok(expectEarlyFail);
this.resolve([e]);
}
Assert.ok(!expectEarlyFail);
} catch (e) {
Assert.ok(expectEarlyFail);
this.resolve([e]);
}
}

View File

@ -57,14 +57,18 @@ function run_test() {
// This one will be canceled with cancelAsyncResolve.
requestList1Canceled1 = dns.asyncResolve(
hostname2,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
flags,
null, // resolverInfo
listener1,
mainThread,
defaultOriginAttributes
);
dns.cancelAsyncResolve(
hostname2,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
flags,
null, // resolverInfo
listener1,
Cr.NS_ERROR_ABORT,
defaultOriginAttributes
@ -73,7 +77,9 @@ function run_test() {
// This one will not be canceled.
requestList1NotCanceled = dns.asyncResolve(
hostname1,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
flags,
null, // resolverInfo
listener1,
mainThread,
defaultOriginAttributes
@ -82,7 +88,9 @@ function run_test() {
// This one will be canceled with cancel(Cr.NS_ERROR_ABORT).
requestList1Canceled2 = dns.asyncResolve(
hostname1,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
flags,
null, // resolverInfo
listener1,
mainThread,
defaultOriginAttributes
@ -92,7 +100,9 @@ function run_test() {
// This one will not be canceled.
requestList2NotCanceled = dns.asyncResolve(
hostname1,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
flags,
null, // resolverInfo
listener2,
mainThread,
defaultOriginAttributes
@ -101,7 +111,9 @@ function run_test() {
// This one will be canceled with cancel(Cr.NS_ERROR_ABORT).
requestList2Canceled = dns.asyncResolve(
hostname2,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
flags,
null, // resolverInfo
listener2,
mainThread,
defaultOriginAttributes

View File

@ -39,7 +39,9 @@ function run_test() {
try {
dns.asyncResolve(
"example.org",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
Ci.nsIDNSService.RESOLVE_DISABLE_IPV4,
null, // resolverInfo
listener,
null,
defaultOriginAttributes

View File

@ -40,7 +40,9 @@ function run_test() {
try {
dns.asyncResolve(
"example.com",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
Ci.nsIDNSService.RESOLVE_DISABLE_IPV6,
null, // resolverInfo
listener,
null,
defaultOriginAttributes

View File

@ -48,7 +48,9 @@ function do_test({
try {
dns.asyncResolve(
testDomain,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null, // resolverInfo
mustBlock
? makeListenerBlock(nextCallback)
: makeListenerDontBlock(nextCallback, expectedAnswer),

View File

@ -30,7 +30,9 @@ function run_test() {
nextTest = do_test_2;
dns.asyncResolve(
"local.vingtetun.org",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null, // resolverInfo
listener,
mainThread,
defaultOriginAttributes
@ -48,7 +50,9 @@ function do_test_2() {
prefs.setCharPref("network.dns.forceResolve", "localhost");
dns.asyncResolve(
"www.example.com",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null, // resolverInfo
listener,
mainThread,
defaultOriginAttributes

View File

@ -49,7 +49,9 @@ function run_test() {
try {
dns.asyncResolve(
"localhost",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null, // resolverInfo
listener1,
mainThread,
defaultOriginAttributes
@ -73,7 +75,9 @@ function test2() {
function test2Continued() {
dns.asyncResolve(
"localhost",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null, // resolverInfo
listener2,
mainThread,
defaultOriginAttributes
@ -90,7 +94,9 @@ function test3() {
function test3Continued() {
dns.asyncResolve(
"localhost",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null, // resolverInfo
listener3,
mainThread,
defaultOriginAttributes

View File

@ -37,7 +37,9 @@ function do_test_dontBlock() {
prefs.setBoolPref("network.dns.blockDotOnion", false);
dns.asyncResolve(
"private.onion",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null, // resolverInfo
listenerDontBlock,
mainThread,
defaultOriginAttributes
@ -49,7 +51,9 @@ function do_test_block() {
try {
dns.asyncResolve(
"private.onion",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null, // resolverInfo
listenerBlock,
mainThread,
defaultOriginAttributes

View File

@ -41,7 +41,9 @@ function run_test() {
do_test_pending();
dns.asyncResolve(
"localhost",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null, // resolverInfo
listener1,
mainThread,
firstOriginAttributes
@ -54,7 +56,9 @@ function test2() {
do_test_pending();
dns.asyncResolve(
"localhost",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
Ci.nsIDNSService.RESOLVE_OFFLINE,
null, // resolverInfo
listener2,
mainThread,
firstOriginAttributes
@ -69,7 +73,9 @@ function test3() {
try {
dns.asyncResolve(
"localhost",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
Ci.nsIDNSService.RESOLVE_OFFLINE,
null, // resolverInfo
listener3,
mainThread,
secondOriginAttributes

View File

@ -79,7 +79,15 @@ add_task(async function test_bad_IPs() {
add_task(async function test_ipv4() {
let listener = new Listener();
override.addIPOverride(DOMAIN, "1.2.3.4");
dns.asyncResolve(DOMAIN, 0, listener, mainThread, defaultOriginAttributes);
dns.asyncResolve(
DOMAIN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null,
listener,
mainThread,
defaultOriginAttributes
);
Assert.equal(await listener.firstAddress(), "1.2.3.4");
dns.clearCache(false);
@ -89,7 +97,15 @@ add_task(async function test_ipv4() {
add_task(async function test_ipv6() {
let listener = new Listener();
override.addIPOverride(DOMAIN, "fe80::6a99:9b2b:6ccc:6e1b");
dns.asyncResolve(DOMAIN, 0, listener, mainThread, defaultOriginAttributes);
dns.asyncResolve(
DOMAIN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null,
listener,
mainThread,
defaultOriginAttributes
);
Assert.equal(await listener.firstAddress(), "fe80::6a99:9b2b:6ccc:6e1b");
dns.clearCache(false);
@ -99,14 +115,30 @@ add_task(async function test_ipv6() {
add_task(async function test_clearOverrides() {
let listener = new Listener();
override.addIPOverride(DOMAIN, "1.2.3.4");
dns.asyncResolve(DOMAIN, 0, listener, mainThread, defaultOriginAttributes);
dns.asyncResolve(
DOMAIN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null,
listener,
mainThread,
defaultOriginAttributes
);
Assert.equal(await listener.firstAddress(), "1.2.3.4");
dns.clearCache(false);
override.clearOverrides();
listener = new Listener();
dns.asyncResolve(DOMAIN, 0, listener, mainThread, defaultOriginAttributes);
dns.asyncResolve(
DOMAIN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null,
listener,
mainThread,
defaultOriginAttributes
);
Assert.notEqual(await listener.firstAddress(), "1.2.3.4");
await new Promise(resolve => do_timeout(1000, resolve));
@ -119,12 +151,28 @@ add_task(async function test_clearHostOverride() {
override.addIPOverride(OTHER, "2.2.2.2");
override.clearHostOverride(DOMAIN);
let listener = new Listener();
dns.asyncResolve(DOMAIN, 0, listener, mainThread, defaultOriginAttributes);
dns.asyncResolve(
DOMAIN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null,
listener,
mainThread,
defaultOriginAttributes
);
Assert.notEqual(await listener.firstAddress(), "2.2.2.2");
listener = new Listener();
dns.asyncResolve(OTHER, 0, listener, mainThread, defaultOriginAttributes);
dns.asyncResolve(
OTHER,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null,
listener,
mainThread,
defaultOriginAttributes
);
Assert.equal(await listener.firstAddress(), "2.2.2.2");
// Note: this test will use the actual system resolver. On windows we do a
@ -145,7 +193,15 @@ add_task(async function test_multiple_IPs() {
override.addIPOverride(DOMAIN, "::1");
override.addIPOverride(DOMAIN, "fe80::6a99:9b2b:6ccc:6e1b");
let listener = new Listener();
dns.asyncResolve(DOMAIN, 0, listener, mainThread, defaultOriginAttributes);
dns.asyncResolve(
DOMAIN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null,
listener,
mainThread,
defaultOriginAttributes
);
Assert.deepEqual(await listener.addresses(), [
"2.2.2.2",
"1.1.1.1",
@ -165,7 +221,9 @@ add_task(async function test_address_family_flags() {
let listener = new Listener();
dns.asyncResolve(
DOMAIN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
Ci.nsIDNSService.RESOLVE_DISABLE_IPV4,
null,
listener,
mainThread,
defaultOriginAttributes
@ -178,7 +236,9 @@ add_task(async function test_address_family_flags() {
listener = new Listener();
dns.asyncResolve(
DOMAIN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
Ci.nsIDNSService.RESOLVE_DISABLE_IPV6,
null,
listener,
mainThread,
defaultOriginAttributes
@ -192,7 +252,15 @@ add_task(async function test_address_family_flags() {
add_task(async function test_cname_flag() {
override.addIPOverride(DOMAIN, "2.2.2.2");
let listener = new Listener();
dns.asyncResolve(DOMAIN, 0, listener, mainThread, defaultOriginAttributes);
dns.asyncResolve(
DOMAIN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null,
listener,
mainThread,
defaultOriginAttributes
);
let [inRequest, inRecord, inStatus] = await listener;
Assert.throws(
() => inRecord.canonicalName,
@ -204,7 +272,9 @@ add_task(async function test_cname_flag() {
listener = new Listener();
dns.asyncResolve(
DOMAIN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
Ci.nsIDNSService.RESOLVE_CANONICAL_NAME,
null,
listener,
mainThread,
defaultOriginAttributes
@ -221,7 +291,9 @@ add_task(async function test_cname_flag() {
listener = new Listener();
dns.asyncResolve(
DOMAIN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
Ci.nsIDNSService.RESOLVE_CANONICAL_NAME,
null,
listener,
mainThread,
defaultOriginAttributes

View File

@ -38,7 +38,9 @@ add_task(async function test_dns_localhost() {
let listener = new Listener();
dns.asyncResolve(
"localhost",
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
0,
null, // resolverInfo
listener,
mainThread,
defaultOriginAttributes
@ -53,7 +55,9 @@ add_task(async function test_idn_cname() {
let listener = new Listener();
dns.asyncResolve(
DOMAIN_IDN,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
Ci.nsIDNSService.RESOLVE_CANONICAL_NAME,
null, // resolverInfo
listener,
mainThread,
defaultOriginAttributes

View File

@ -109,10 +109,11 @@ add_task(async function testEsniRequest() {
);
let listenerEsni = new DNSListener();
let request = dns.asyncResolveByType(
let request = dns.asyncResolve(
"_esni.example.com",
dns.RESOLVE_TYPE_TXT,
0,
null, // resolverInfo
listenerEsni,
mainThread,
defaultOriginAttributes
@ -136,7 +137,9 @@ add_task(async function testEsniPushPart1() {
let listenerAddr = new DNSListener();
let request = dns.asyncResolve(
"_esni_push.example.com",
dns.RESOLVE_TYPE_DEFAULT,
0,
null, // resolverInfo
listenerAddr,
mainThread,
defaultOriginAttributes
@ -158,10 +161,11 @@ add_task(async function testEsniPushPart2() {
"https://foo.example.com:" + h2Port + "/404"
);
let listenerEsni = new DNSListener();
let request = dns.asyncResolveByType(
let request = dns.asyncResolve(
"_esni_push.example.com",
dns.RESOLVE_TYPE_TXT,
0,
null, // resolverInfo
listenerEsni,
mainThread,
defaultOriginAttributes
@ -182,10 +186,11 @@ add_task(async function testEsniHTTPSSVC() {
"https://foo.example.com:" + h2Port + "/doh"
);
let listenerEsni = new DNSListener();
let request = dns.asyncResolveByType(
let request = dns.asyncResolve(
"httpssvc_esni.example.com",
dns.RESOLVE_TYPE_HTTPSSVC,
0,
null, // resolverInfo
listenerEsni,
mainThread,
defaultOriginAttributes

View File

@ -131,29 +131,23 @@ class DNSListener {
this.promise = new Promise(resolve => {
this.resolve = resolve;
});
if (trrServer == "") {
let resolverInfo =
trrServer == "" ? null : dns.newTRRResolverInfo(trrServer);
try {
this.request = dns.asyncResolve(
name,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
flags,
resolverInfo,
this,
mainThread,
defaultOriginAttributes
);
} else {
try {
this.request = dns.asyncResolveWithTrrServer(
name,
trrServer,
flags,
this,
mainThread,
defaultOriginAttributes
);
Assert.ok(!expectEarlyFail);
} catch (e) {
Assert.ok(expectEarlyFail);
this.resolve([e]);
}
Assert.ok(!expectEarlyFail);
} catch (e) {
Assert.ok(expectEarlyFail);
this.resolve([e]);
}
}

View File

@ -117,10 +117,11 @@ add_task(async function testHTTPSSVC() {
}
let listenerEsni = new DNSListener();
let request = dns.asyncResolveByType(
let request = dns.asyncResolve(
"test.httpssvc.com",
dns.RESOLVE_TYPE_HTTPSSVC,
0,
null, // resolverInfo
listenerEsni,
mainThread,
defaultOriginAttributes
@ -416,10 +417,11 @@ add_task(async function test_aliasform() {
]);
let listener = new DNSListener();
let request = dns.asyncResolveByType(
let request = dns.asyncResolve(
"multi.com",
dns.RESOLVE_TYPE_HTTPSSVC,
0,
null, // resolverInfo
listener,
mainThread,
defaultOriginAttributes
@ -455,10 +457,11 @@ add_task(async function test_aliasform() {
]);
listener = new DNSListener();
request = dns.asyncResolveByType(
request = dns.asyncResolve(
"order.com",
dns.RESOLVE_TYPE_HTTPSSVC,
0,
null, // resolverInfo
listener,
mainThread,
defaultOriginAttributes
@ -490,10 +493,11 @@ add_task(async function test_aliasform() {
]);
listener = new DNSListener();
request = dns.asyncResolveByType(
request = dns.asyncResolve(
"duplicate.com",
dns.RESOLVE_TYPE_HTTPSSVC,
0,
null, // resolverInfo
listener,
mainThread,
defaultOriginAttributes
@ -526,10 +530,11 @@ add_task(async function test_aliasform() {
]);
listener = new DNSListener();
request = dns.asyncResolveByType(
request = dns.asyncResolve(
"mandatory.com",
dns.RESOLVE_TYPE_HTTPSSVC,
0,
null, // resolverInfo
listener,
mainThread,
defaultOriginAttributes
@ -573,10 +578,11 @@ add_task(async function test_aliasform() {
]);
listener = new DNSListener();
request = dns.asyncResolveByType(
request = dns.asyncResolve(
"mandatory2.com",
dns.RESOLVE_TYPE_HTTPSSVC,
0,
null, // resolverInfo
listener,
mainThread,
defaultOriginAttributes

View File

@ -35,10 +35,11 @@ DNSListener.prototype.QueryInterface = ChromeUtils.generateQI([
add_task(async function testEsniRequest() {
// use the h2 server as DOH provider
let listenerEsni = new DNSListener();
let request = dns.asyncResolveByType(
let request = dns.asyncResolve(
"_esni.example.com",
dns.RESOLVE_TYPE_TXT,
0,
null, // resolverInfo
listenerEsni,
mainThread,
defaultOriginAttributes
@ -56,10 +57,11 @@ add_task(async function testEsniRequest() {
add_task(async function testEsniHTTPSSVC() {
// use the h2 server as DOH provider
let listenerEsni = new DNSListener();
let request = dns.asyncResolveByType(
let request = dns.asyncResolve(
"httpssvc_esni.example.com",
dns.RESOLVE_TYPE_HTTPSSVC,
0,
null, // resolverInfo
listenerEsni,
mainThread,
defaultOriginAttributes

View File

@ -70,7 +70,9 @@ this.dns = class extends ExtensionAPI {
try {
request = dnss.asyncResolve(
hostname,
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
dnsFlags,
null, // resolverInfo
listener,
null,
{} /* defaultOriginAttributes */

View File

@ -657,7 +657,8 @@ static nsresult ResolveHost(nsCString& host, java::GeckoResult::Param result) {
nsCOMPtr<nsICancelable> cancelable;
RefPtr<DNSListener> listener = new DNSListener(host, result);
rv = dns->AsyncResolveNative(host, 0, listener, nullptr /* aListenerTarget */,
rv = dns->AsyncResolveNative(host, nsIDNSService::RESOLVE_TYPE_DEFAULT, 0,
nullptr, listener, nullptr /* aListenerTarget */,
OriginAttributes(), getter_AddRefs(cancelable));
return rv;
}