From 9bb6c7af5eeef694d2e7a81e9fe14dfa9d06f12d Mon Sep 17 00:00:00 2001 From: "sergeyu@chromium.org" Date: Thu, 31 Mar 2011 20:57:03 +0000 Subject: Chromoting: Disable NAT traversing BUG=None TEST=None Review URL: http://codereview.chromium.org/6785002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80070 0039d316-1c4b-4281-b951-d872f2087c98 --- remoting/jingle_glue/jingle_client.cc | 22 +++++++++++++++------- remoting/jingle_glue/jingle_client.h | 6 ++++++ 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'remoting') diff --git a/remoting/jingle_glue/jingle_client.cc b/remoting/jingle_glue/jingle_client.cc index d216ff7..538b05b 100644 --- a/remoting/jingle_glue/jingle_client.cc +++ b/remoting/jingle_glue/jingle_client.cc @@ -185,7 +185,8 @@ JingleClient::JingleClient(JingleThread* thread, talk_base::PacketSocketFactory* socket_factory, PortAllocatorSessionFactory* session_factory, Callback* callback) - : thread_(thread), + : enable_nat_traversing_(false), + thread_(thread), state_(START), initialized_(false), closed_(false), @@ -230,6 +231,11 @@ void JingleClient::DoInitialize() { new remoting::HttpPortAllocator( network_manager_.get(), socket_factory_.get(), port_allocator_session_factory_.get(), "transp2")); + if (!enable_nat_traversing_) { + port_allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_STUN | + cricket::PORTALLOCATOR_DISABLE_RELAY | + cricket::PORTALLOCATOR_DISABLE_TCP); + } // TODO(ajwong): The strategy needs a "start" command or something. Right // now, Init() implicitly starts processing events. Thus, we must have the @@ -237,12 +243,14 @@ void JingleClient::DoInitialize() { // may occur and callback into class before we're done initializing. signal_strategy_->Init(this); - jingle_info_request_.reset( - new JingleInfoRequest(signal_strategy_->CreateIqRequest())); - jingle_info_request_->SetCallback( - NewCallback(this, &JingleClient::OnJingleInfo)); - jingle_info_request_->Run( - NewRunnableMethod(this, &JingleClient::DoStartSession)); + if (enable_nat_traversing_) { + jingle_info_request_.reset( + new JingleInfoRequest(signal_strategy_->CreateIqRequest())); + jingle_info_request_->SetCallback( + NewCallback(this, &JingleClient::OnJingleInfo)); + jingle_info_request_->Run( + NewRunnableMethod(this, &JingleClient::DoStartSession)); + } } void JingleClient::DoStartSession() { diff --git a/remoting/jingle_glue/jingle_client.h b/remoting/jingle_glue/jingle_client.h index 851525e..027a8d3 100644 --- a/remoting/jingle_glue/jingle_client.h +++ b/remoting/jingle_glue/jingle_client.h @@ -197,6 +197,12 @@ class JingleClient : public base::RefCountedThreadSafe, const std::vector& relay_hosts, const std::vector& stun_hosts); + // This must be set to true to enable NAT traversal. STUN/Relay + // servers are not used when NAT traversal is disabled, so P2P + // connection will works only when both peers are on the same + // network. + bool enable_nat_traversing_; + // JingleThread used for the connection. Set in the constructor. JingleThread* thread_; -- cgit v1.1