Verified Commit 61e0f2c3 authored by Kershaw Chang's avatar Kershaw Chang Committed by Pier Angelo Vendrame
Browse files

Bug 1910593 - Don't prefetch HTTPS RR if proxyDNS is enabled, r=necko-reviewers,valentin

parent d6722abd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ dictionary DnsCacheEntry {
  boolean trr = false;
  DOMString originAttributesSuffix = "";
  DOMString flags = "";
  unsigned short type = 0;
};

[GenerateConversionToJS]
+7 −4
Original line number Diff line number Diff line
@@ -906,11 +906,14 @@ nsresult Dashboard::GetDNSCacheEntries(DnsData* dnsData) {
      CopyASCIItoUTF16(dnsData->mData[i].hostaddr[j], *addr);
    }

    entry.mType = dnsData->mData[i].resolveType;
    if (entry.mType == nsIDNSService::RESOLVE_TYPE_DEFAULT) {
      if (dnsData->mData[i].family == PR_AF_INET6) {
        entry.mFamily.AssignLiteral(u"ipv6");
      } else {
        entry.mFamily.AssignLiteral(u"ipv4");
      }
    }

    entry.mOriginAttributesSuffix =
        NS_ConvertUTF8toUTF16(dnsData->mData[i].originAttributesSuffix);
+11 −7
Original line number Diff line number Diff line
@@ -35,12 +35,12 @@ struct DnsAndConnectSockets {
struct DNSCacheEntries {
  nsCString hostname;
  nsTArray<nsCString> hostaddr;
  uint16_t family;
  int64_t expiration;
  nsCString netInterface;
  bool TRR;
  uint16_t family{0};
  int64_t expiration{0};
  bool TRR{false};
  nsCString originAttributesSuffix;
  nsCString flags;
  uint16_t resolveType{0};
};

struct HttpConnInfo {
@@ -99,8 +99,10 @@ struct ParamTraits<mozilla::net::DNSCacheEntries> {
    WriteParam(aWriter, aParam.hostaddr);
    WriteParam(aWriter, aParam.family);
    WriteParam(aWriter, aParam.expiration);
    WriteParam(aWriter, aParam.netInterface);
    WriteParam(aWriter, aParam.TRR);
    WriteParam(aWriter, aParam.originAttributesSuffix);
    WriteParam(aWriter, aParam.flags);
    WriteParam(aWriter, aParam.resolveType);
  }

  static bool Read(MessageReader* aReader, paramType* aResult) {
@@ -108,8 +110,10 @@ struct ParamTraits<mozilla::net::DNSCacheEntries> {
           ReadParam(aReader, &aResult->hostaddr) &&
           ReadParam(aReader, &aResult->family) &&
           ReadParam(aReader, &aResult->expiration) &&
           ReadParam(aReader, &aResult->netInterface) &&
           ReadParam(aReader, &aResult->TRR);
           ReadParam(aReader, &aResult->TRR) &&
           ReadParam(aReader, &aResult->originAttributesSuffix) &&
           ReadParam(aReader, &aResult->flags) &&
           ReadParam(aReader, &aResult->resolveType);
  }
};

+11 −17
Original line number Diff line number Diff line
@@ -1986,20 +1986,13 @@ void nsHostResolver::GetDNSCacheEntries(nsTArray<DNSCacheEntries>* args) {
      continue;
    }

    // For now we only show A/AAAA records.
    if (!rec->IsAddrRecord()) {
      continue;
    }

    RefPtr<AddrHostRecord> addrRec = do_QueryObject(rec);
    MOZ_ASSERT(addrRec);
    if (!addrRec || !addrRec->addr_info) {
      continue;
    }

    DNSCacheEntries info;
    info.resolveType = rec->type;
    info.hostname = rec->host;
    info.family = rec->af;
    if (rec->mValidEnd.IsNull()) {
      continue;
    }
    info.expiration =
        (int64_t)(rec->mValidEnd - TimeStamp::NowLoRes()).ToSeconds();
    if (info.expiration <= 0) {
@@ -2007,7 +2000,13 @@ void nsHostResolver::GetDNSCacheEntries(nsTArray<DNSCacheEntries>* args) {
      continue;
    }

    {
    info.originAttributesSuffix = recordEntry.GetKey().originSuffix;
    info.flags = nsPrintfCString("%u|0x%x|%u|%d|%s", rec->type,
                                 static_cast<uint32_t>(rec->flags), rec->af,
                                 rec->pb, rec->mTrrServer.get());

    RefPtr<AddrHostRecord> addrRec = do_QueryObject(rec);
    if (addrRec && addrRec->addr_info) {
      MutexAutoLock lock(addrRec->addr_info_lock);
      for (const auto& addr : addrRec->addr_info->Addresses()) {
        char buf[kIPv6CStrBufSize];
@@ -2018,11 +2017,6 @@ void nsHostResolver::GetDNSCacheEntries(nsTArray<DNSCacheEntries>* args) {
      info.TRR = addrRec->addr_info->IsTRR();
    }

    info.originAttributesSuffix = recordEntry.GetKey().originSuffix;
    info.flags = nsPrintfCString("%u|0x%x|%u|%d|%s", rec->type,
                                 static_cast<uint32_t>(rec->flags), rec->af,
                                 rec->pb, rec->mTrrServer.get());

    args->AppendElement(std::move(info));
  }
}
+16 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@
namespace mozilla {
namespace net {

extern const char kProxyType_SOCKS[];

const uint32_t kHttp3VersionCount = 5;
const nsCString kHttp3Versions[] = {"h3-29"_ns, "h3-30"_ns, "h3-31"_ns,
                                    "h3-32"_ns, "h3"_ns};
@@ -1165,5 +1167,19 @@ void DisallowHTTPSRR(uint32_t& aCaps) {
  aCaps = (aCaps | NS_HTTP_DISALLOW_HTTPS_RR) & ~NS_HTTP_FORCE_WAIT_HTTP_RR;
}

ProxyDNSStrategy GetProxyDNSStrategyHelper(const char* aType, uint32_t aFlag) {
  if (!aType) {
    return ProxyDNSStrategy::ORIGIN;
  }

  if (!(aFlag & nsIProxyInfo::TRANSPARENT_PROXY_RESOLVES_HOST)) {
    if (aType == kProxyType_SOCKS) {
      return ProxyDNSStrategy::ORIGIN;
    }
  }

  return ProxyDNSStrategy::PROXY;
}

}  // namespace net
}  // namespace mozilla
Loading