diff options
Diffstat (limited to 'remoting/jingle_glue')
-rw-r--r-- | remoting/jingle_glue/jingle_client.cc | 22 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_client.h | 6 |
2 files changed, 21 insertions, 7 deletions
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<JingleClient>, const std::vector<std::string>& relay_hosts, const std::vector<talk_base::SocketAddress>& 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_; |