diff --git a/media/mtransport/test/webrtcproxychannel_unittest.cpp b/media/mtransport/test/webrtcproxychannel_unittest.cpp index 1f664d8cd51a..acae17fd0a3b 100644 --- a/media/mtransport/test/webrtcproxychannel_unittest.cpp +++ b/media/mtransport/test/webrtcproxychannel_unittest.cpp @@ -182,6 +182,10 @@ class FakeSocketTransportProvider : public nsISocketTransport { MOZ_ASSERT(false); return NS_OK; } + NS_IMETHOD ResolvedByTRR(bool *aResolvedByTRR) override { + MOZ_ASSERT(false); + return NS_OK; + } // nsITransport NS_IMETHOD OpenInputStream(uint32_t aFlags, uint32_t aSegmentSize, diff --git a/netwerk/base/nsISocketTransport.idl b/netwerk/base/nsISocketTransport.idl index c59ebe7a9104..ad9a58134128 100644 --- a/netwerk/base/nsISocketTransport.idl +++ b/netwerk/base/nsISocketTransport.idl @@ -314,4 +314,9 @@ interface nsISocketTransport : nsITransport * The value is set after PR_Connect is called. */ readonly attribute boolean esniUsed; + + /** + * IP address resolved using TRR. + */ + bool resolvedByTRR(); }; diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp index 6b8808b6e0f1..fb0c7281fe96 100644 --- a/netwerk/base/nsSocketTransport2.cpp +++ b/netwerk/base/nsSocketTransport2.cpp @@ -708,6 +708,7 @@ nsSocketTransport::nsSocketTransport() mInputClosed(true), mOutputClosed(true), mResolving(false), + mResolvedByTRR(false), mDNSLookupStatus(NS_OK), mDNSARequestFinished(0), mEsniQueried(false), @@ -1803,6 +1804,7 @@ bool nsSocketTransport::RecoverFromError() { // try next ip address only if past the resolver stage... if (mState == STATE_CONNECTING && mDNSRecord) { nsresult rv = mDNSRecord->GetNextAddr(SocketPort(), &mNetAddr); + mDNSRecord->IsTRR(&mResolvedByTRR); if (NS_SUCCEEDED(rv)) { SOCKET_LOG((" trying again with next ip address\n")); tryAgain = true; @@ -2096,6 +2098,7 @@ void nsSocketTransport::OnSocketEvent(uint32_t type, nsresult status, mDNSTxtRequest = nullptr; if (mDNSRecord) { mDNSRecord->GetNextAddr(SocketPort(), &mNetAddr); + mDNSRecord->IsTRR(&mResolvedByTRR); } // status contains DNS lookup status if (NS_FAILED(status)) { @@ -3523,5 +3526,11 @@ nsSocketTransport::GetEsniUsed(bool *aEsniUsed) { return NS_OK; } +NS_IMETHODIMP +nsSocketTransport::ResolvedByTRR(bool *aResolvedByTRR) { + *aResolvedByTRR = mResolvedByTRR; + return NS_OK; +} + } // namespace net } // namespace mozilla diff --git a/netwerk/base/nsSocketTransport2.h b/netwerk/base/nsSocketTransport2.h index 904a241557c0..ee7d86e82f6d 100644 --- a/netwerk/base/nsSocketTransport2.h +++ b/netwerk/base/nsSocketTransport2.h @@ -328,6 +328,7 @@ class nsSocketTransport final : public nsASocketHandler, nsCOMPtr mDNSRequest; nsCOMPtr mDNSRecord; + bool mResolvedByTRR; nsresult mDNSLookupStatus; PRIntervalTime mDNSARequestFinished; diff --git a/netwerk/dns/nsDNSService2.cpp b/netwerk/dns/nsDNSService2.cpp index ed20e02016b8..4d3cdf3346db 100644 --- a/netwerk/dns/nsDNSService2.cpp +++ b/netwerk/dns/nsDNSService2.cpp @@ -118,6 +118,7 @@ nsDNSRecord::IsTRR(bool *retval) { } return NS_OK; } + NS_IMETHODIMP nsDNSRecord::GetNextAddr(uint16_t port, NetAddr *addr) { if (mDone) { diff --git a/netwerk/protocol/http/TunnelUtils.cpp b/netwerk/protocol/http/TunnelUtils.cpp index 834e2866cbb0..231a5452c7ef 100644 --- a/netwerk/protocol/http/TunnelUtils.cpp +++ b/netwerk/protocol/http/TunnelUtils.cpp @@ -1827,6 +1827,14 @@ SocketTransportShim::GetEsniUsed(bool *aEsniUsed) { return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +SocketTransportShim::ResolvedByTRR(bool *aResolvedByTRR) { + if (mIsWebsocket) { + LOG3(("WARNING: SocketTransportShim::IsTRR %p", this)); + } + return NS_ERROR_NOT_IMPLEMENTED; +} + #define FWD_TS_PTR(fx, ts) \ NS_IMETHODIMP \ SocketTransportShim::fx(ts *arg) { return mWrapped->fx(arg); } diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 44c6c7d1cc2d..87ff4a937af1 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -8429,11 +8429,15 @@ nsHttpChannel::OnTransportStatus(nsITransport *trans, nsresult status, status == NS_NET_STATUS_WAITING_FOR) { if (mTransaction) { mTransaction->GetNetworkAddresses(mSelfAddr, mPeerAddr); + mResolvedByTRR = mTransaction->ResolvedByTRR(); } else { nsCOMPtr socketTransport = do_QueryInterface(trans); if (socketTransport) { socketTransport->GetSelfAddr(&mSelfAddr); socketTransport->GetPeerAddr(&mPeerAddr); + bool isTrr = false; + socketTransport->ResolvedByTRR(&isTrr); + mResolvedByTRR = isTrr; } } } diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index 5cc784f07d2f..64cf05e6e372 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -706,6 +706,10 @@ class nsHttpChannel final : public HttpBaseChannel, // Used to suspend any newly created pumps in mCallOnResume handler. uint32_t mAsyncResumePending : 1; + // If the request was performed to a TRR resolved IP address. + // Will be false if loaded from the cache. + uint32_t mResolvedByTRR : 1; + nsTArray mRedirectFuncStack; // Needed for accurate DNS timing diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index 99516732455d..de571e29bf8c 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -143,6 +143,7 @@ nsHttpTransaction::nsHttpTransaction() mPassedRatePacing(false), mSynchronousRatePaceRequest(false), mClassOfService(0), + mResolvedByTRR(false), m0RTTInProgress(false), mDoNotTryEarlyData(false), mEarlyDataDisposition(EARLY_NONE), @@ -591,6 +592,7 @@ void nsHttpTransaction::OnTransportStatus(nsITransport *transport, MutexAutoLock lock(mLock); socketTransport->GetSelfAddr(&mSelfAddr); socketTransport->GetPeerAddr(&mPeerAddr); + socketTransport->ResolvedByTRR(&mResolvedByTRR); } } diff --git a/netwerk/protocol/http/nsHttpTransaction.h b/netwerk/protocol/http/nsHttpTransaction.h index aa70956904aa..f06d2cc0dcc2 100644 --- a/netwerk/protocol/http/nsHttpTransaction.h +++ b/netwerk/protocol/http/nsHttpTransaction.h @@ -464,10 +464,12 @@ class nsHttpTransaction final : public nsAHttpTransaction, public: void GetNetworkAddresses(NetAddr &self, NetAddr &peer); + bool ResolvedByTRR() { return mResolvedByTRR; } private: NetAddr mSelfAddr; NetAddr mPeerAddr; + bool mResolvedByTRR; bool m0RTTInProgress; bool mDoNotTryEarlyData;