OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <memory> | 12 #include <memory> |
13 | 13 |
14 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | |
15 #include "webrtc/p2p/base/p2pconstants.h" | |
16 #include "webrtc/p2p/base/p2ptransportchannel.h" | |
17 #include "webrtc/p2p/base/testrelayserver.h" | |
18 #include "webrtc/p2p/base/teststunserver.h" | |
19 #include "webrtc/p2p/base/testturnserver.h" | |
20 #include "webrtc/p2p/client/basicportallocator.h" | |
21 #include "webrtc/base/fakeclock.h" | 14 #include "webrtc/base/fakeclock.h" |
22 #include "webrtc/base/fakenetwork.h" | 15 #include "webrtc/base/fakenetwork.h" |
23 #include "webrtc/base/firewallsocketserver.h" | 16 #include "webrtc/base/firewallsocketserver.h" |
24 #include "webrtc/base/gunit.h" | 17 #include "webrtc/base/gunit.h" |
25 #include "webrtc/base/helpers.h" | 18 #include "webrtc/base/helpers.h" |
26 #include "webrtc/base/ipaddress.h" | 19 #include "webrtc/base/ipaddress.h" |
27 #include "webrtc/base/logging.h" | 20 #include "webrtc/base/logging.h" |
28 #include "webrtc/base/natserver.h" | 21 #include "webrtc/base/natserver.h" |
29 #include "webrtc/base/natsocketfactory.h" | 22 #include "webrtc/base/natsocketfactory.h" |
| 23 #include "webrtc/base/nethelpers.h" |
30 #include "webrtc/base/network.h" | 24 #include "webrtc/base/network.h" |
31 #include "webrtc/base/physicalsocketserver.h" | 25 #include "webrtc/base/physicalsocketserver.h" |
32 #include "webrtc/base/socketaddress.h" | 26 #include "webrtc/base/socketaddress.h" |
33 #include "webrtc/base/ssladapter.h" | 27 #include "webrtc/base/ssladapter.h" |
34 #include "webrtc/base/thread.h" | 28 #include "webrtc/base/thread.h" |
35 #include "webrtc/base/virtualsocketserver.h" | 29 #include "webrtc/base/virtualsocketserver.h" |
| 30 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
| 31 #include "webrtc/p2p/base/p2pconstants.h" |
| 32 #include "webrtc/p2p/base/p2ptransportchannel.h" |
| 33 #include "webrtc/p2p/base/testrelayserver.h" |
| 34 #include "webrtc/p2p/base/teststunserver.h" |
| 35 #include "webrtc/p2p/base/testturnserver.h" |
| 36 #include "webrtc/p2p/client/basicportallocator.h" |
36 | 37 |
37 using rtc::IPAddress; | 38 using rtc::IPAddress; |
38 using rtc::SocketAddress; | 39 using rtc::SocketAddress; |
39 using rtc::Thread; | 40 using rtc::Thread; |
40 | 41 |
| 42 #define MAYBE_SKIP_IPV4 \ |
| 43 if (!rtc::HasIPv4Enabled()) { \ |
| 44 LOG(LS_INFO) << "No IPv4... skipping"; \ |
| 45 return; \ |
| 46 } |
| 47 |
41 static const SocketAddress kAnyAddr("0.0.0.0", 0); | 48 static const SocketAddress kAnyAddr("0.0.0.0", 0); |
42 static const SocketAddress kClientAddr("11.11.11.11", 0); | 49 static const SocketAddress kClientAddr("11.11.11.11", 0); |
43 static const SocketAddress kClientAddr2("22.22.22.22", 0); | 50 static const SocketAddress kClientAddr2("22.22.22.22", 0); |
44 static const SocketAddress kLoopbackAddr("127.0.0.1", 0); | 51 static const SocketAddress kLoopbackAddr("127.0.0.1", 0); |
45 static const SocketAddress kPrivateAddr("192.168.1.11", 0); | 52 static const SocketAddress kPrivateAddr("192.168.1.11", 0); |
46 static const SocketAddress kPrivateAddr2("192.168.1.12", 0); | 53 static const SocketAddress kPrivateAddr2("192.168.1.12", 0); |
47 static const SocketAddress kClientIPv6Addr("2401:fa00:4:1000:be30:5bff:fee5:c3", | 54 static const SocketAddress kClientIPv6Addr("2401:fa00:4:1000:be30:5bff:fee5:c3", |
48 0); | 55 0); |
49 static const SocketAddress kClientIPv6Addr2( | 56 static const SocketAddress kClientIPv6Addr2( |
50 "2401:fa00:4:2000:be30:5bff:fee5:c3", | 57 "2401:fa00:4:2000:be30:5bff:fee5:c3", |
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 TestEachInterfaceHasItsOwnTurnPorts(); | 1523 TestEachInterfaceHasItsOwnTurnPorts(); |
1517 } | 1524 } |
1518 | 1525 |
1519 // Testing DNS resolve for the TURN server, this will test AllocationSequence | 1526 // Testing DNS resolve for the TURN server, this will test AllocationSequence |
1520 // handling the unresolved address signal from TurnPort. | 1527 // handling the unresolved address signal from TurnPort. |
1521 // TODO(pthatcher): Make this test work with SIMULATED_WAIT. It | 1528 // TODO(pthatcher): Make this test work with SIMULATED_WAIT. It |
1522 // appears that it doesn't currently because of the DNS look up not | 1529 // appears that it doesn't currently because of the DNS look up not |
1523 // using the fake clock. | 1530 // using the fake clock. |
1524 TEST_F(BasicPortAllocatorTestWithRealClock, | 1531 TEST_F(BasicPortAllocatorTestWithRealClock, |
1525 TestSharedSocketWithServerAddressResolve) { | 1532 TestSharedSocketWithServerAddressResolve) { |
| 1533 // This test relies on a real query for "localhost", so it won't work on an |
| 1534 // IPv6-only machine. |
| 1535 MAYBE_SKIP_IPV4; |
1526 turn_server_.AddInternalSocket(rtc::SocketAddress("127.0.0.1", 3478), | 1536 turn_server_.AddInternalSocket(rtc::SocketAddress("127.0.0.1", 3478), |
1527 PROTO_UDP); | 1537 PROTO_UDP); |
1528 AddInterface(kClientAddr); | 1538 AddInterface(kClientAddr); |
1529 allocator_.reset(new BasicPortAllocator(&network_manager_)); | 1539 allocator_.reset(new BasicPortAllocator(&network_manager_)); |
1530 RelayServerConfig turn_server(RELAY_TURN); | 1540 RelayServerConfig turn_server(RELAY_TURN); |
1531 RelayCredentials credentials(kTurnUsername, kTurnPassword); | 1541 RelayCredentials credentials(kTurnUsername, kTurnPassword); |
1532 turn_server.credentials = credentials; | 1542 turn_server.credentials = credentials; |
1533 turn_server.ports.push_back( | 1543 turn_server.ports.push_back( |
1534 ProtocolAddress(rtc::SocketAddress("localhost", 3478), PROTO_UDP)); | 1544 ProtocolAddress(rtc::SocketAddress("localhost", 3478), PROTO_UDP)); |
1535 allocator_->AddTurnServer(turn_server); | 1545 allocator_->AddTurnServer(turn_server); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1893 for (const Candidate& candidate : candidates) { | 1903 for (const Candidate& candidate : candidates) { |
1894 // Expect only relay candidates now that the filter is applied. | 1904 // Expect only relay candidates now that the filter is applied. |
1895 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); | 1905 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); |
1896 // Expect that the raddr is emptied due to the CF_RELAY filter. | 1906 // Expect that the raddr is emptied due to the CF_RELAY filter. |
1897 EXPECT_EQ(candidate.related_address(), | 1907 EXPECT_EQ(candidate.related_address(), |
1898 rtc::EmptySocketAddressWithFamily(candidate.address().family())); | 1908 rtc::EmptySocketAddressWithFamily(candidate.address().family())); |
1899 } | 1909 } |
1900 } | 1910 } |
1901 | 1911 |
1902 } // namespace cricket | 1912 } // namespace cricket |
OLD | NEW |