mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1704762 - Add way to specify NXDOMAIN result in NativeDNSResolverOverride r=necko-reviewers,dragana
Differential Revision: https://phabricator.services.mozilla.com/D113355
This commit is contained in:
parent
e817cf406f
commit
802e84bdf9
@ -348,7 +348,7 @@ nsresult GetAddrInfo(const nsACString& aHost, uint16_t aAddressFamily,
|
||||
// If there is an override for this host, then we synthetize a result.
|
||||
if (gOverrideService &&
|
||||
FindAddrOverride(aHost, aAddressFamily, aFlags, aAddrInfo)) {
|
||||
return NS_OK;
|
||||
return (*aAddrInfo)->Addresses().Length() ? NS_OK : NS_ERROR_UNKNOWN_HOST;
|
||||
}
|
||||
|
||||
nsAutoCString host(aHost);
|
||||
@ -417,6 +417,13 @@ NS_IMETHODIMP NativeDNSResolverOverride::AddIPOverride(
|
||||
// the output buffer in the case of IPv6 input. See bug 223145.
|
||||
memset(&tempAddr, 0, sizeof(PRNetAddr));
|
||||
|
||||
if (aIPLiteral.Equals("N/A"_ns)) {
|
||||
AutoWriteLock lock(mLock);
|
||||
auto& overrides = mOverrides.LookupOrInsert(aHost);
|
||||
overrides.Clear();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (PR_StringToNetAddr(nsCString(aIPLiteral).get(), &tempAddr) !=
|
||||
PR_SUCCESS) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
@ -48,8 +48,9 @@ NS_IMETHODIMP NativeDNSResolverOverrideParent::AddIPOverride(
|
||||
// the output buffer in the case of IPv6 input. See bug 223145.
|
||||
memset(&tempAddr, 0, sizeof(PRNetAddr));
|
||||
|
||||
if (PR_StringToNetAddr(nsCString(aIPLiteral).get(), &tempAddr) !=
|
||||
PR_SUCCESS) {
|
||||
if (!aIPLiteral.Equals("N/A"_ns) &&
|
||||
PR_StringToNetAddr(nsCString(aIPLiteral).get(), &tempAddr) !=
|
||||
PR_SUCCESS) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
@ -309,3 +309,20 @@ add_task(async function test_cname_flag() {
|
||||
dns.clearCache(false);
|
||||
override.clearOverrides();
|
||||
});
|
||||
|
||||
add_task(async function test_nxdomain() {
|
||||
override.addIPOverride(DOMAIN, "N/A");
|
||||
let listener = new Listener();
|
||||
dns.asyncResolve(
|
||||
DOMAIN,
|
||||
Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
|
||||
Ci.nsIDNSService.RESOLVE_CANONICAL_NAME,
|
||||
null,
|
||||
listener,
|
||||
mainThread,
|
||||
defaultOriginAttributes
|
||||
);
|
||||
|
||||
let [, , inStatus] = await listener;
|
||||
equal(inStatus, Cr.NS_ERROR_UNKNOWN_HOST);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user