From 2e10bf25d730018a0e6d93d80a4f217da9831679 Mon Sep 17 00:00:00 2001 From: Kershaw Chang Date: Fri, 21 Aug 2020 18:59:03 +0000 Subject: [PATCH] Bug 1652655 - P1: Sort HTTPSSVC records, r=dragana,necko-reviewers Differential Revision: https://phabricator.services.mozilla.com/D85121 --- netwerk/dns/HTTPSSVC.h | 3 +++ netwerk/dns/TRR.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/netwerk/dns/HTTPSSVC.h b/netwerk/dns/HTTPSSVC.h index 7c8184dd40c2..de757539bdda 100644 --- a/netwerk/dns/HTTPSSVC.h +++ b/netwerk/dns/HTTPSSVC.h @@ -82,6 +82,9 @@ struct SVCB { mSvcDomainName == aOther.mSvcDomainName && mSvcFieldValue == aOther.mSvcFieldValue; } + bool operator<(const SVCB& aOther) const { + return mSvcFieldPriority < aOther.mSvcFieldPriority; + } uint16_t mSvcFieldPriority = 0; nsCString mSvcDomainName; CopyableTArray mSvcFieldValue; diff --git a/netwerk/dns/TRR.cpp b/netwerk/dns/TRR.cpp index 2933f8e5153d..3ab663c86a66 100644 --- a/netwerk/dns/TRR.cpp +++ b/netwerk/dns/TRR.cpp @@ -1197,6 +1197,16 @@ nsresult TRR::DohDecode(nsCString& aHost) { LOG(("TRR: No entries were stored!\n")); return NS_ERROR_FAILURE; } + + // https://tools.ietf.org/html/draft-ietf-dnsop-svcb-httpssvc-03#page-14 + // If one or more SVCB records of ServiceForm SvcRecordType are returned for + // HOST, clients should select the highest-priority option with acceptable + // parameters. + if (mResult.is()) { + auto& results = mResult.as(); + results.Sort(); + } + return NS_OK; }