зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1569183: Add a proxy policy argument to NrSocketProxyConfig, and always set this config on the NrIceCtx. r=mjf
Differential Revision: https://phabricator.services.mozilla.com/D45101 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8bd10b72d0
Коммит
dbee4e76f5
|
@ -26,7 +26,8 @@ class MediaTransportParent : public dom::PMediaTransportParent {
|
|||
const RTCIceTransportPolicy& icePolicy);
|
||||
mozilla::ipc::IPCResult RecvSetProxyConfig(const dom::TabId& tabId,
|
||||
const net::LoadInfoArgs& args,
|
||||
const nsCString& alpn);
|
||||
const nsCString& alpn,
|
||||
const int& proxyPolicy);
|
||||
mozilla::ipc::IPCResult RecvEnsureProvisionalTransport(
|
||||
const string& transportId, const string& localUfrag,
|
||||
const string& localPwd, const int& componentCount);
|
||||
|
|
|
@ -48,7 +48,8 @@ parent:
|
|||
|
||||
async SetProxyConfig(TabId id,
|
||||
LoadInfoArgs args, // Does this have the id?
|
||||
nsCString alpn);
|
||||
nsCString alpn,
|
||||
int proxyPolicy);
|
||||
|
||||
async EnsureProvisionalTransport(string transportId,
|
||||
string localUfrag,
|
||||
|
|
|
@ -56,9 +56,9 @@ void WebrtcTCPSocketWrapper::AsyncOpen(
|
|||
|
||||
MOZ_ASSERT(!mWebrtcTCPSocket, "wrapper already open");
|
||||
mWebrtcTCPSocket = new WebrtcTCPSocketChild(this);
|
||||
mWebrtcTCPSocket->AsyncOpen(aHost, aPort, aConfig->GetLoadInfoArgs(),
|
||||
aConfig->GetAlpn(),
|
||||
dom::TabId(aConfig->GetTabId()));
|
||||
mWebrtcTCPSocket->AsyncOpen(
|
||||
aHost, aPort, aConfig->GetLoadInfoArgs(), aConfig->GetAlpn(),
|
||||
dom::TabId(aConfig->GetTabId()), aConfig->GetProxyPolicy());
|
||||
}
|
||||
|
||||
void WebrtcTCPSocketWrapper::SendWrite(nsTArray<uint8_t>&& aReadData) {
|
||||
|
|
|
@ -22,7 +22,8 @@ parent:
|
|||
async AsyncOpen(nsCString aHost,
|
||||
int32_t aPort,
|
||||
LoadInfoArgs aLoadInfoArgs,
|
||||
nsCString aAlpn);
|
||||
nsCString aAlpn,
|
||||
int proxyPolicy);
|
||||
async Write(uint8_t[] aWriteData);
|
||||
async Close();
|
||||
|
||||
|
|
|
@ -138,7 +138,8 @@ void WebrtcTCPSocket::CloseWithReason(nsresult aReason) {
|
|||
|
||||
nsresult WebrtcTCPSocket::Open(const nsCString& aHost, const int& aPort,
|
||||
const net::LoadInfoArgs& aArgs,
|
||||
const nsCString& aAlpn) {
|
||||
const nsCString& aAlpn,
|
||||
NrSocketProxyConfig::ProxyPolicy aProxyPolicy) {
|
||||
LOG(("WebrtcTCPSocket::Open %p\n", this));
|
||||
|
||||
if (NS_WARN_IF(mOpened)) {
|
||||
|
@ -162,10 +163,18 @@ nsresult WebrtcTCPSocket::Open(const nsCString& aHost, const int& aPort,
|
|||
|
||||
mLoadInfoArgs = aArgs;
|
||||
mAlpn = aAlpn;
|
||||
if (aProxyPolicy == NrSocketProxyConfig::kForceProxy) {
|
||||
mForceProxy = true;
|
||||
}
|
||||
|
||||
if (aProxyPolicy == NrSocketProxyConfig::kDisableProxy) {
|
||||
rv = OpenWithoutHttpProxy(nullptr);
|
||||
} else {
|
||||
// We need to figure out whether a proxy needs to be used for mURI before we
|
||||
// can start on establishing a connection.
|
||||
rv = DoProxyConfigLookup();
|
||||
}
|
||||
|
||||
// We need to figure out whether a proxy needs to be used for mURI before we
|
||||
// can start on establishing a connection.
|
||||
rv = DoProxyConfigLookup();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
CloseWithReason(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
@ -239,6 +248,10 @@ NS_IMETHODIMP WebrtcTCPSocket::OnProxyAvailable(nsICancelable* aRequest,
|
|||
}
|
||||
|
||||
nsresult WebrtcTCPSocket::OpenWithoutHttpProxy(nsIProxyInfo* aSocksProxyInfo) {
|
||||
if (NS_WARN_IF(mForceProxy && !aSocksProxyInfo)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCString host;
|
||||
int32_t port;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "mozilla/dom/ipc/IdType.h" // TabId
|
||||
#include "mozilla/dom/PContentChild.h" // LoadInfoArgs
|
||||
#include "nsIProtocolProxyCallback.h"
|
||||
#include "mtransport/nr_socket_proxy_config.h"
|
||||
|
||||
class nsISocketTransport;
|
||||
|
||||
|
@ -52,7 +53,8 @@ class WebrtcTCPSocket : public nsIHttpUpgradeListener,
|
|||
|
||||
void SetTabId(dom::TabId aTabId);
|
||||
nsresult Open(const nsCString& aHost, const int& aPort,
|
||||
const net::LoadInfoArgs& aArgs, const nsCString& aAlpn);
|
||||
const net::LoadInfoArgs& aArgs, const nsCString& aAlpn,
|
||||
NrSocketProxyConfig::ProxyPolicy aProxyPolicy);
|
||||
nsresult Write(nsTArray<uint8_t>&& aBytes);
|
||||
nsresult Close();
|
||||
|
||||
|
@ -75,6 +77,7 @@ class WebrtcTCPSocket : public nsIHttpUpgradeListener,
|
|||
net::LoadInfoArgs mLoadInfoArgs;
|
||||
nsCString mAlpn;
|
||||
bool mSsl = false;
|
||||
bool mForceProxy = false;
|
||||
|
||||
nsresult DoProxyConfigLookup();
|
||||
nsresult OpenWithHttpProxy();
|
||||
|
|
|
@ -63,10 +63,10 @@ WebrtcTCPSocketChild::~WebrtcTCPSocketChild() {
|
|||
LOG(("WebrtcTCPSocketChild::~WebrtcTCPSocketChild %p\n", this));
|
||||
}
|
||||
|
||||
void WebrtcTCPSocketChild::AsyncOpen(const nsCString& aHost, const int& aPort,
|
||||
const net::LoadInfoArgs& aArgs,
|
||||
const nsCString& aAlpn,
|
||||
const dom::TabId& aTabId) {
|
||||
void WebrtcTCPSocketChild::AsyncOpen(
|
||||
const nsCString& aHost, const int& aPort, const net::LoadInfoArgs& aArgs,
|
||||
const nsCString& aAlpn, const dom::TabId& aTabId,
|
||||
NrSocketProxyConfig::ProxyPolicy aProxyPolicy) {
|
||||
LOG(("WebrtcTCPSocketChild::AsyncOpen %p %s:%d\n", this, aHost.get(), aPort));
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread(), "not main thread");
|
||||
|
@ -85,7 +85,7 @@ void WebrtcTCPSocketChild::AsyncOpen(const nsCString& aHost, const int& aPort,
|
|||
aTabId);
|
||||
}
|
||||
|
||||
SendAsyncOpen(aHost, aPort, aArgs, aAlpn);
|
||||
SendAsyncOpen(aHost, aPort, aArgs, aAlpn, aProxyPolicy);
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "mozilla/net/PWebrtcTCPSocketChild.h"
|
||||
#include "mozilla/dom/ipc/IdType.h"
|
||||
#include "mtransport/nr_socket_proxy_config.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -30,7 +31,8 @@ class WebrtcTCPSocketChild : public PWebrtcTCPSocketChild {
|
|||
|
||||
void AsyncOpen(const nsCString& aHost, const int& aPort,
|
||||
const net::LoadInfoArgs& aArgs, const nsCString& aAlpn,
|
||||
const dom::TabId& aTabId);
|
||||
const dom::TabId& aTabId,
|
||||
NrSocketProxyConfig::ProxyPolicy aProxyPolicy);
|
||||
|
||||
void AddIPDLReference() { AddRef(); }
|
||||
void ReleaseIPDLReference() { Release(); }
|
||||
|
|
|
@ -19,12 +19,13 @@ namespace net {
|
|||
|
||||
mozilla::ipc::IPCResult WebrtcTCPSocketParent::RecvAsyncOpen(
|
||||
const nsCString& aHost, const int& aPort, const LoadInfoArgs& aLoadInfoArgs,
|
||||
const nsCString& aAlpn) {
|
||||
const nsCString& aAlpn, const int& aProxyPolicy) {
|
||||
LOG(("WebrtcTCPSocketParent::RecvAsyncOpen %p to %s:%d\n", this, aHost.get(),
|
||||
aPort));
|
||||
|
||||
MOZ_ASSERT(mChannel, "webrtc TCP socket should be non-null");
|
||||
mChannel->Open(aHost, aPort, aLoadInfoArgs, aAlpn);
|
||||
mChannel->Open(aHost, aPort, aLoadInfoArgs, aAlpn,
|
||||
static_cast<NrSocketProxyConfig::ProxyPolicy>(aProxyPolicy));
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ class WebrtcTCPSocketParent : public PWebrtcTCPSocketParent,
|
|||
mozilla::ipc::IPCResult RecvAsyncOpen(const nsCString& aHost,
|
||||
const int& aPort,
|
||||
const LoadInfoArgs& aLoadInfoArgs,
|
||||
const nsCString& aAlpn) override;
|
||||
const nsCString& aAlpn,
|
||||
const int& aProxyPolicy) override;
|
||||
|
||||
mozilla::ipc::IPCResult RecvWrite(nsTArray<uint8_t>&& aWriteData) override;
|
||||
|
||||
|
|
|
@ -16,12 +16,14 @@ class NrSocketProxyConfig::Private {
|
|||
uint64_t mTabId;
|
||||
nsCString mAlpn;
|
||||
net::LoadInfoArgs mLoadInfoArgs;
|
||||
ProxyPolicy mProxyPolicy;
|
||||
};
|
||||
|
||||
NrSocketProxyConfig::NrSocketProxyConfig(uint64_t aTabId,
|
||||
const nsCString& aAlpn,
|
||||
const net::LoadInfoArgs& aArgs)
|
||||
: mPrivate(new Private({aTabId, aAlpn, aArgs})) {}
|
||||
const net::LoadInfoArgs& aArgs,
|
||||
ProxyPolicy aProxyPolicy)
|
||||
: mPrivate(new Private({aTabId, aAlpn, aArgs, aProxyPolicy})) {}
|
||||
|
||||
NrSocketProxyConfig::NrSocketProxyConfig(NrSocketProxyConfig&& aOrig)
|
||||
: mPrivate(std::move(aOrig.mPrivate)) {}
|
||||
|
@ -38,4 +40,7 @@ const net::LoadInfoArgs& NrSocketProxyConfig::GetLoadInfoArgs() const {
|
|||
return mPrivate->mLoadInfoArgs;
|
||||
}
|
||||
|
||||
NrSocketProxyConfig::ProxyPolicy NrSocketProxyConfig::GetProxyPolicy() const {
|
||||
return mPrivate->mProxyPolicy;
|
||||
}
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -19,8 +19,11 @@ class LoadInfoArgs;
|
|||
|
||||
class NrSocketProxyConfig {
|
||||
public:
|
||||
typedef enum { kDisableProxy, kEnableProxy, kForceProxy } ProxyPolicy;
|
||||
|
||||
NrSocketProxyConfig(uint64_t aTabId, const nsCString& aAlpn,
|
||||
const net::LoadInfoArgs& aArgs);
|
||||
const net::LoadInfoArgs& aArgs, ProxyPolicy aProxyPolicy);
|
||||
|
||||
// We need to actually write the default impl ourselves, because the compiler
|
||||
// needs to know how to destroy mPrivate in case an exception is thrown, even
|
||||
// though we disable exceptions in our build.
|
||||
|
@ -31,6 +34,7 @@ class NrSocketProxyConfig {
|
|||
uint64_t GetTabId() const;
|
||||
const nsCString& GetAlpn() const;
|
||||
const net::LoadInfoArgs& GetLoadInfoArgs() const;
|
||||
ProxyPolicy GetProxyPolicy() const;
|
||||
|
||||
private:
|
||||
// LoadInfoArgs includes stuff that conflicts with nICEr includes.
|
||||
|
|
|
@ -280,7 +280,6 @@ NrIceCtx::NrIceCtx(const std::string& name, Policy policy)
|
|||
policy_(policy),
|
||||
nat_(nullptr),
|
||||
proxy_config_(nullptr),
|
||||
proxy_only_(false),
|
||||
obfuscate_host_addresses_(false) {}
|
||||
|
||||
/* static */
|
||||
|
@ -852,7 +851,7 @@ nsresult NrIceCtx::SetProxyConfig(NrSocketProxyConfig&& config) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void NrIceCtx::SetCtxFlags(bool default_route_only, bool proxy_only) {
|
||||
void NrIceCtx::SetCtxFlags(bool default_route_only) {
|
||||
ASSERT_ON_THREAD(sts_target_);
|
||||
|
||||
if (default_route_only) {
|
||||
|
@ -860,15 +859,9 @@ void NrIceCtx::SetCtxFlags(bool default_route_only, bool proxy_only) {
|
|||
} else {
|
||||
nr_ice_ctx_remove_flags(ctx_, NR_ICE_CTX_FLAGS_ONLY_DEFAULT_ADDRS);
|
||||
}
|
||||
|
||||
if (proxy_only) {
|
||||
nr_ice_ctx_add_flags(ctx_, NR_ICE_CTX_FLAGS_ONLY_PROXY);
|
||||
} else {
|
||||
nr_ice_ctx_remove_flags(ctx_, NR_ICE_CTX_FLAGS_ONLY_PROXY);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult NrIceCtx::StartGathering(bool default_route_only, bool proxy_only,
|
||||
nsresult NrIceCtx::StartGathering(bool default_route_only,
|
||||
bool obfuscate_host_addresses) {
|
||||
ASSERT_ON_THREAD(sts_target_);
|
||||
|
||||
|
@ -876,9 +869,7 @@ nsresult NrIceCtx::StartGathering(bool default_route_only, bool proxy_only,
|
|||
|
||||
SetGatheringState(ICE_CTX_GATHER_STARTED);
|
||||
|
||||
SetCtxFlags(default_route_only, proxy_only);
|
||||
|
||||
proxy_only_ = proxy_only;
|
||||
SetCtxFlags(default_route_only);
|
||||
|
||||
// This might start gathering for the first time, or again after
|
||||
// renegotiation, or might do nothing at all if gathering has already
|
||||
|
@ -1098,11 +1089,6 @@ int nr_socket_local_create(void* obj, nr_transport_addr* addr,
|
|||
|
||||
if (obj) {
|
||||
config = static_cast<NrIceCtx*>(obj)->GetProxyConfig();
|
||||
bool ctx_proxy_only = static_cast<NrIceCtx*>(obj)->proxy_only();
|
||||
|
||||
if (ctx_proxy_only && !config) {
|
||||
ABORT(R_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
r = NrSocketBase::CreateSocket(addr, &sock, config);
|
||||
|
|
|
@ -306,12 +306,10 @@ class NrIceCtx {
|
|||
return proxy_config_;
|
||||
}
|
||||
|
||||
void SetCtxFlags(bool default_route_only, bool proxy_only);
|
||||
|
||||
bool proxy_only() const { return proxy_only_; }
|
||||
void SetCtxFlags(bool default_route_only);
|
||||
|
||||
// Start ICE gathering
|
||||
nsresult StartGathering(bool default_route_only, bool proxy_only,
|
||||
nsresult StartGathering(bool default_route_only,
|
||||
bool obfuscate_host_addresses);
|
||||
|
||||
// Start checking
|
||||
|
@ -395,7 +393,6 @@ class NrIceCtx {
|
|||
Policy policy_;
|
||||
RefPtr<TestNat> nat_;
|
||||
std::shared_ptr<NrSocketProxyConfig> proxy_config_;
|
||||
bool proxy_only_;
|
||||
bool obfuscate_host_addresses_;
|
||||
std::map<std::string, std::string> obfuscated_host_addresses_;
|
||||
};
|
||||
|
|
|
@ -537,7 +537,7 @@ class IceTestPeer : public sigslot::has_slots<> {
|
|||
|
||||
test_utils_->sts_target()->Dispatch(
|
||||
WrapRunnableRet(&res, ice_ctx_, &NrIceCtx::StartGathering,
|
||||
default_route_only, false, false),
|
||||
default_route_only, false),
|
||||
NS_DISPATCH_SYNC);
|
||||
|
||||
ASSERT_TRUE(NS_SUCCEEDED(res));
|
||||
|
|
|
@ -37,7 +37,8 @@ class NrTcpSocketTest : public MtransportTest {
|
|||
void SetUp() override {
|
||||
nsCString alpn = NS_LITERAL_CSTRING("webrtc");
|
||||
std::shared_ptr<NrSocketProxyConfig> config;
|
||||
config.reset(new NrSocketProxyConfig(0, alpn, net::LoadInfoArgs()));
|
||||
config.reset(new NrSocketProxyConfig(0, alpn, net::LoadInfoArgs(),
|
||||
NrSocketProxyConfig::kForceProxy));
|
||||
// config is never used but must be non-null
|
||||
mSProxy = new NrTcpSocket(config);
|
||||
int r = nr_socket_create_int((void*)mSProxy.get(), mSProxy->vtbl(),
|
||||
|
|
|
@ -619,7 +619,7 @@ class TransportTestPeer : public sigslot::has_slots<> {
|
|||
|
||||
// Start gathering
|
||||
test_utils_->sts_target()->Dispatch(
|
||||
WrapRunnableRet(&res, ice_ctx_, &NrIceCtx::StartGathering, false, false,
|
||||
WrapRunnableRet(&res, ice_ctx_, &NrIceCtx::StartGathering, false,
|
||||
false),
|
||||
NS_DISPATCH_SYNC);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(res));
|
||||
|
|
|
@ -163,8 +163,6 @@ class MediaTransportHandlerSTS : public MediaTransportHandler,
|
|||
RefPtr<NrIceCtx> mIceCtx;
|
||||
RefPtr<NrIceResolver> mDNSResolver;
|
||||
std::map<std::string, Transport> mTransports;
|
||||
bool mProxyOnlyIfBehindProxy = false;
|
||||
bool mProxyOnly = false;
|
||||
bool mObfuscateHostAddresses = false;
|
||||
|
||||
// mDNS Support
|
||||
|
@ -430,11 +428,6 @@ nsresult MediaTransportHandlerSTS::CreateIceCtx(
|
|||
__func__);
|
||||
}
|
||||
|
||||
mProxyOnlyIfBehindProxy = Preferences::GetBool(
|
||||
"media.peerconnection.ice.proxy_only_if_behind_proxy", false);
|
||||
mProxyOnly =
|
||||
Preferences::GetBool("media.peerconnection.ice.proxy_only", false);
|
||||
|
||||
mIceCtx->SignalGatheringStateChange.connect(
|
||||
this, &MediaTransportHandlerSTS::OnGatheringStateChange);
|
||||
mIceCtx->SignalConnectionStateChange.connect(
|
||||
|
@ -657,17 +650,13 @@ void MediaTransportHandlerSTS::StartIceGathering(
|
|||
mInitPromise->Then(
|
||||
mStsThread, __func__,
|
||||
[=, self = RefPtr<MediaTransportHandlerSTS>(this)]() {
|
||||
if (mIceCtx->GetProxyConfig() && mProxyOnlyIfBehindProxy) {
|
||||
mProxyOnly = true;
|
||||
}
|
||||
|
||||
mObfuscateHostAddresses = aObfuscateHostAddresses;
|
||||
|
||||
// Belt and suspenders - in e10s mode, the call below to SetStunAddrs
|
||||
// needs to have the proper flags set on ice ctx. For non-e10s,
|
||||
// setting those flags happens in StartGathering. We could probably
|
||||
// just set them here, and only do it here.
|
||||
mIceCtx->SetCtxFlags(aDefaultRouteOnly, mProxyOnly);
|
||||
mIceCtx->SetCtxFlags(aDefaultRouteOnly);
|
||||
|
||||
if (aStunAddrs.Length()) {
|
||||
mIceCtx->SetStunAddrs(aStunAddrs);
|
||||
|
@ -675,8 +664,7 @@ void MediaTransportHandlerSTS::StartIceGathering(
|
|||
|
||||
// Start gathering, but only if there are streams
|
||||
if (!mIceCtx->GetStreams().empty()) {
|
||||
mIceCtx->StartGathering(aDefaultRouteOnly, mProxyOnly,
|
||||
aObfuscateHostAddresses);
|
||||
mIceCtx->StartGathering(aDefaultRouteOnly, aObfuscateHostAddresses);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,8 @@ void MediaTransportHandlerIPC::SetProxyConfig(
|
|||
if (mChild) {
|
||||
mChild->SendSetProxyConfig(dom::TabId(aProxyConfig.GetTabId()),
|
||||
aProxyConfig.GetLoadInfoArgs(),
|
||||
aProxyConfig.GetAlpn());
|
||||
aProxyConfig.GetAlpn(),
|
||||
aProxyConfig.GetProxyPolicy());
|
||||
}
|
||||
},
|
||||
[](const nsCString& aError) {});
|
||||
|
|
|
@ -137,8 +137,10 @@ mozilla::ipc::IPCResult MediaTransportParent::RecvCreateIceCtx(
|
|||
|
||||
mozilla::ipc::IPCResult MediaTransportParent::RecvSetProxyConfig(
|
||||
const dom::TabId& tabId, const net::LoadInfoArgs& args,
|
||||
const nsCString& alpn) {
|
||||
mImpl->mHandler->SetProxyConfig(NrSocketProxyConfig(tabId, alpn, args));
|
||||
const nsCString& alpn, const int& proxyPolicy) {
|
||||
mImpl->mHandler->SetProxyConfig(NrSocketProxyConfig(
|
||||
tabId, alpn, args,
|
||||
static_cast<NrSocketProxyConfig::ProxyPolicy>(proxyPolicy)));
|
||||
return ipc::IPCResult::Ok();
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ PeerConnectionMedia::PeerConnectionMedia(PeerConnectionImpl* parent)
|
|||
mParentName(parent->GetName()),
|
||||
mMainThread(mParent->GetMainThread()),
|
||||
mSTSThread(mParent->GetSTSThread()),
|
||||
mProxyResolveCompleted(false),
|
||||
mProxyConfig(nullptr),
|
||||
mWaitingOnProxyLookup(false),
|
||||
mForceProxy(false),
|
||||
mStunAddrsRequest(nullptr),
|
||||
mLocalAddrsCompleted(false),
|
||||
mTargetForDefaultLocalAddressLookupIsSet(false),
|
||||
|
@ -108,13 +108,22 @@ static net::ProxyConfigLookupChild* CreateActor(PeerConnectionMedia* aSelf) {
|
|||
nsresult PeerConnectionMedia::InitProxy() {
|
||||
// Allow mochitests to disable this, since mochitest configures a fake proxy
|
||||
// that serves up content.
|
||||
bool disable =
|
||||
Preferences::GetBool("media.peerconnection.disable_http_proxy", false);
|
||||
if (disable) {
|
||||
mProxyResolveCompleted = true;
|
||||
mForceProxy =
|
||||
Preferences::GetBool("media.peerconnection.ice.proxy_only", false);
|
||||
if (mForceProxy) {
|
||||
// Matter is settled, we're done.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mWaitingOnProxyLookup = Preferences::GetBool(
|
||||
"media.peerconnection.ice.proxy_only_if_behind_proxy", false);
|
||||
if (!mWaitingOnProxyLookup) {
|
||||
// We won't be forcing the use of a proxy.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We have to determine if we're behind a proxy before we can decide whether
|
||||
// to set mForceProxy.
|
||||
if (XRE_IsContentProcess()) {
|
||||
if (NS_WARN_IF(!net::gNeckoChild)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -141,7 +150,9 @@ nsresult PeerConnectionMedia::InitProxy() {
|
|||
|
||||
nsresult PeerConnectionMedia::Init() {
|
||||
nsresult rv = InitProxy();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// setup the stun local addresses IPC async call
|
||||
InitLocalAddrs();
|
||||
|
@ -415,14 +426,14 @@ nsresult PeerConnectionMedia::SetTargetForDefaultLocalAddressLookup() {
|
|||
|
||||
void PeerConnectionMedia::EnsureIceGathering(bool aDefaultRouteOnly,
|
||||
bool aObfuscateHostAddresses) {
|
||||
if (mProxyConfig) {
|
||||
auto proxyConfig = GetProxyConfig();
|
||||
if (proxyConfig) {
|
||||
// Note that this could check if PrivacyRequested() is set on the PC and
|
||||
// remove "webrtc" from the ALPN list. But that would only work if the PC
|
||||
// was constructed with a peerIdentity constraint, not when isolated
|
||||
// streams are added. If we ever need to signal to the proxy that the
|
||||
// media is isolated, then we would need to restructure this code.
|
||||
mTransportHandler->SetProxyConfig(std::move(*mProxyConfig));
|
||||
mProxyConfig.reset();
|
||||
mTransportHandler->SetProxyConfig(std::move(*proxyConfig));
|
||||
}
|
||||
|
||||
if (!mTargetForDefaultLocalAddressLookupIsSet) {
|
||||
|
@ -759,24 +770,30 @@ void PeerConnectionMedia::ProxySettingReceived(bool aProxied) {
|
|||
// PeerConnectionMedia is no longer waiting
|
||||
return;
|
||||
}
|
||||
|
||||
if (aProxied) {
|
||||
SetProxy();
|
||||
}
|
||||
|
||||
mProxyResolveCompleted = true;
|
||||
mWaitingOnProxyLookup = false;
|
||||
mForceProxy = aProxied;
|
||||
FlushIceCtxOperationQueueIfReady();
|
||||
}
|
||||
|
||||
void PeerConnectionMedia::SetProxy() {
|
||||
CSFLogInfo(LOGTAG, "%s: Had proxyinfo", __FUNCTION__);
|
||||
std::unique_ptr<NrSocketProxyConfig> PeerConnectionMedia::GetProxyConfig()
|
||||
const {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
NrSocketProxyConfig::ProxyPolicy proxyPolicy =
|
||||
NrSocketProxyConfig::kEnableProxy;
|
||||
|
||||
if (mForceProxy) {
|
||||
proxyPolicy = NrSocketProxyConfig::kForceProxy;
|
||||
} else if (Preferences::GetBool("media.peerconnection.disable_http_proxy",
|
||||
false)) {
|
||||
proxyPolicy = NrSocketProxyConfig::kDisableProxy;
|
||||
}
|
||||
|
||||
nsCString alpn = NS_LITERAL_CSTRING("webrtc,c-webrtc");
|
||||
auto browserChild = BrowserChild::GetFrom(GetWindow());
|
||||
if (!browserChild) {
|
||||
// Android doesn't have browser child apparently...
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
TabId id = browserChild->GetTabId();
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = new net::LoadInfo(
|
||||
|
@ -785,7 +802,8 @@ void PeerConnectionMedia::SetProxy() {
|
|||
Maybe<net::LoadInfoArgs> loadInfoArgs;
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
mozilla::ipc::LoadInfoToLoadInfoArgs(loadInfo, &loadInfoArgs));
|
||||
mProxyConfig.reset(new NrSocketProxyConfig(id, alpn, *loadInfoArgs));
|
||||
return std::unique_ptr<NrSocketProxyConfig>(
|
||||
new NrSocketProxyConfig(id, alpn, *loadInfoArgs, proxyPolicy));
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -140,7 +140,7 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
|
|||
private:
|
||||
void InitLocalAddrs(); // for stun local address IPC request
|
||||
nsresult InitProxy();
|
||||
void SetProxy();
|
||||
std::unique_ptr<NrSocketProxyConfig> GetProxyConfig() const;
|
||||
|
||||
class StunAddrsHandler : public net::StunAddrsListener {
|
||||
public:
|
||||
|
@ -186,7 +186,7 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
|
|||
const CandidateInfo& aCandidateInfo);
|
||||
|
||||
bool IsIceCtxReady() const {
|
||||
return mProxyResolveCompleted && mLocalAddrsCompleted;
|
||||
return !mWaitingOnProxyLookup && mLocalAddrsCompleted;
|
||||
}
|
||||
|
||||
// The parent PC
|
||||
|
@ -209,11 +209,10 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
|
|||
// gathering or start checking)
|
||||
std::vector<nsCOMPtr<nsIRunnable>> mQueuedIceCtxOperations;
|
||||
|
||||
// Used to track the state of the request.
|
||||
bool mProxyResolveCompleted;
|
||||
|
||||
// Used to track proxy existence and socket proxy configuration.
|
||||
std::unique_ptr<NrSocketProxyConfig> mProxyConfig;
|
||||
// If the "media.peerconnection.ice.proxy_only_if_behind_proxy" pref is set,
|
||||
// we need to test this before we can know what proxy policy to use.
|
||||
bool mWaitingOnProxyLookup;
|
||||
bool mForceProxy;
|
||||
|
||||
// Used to cancel incoming stun addrs response
|
||||
RefPtr<net::StunAddrsRequestChild> mStunAddrsRequest;
|
||||
|
|
Загрузка…
Ссылка в новой задаче