bug 1162821 - filter dns name collision records r=sworkman IGNORE IDL

This commit is contained in:
Patrick McManus 2015-05-08 14:18:20 -04:00
parent bed2514c45
commit 10eaf0063e
5 changed files with 20 additions and 7 deletions

View File

@ -260,18 +260,22 @@ NetAddrElement::~NetAddrElement()
}
AddrInfo::AddrInfo(const char *host, const PRAddrInfo *prAddrInfo,
bool disableIPv4, const char *cname)
bool disableIPv4, bool filterNameCollision, const char *cname)
{
MOZ_ASSERT(prAddrInfo, "Cannot construct AddrInfo with a null prAddrInfo pointer!");
const uint32_t nameCollisionAddr = htonl(0x7f003535); // 127.0.53.53
Init(host, cname);
PRNetAddr tmpAddr;
void *iter = nullptr;
do {
iter = PR_EnumerateAddrInfo(iter, prAddrInfo, 0, &tmpAddr);
if (iter && (!disableIPv4 || tmpAddr.raw.family != PR_AF_INET)) {
NetAddrElement *addrElement = new NetAddrElement(&tmpAddr);
mAddresses.insertBack(addrElement);
bool addIt = iter &&
(!disableIPv4 || tmpAddr.raw.family != PR_AF_INET) &&
(!filterNameCollision || tmpAddr.raw.family != PR_AF_INET || (tmpAddr.inet.ip != nameCollisionAddr));
if (addIt) {
NetAddrElement *addrElement = new NetAddrElement(&tmpAddr);
mAddresses.insertBack(addrElement);
}
} while (iter);
}

View File

@ -130,7 +130,7 @@ public:
// Creates an AddrInfo object. It calls the AddrInfo(const char*, const char*)
// to initialize the host and the cname.
AddrInfo(const char *host, const PRAddrInfo *prAddrInfo, bool disableIPv4,
const char *cname);
bool filterNameCollision, const char *cname);
// Creates a basic AddrInfo object (initialize only the host and the cname).
AddrInfo(const char *host, const char *cname);

View File

@ -328,7 +328,9 @@ _GetAddrInfo_Portable(const char* aCanonHost, uint16_t aAddressFamily,
canonName = PR_GetCanonNameFromAddrInfo(prai);
}
nsAutoPtr<AddrInfo> ai(new AddrInfo(aCanonHost, prai, disableIPv4, canonName));
bool filterNameCollision = !(aFlags & nsHostResolver::RES_ALLOW_NAME_COLLISION);
nsAutoPtr<AddrInfo> ai(new AddrInfo(aCanonHost, prai, disableIPv4,
filterNameCollision, canonName));
PR_FreeAddrInfo(prai);
if (ai->mAddresses.isEmpty()) {
return NS_ERROR_UNKNOWN_HOST;

View File

@ -285,7 +285,9 @@ public:
RES_PRIORITY_LOW = 1 << 3,
RES_SPECULATE = 1 << 4,
//RES_DISABLE_IPV6 = 1 << 5, // Not used
RES_OFFLINE = 1 << 6
RES_OFFLINE = 1 << 6,
//RES_DISABLE_IPv4 = 1 << 7, // Not Used
RES_ALLOW_NAME_COLLISION = 1 << 8
};
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;

View File

@ -163,4 +163,9 @@ interface nsIDNSService : nsISupports
* If set, only IPv6 addresses will be returned from resolve/asyncResolve.
*/
const unsigned long RESOLVE_DISABLE_IPV4 = (1 << 7);
/**
* If set, allow name collision results (127.0.53.53) which are normally filtered.
*/
const unsigned long RESOLVE_ALLOW_NAME_COLLISION = (1 << 8);
};