diff options
author | mallinath@webrtc.org <mallinath@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-04-15 01:10:58 +0000 |
---|---|---|
committer | mallinath@webrtc.org <mallinath@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-04-15 01:10:58 +0000 |
commit | bf9b1e0e3c606f615851d9f33f4d5222acfc921e (patch) | |
tree | 2b0227736a157330bdffa57183272b2638e8846a /p2p | |
parent | 3d75191019fa48cd2a8064b9f19b88b05f65cecb (diff) | |
download | talk-bf9b1e0e3c606f615851d9f33f4d5222acfc921e.tar.gz |
In shared socket mode, use udp port as default receiver even if
stun server address is not set.
This can happen in a loopback scenarios where clients do not need
to provide any server information.
R=fischman@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/12009004
git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@5906 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'p2p')
-rw-r--r-- | p2p/base/p2ptransportchannel_unittest.cc | 37 | ||||
-rw-r--r-- | p2p/client/basicportallocator.cc | 29 |
2 files changed, 52 insertions, 14 deletions
diff --git a/p2p/base/p2ptransportchannel_unittest.cc b/p2p/base/p2ptransportchannel_unittest.cc index 566fd14..c59a342 100644 --- a/p2p/base/p2ptransportchannel_unittest.cc +++ b/p2p/base/p2ptransportchannel_unittest.cc @@ -1509,6 +1509,43 @@ TEST_F(P2PTransportChannelTest, TestIPv6Connections) { DestroyChannels(); } +// Simple test without any stun or turn server addresses. Making sure ports +// can receive and send data. +TEST_F(P2PTransportChannelTest, TestSharedSocketModeWithStunTurnAddress) { + AddAddress(0, kPublicAddrs[0]); + AddAddress(1, kPublicAddrs[1]); + + const talk_base::SocketAddress null_addr; + GetEndpoint(0)->allocator_.reset(new cricket::BasicPortAllocator( + &(GetEndpoint(0)->network_manager_), null_addr, null_addr, + null_addr, null_addr)); + GetEndpoint(1)->allocator_.reset(new cricket::BasicPortAllocator( + &(GetEndpoint(1)->network_manager_), null_addr, null_addr, + null_addr, null_addr)); + + SetAllocatorFlags(0, cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | + cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); + SetAllocatorFlags(1, cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | + cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); + + SetAllocationStepDelay(0, kMinimumStepDelay); + SetAllocationStepDelay(1, kMinimumStepDelay); + + CreateChannels(1); + + EXPECT_TRUE_WAIT(ep1_ch1()->readable() && + ep1_ch1()->writable() && + ep2_ch1()->readable() && + ep2_ch1()->writable(), + 1000); + + EXPECT_TRUE(ep1_ch1()->best_connection() && + ep2_ch1()->best_connection()); + + TestSendRecv(1); + DestroyChannels(); +} + // Test what happens when we have 2 users behind the same NAT. This can lead // to interesting behavior because the STUN server will only give out the // address of the outermost NAT. diff --git a/p2p/client/basicportallocator.cc b/p2p/client/basicportallocator.cc index 8338abe..99d53f3 100644 --- a/p2p/client/basicportallocator.cc +++ b/p2p/client/basicportallocator.cc @@ -863,20 +863,19 @@ void AllocationSequence::CreateUDPPorts() { if (port) { // If shared socket is enabled, STUN candidate will be allocated by the // UDPPort. - if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && - !IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) { - ASSERT(config_ && !config_->stun_address.IsNil()); - if (!(config_ && !config_->stun_address.IsNil())) { - LOG(LS_WARNING) - << "AllocationSequence: No STUN server configured, skipping."; - return; - } + if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { udp_port_ = port; - // If there is a TURN UDP server available, then we will use TURN port - // to get stun address, otherwise by UDP port. - // Shared socket mode is not used in GTURN mode. - if (config_ && !config_->SupportsProtocol(RELAY_TURN, PROTO_UDP)) { - port->set_server_addr(config_->stun_address); + + // If STUN is not disabled, setting stun server address to port. + if (!IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) { + // If there is a TURN UDP server available, then we will use TURN port + // to get stun address, otherwise by UDP port. + // Shared socket mode is not used in GTURN mode. + if (config_ && + !config_->SupportsProtocol(RELAY_TURN, PROTO_UDP) && + !config_->stun_address.IsNil()) { + port->set_server_addr(config_->stun_address); + } } } @@ -1059,7 +1058,9 @@ void AllocationSequence::OnReadPacket( port = udp_port_; } ASSERT(port != NULL); - port->HandleIncomingPacket(socket, data, size, remote_addr, packet_time); + if (port) { + port->HandleIncomingPacket(socket, data, size, remote_addr, packet_time); + } } void AllocationSequence::OnPortDestroyed(PortInterface* port) { |