WebRTC Bug 4865

Bug 4865: even without STUN/TURN, as long as the peer is on the open internet, the connectivity should work. This is actually a regression even for hangouts.

We need to issue the 0.0.0.0 candidate into Port::candidates_ and filter it out later. The reason is that when we create connection, we need a local candidate to match the remote candidate.

The same connection later will be updated with the prflx local candidate once the STUN ping response is received.

BUG=webrtc:4865
R=juberti@webrtc.org

Review URL: https://codereview.webrtc.org/1274013002 .

Cr-Commit-Position: refs/heads/master@{#9708}
This commit is contained in:
Guo-wei Shieh
2015-08-13 22:24:02 -07:00
parent ee8c6d3273
commit 38f8893235
5 changed files with 247 additions and 49 deletions

View File

@ -149,6 +149,41 @@ class VirtualSocketServerTest : public testing::Test {
}
}
// Test a client can bind to the any address, and all sent packets will have
// the default route as the source address. Also, it can receive packets sent
// to the default route.
void TestDefaultRoute(const IPAddress& default_route) {
ss_->SetDefaultRoute(default_route);
// Create client1 bound to the any address.
AsyncSocket* socket =
ss_->CreateAsyncSocket(default_route.family(), SOCK_DGRAM);
socket->Bind(EmptySocketAddressWithFamily(default_route.family()));
SocketAddress client1_any_addr = socket->GetLocalAddress();
EXPECT_TRUE(client1_any_addr.IsAnyIP());
TestClient* client1 = new TestClient(new AsyncUDPSocket(socket));
// Create client2 bound to the default route.
AsyncSocket* socket2 =
ss_->CreateAsyncSocket(default_route.family(), SOCK_DGRAM);
socket2->Bind(SocketAddress(default_route, 0));
SocketAddress client2_addr = socket2->GetLocalAddress();
EXPECT_FALSE(client2_addr.IsAnyIP());
TestClient* client2 = new TestClient(new AsyncUDPSocket(socket2));
// Client1 sends to client2, client2 should see the default route as
// client1's address.
SocketAddress client1_addr;
EXPECT_EQ(6, client1->SendTo("bizbaz", 6, client2_addr));
EXPECT_TRUE(client2->CheckNextPacket("bizbaz", 6, &client1_addr));
EXPECT_EQ(client1_addr,
SocketAddress(default_route, client1_any_addr.port()));
// Client2 can send back to client1's default route address.
EXPECT_EQ(3, client2->SendTo("foo", 3, client1_addr));
EXPECT_TRUE(client1->CheckNextPacket("foo", 3, &client2_addr));
}
void BasicTest(const SocketAddress& initial_addr) {
AsyncSocket* socket = ss_->CreateAsyncSocket(initial_addr.family(),
SOCK_DGRAM);
@ -791,6 +826,18 @@ TEST_F(VirtualSocketServerTest, basic_v6) {
BasicTest(ipv6_test_addr);
}
TEST_F(VirtualSocketServerTest, TestDefaultRoute_v4) {
IPAddress ipv4_default_addr(0x01020304);
TestDefaultRoute(ipv4_default_addr);
}
TEST_F(VirtualSocketServerTest, TestDefaultRoute_v6) {
IPAddress ipv6_default_addr;
EXPECT_TRUE(
IPFromString("2401:fa00:4:1000:be30:5bff:fee5:c3", &ipv6_default_addr));
TestDefaultRoute(ipv6_default_addr);
}
TEST_F(VirtualSocketServerTest, connect_v4) {
ConnectTest(kIPv4AnyAddress);
}