OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 "webrtc/p2p/client/basicportallocator.h" | 11 #include "webrtc/p2p/client/basicportallocator.h" |
12 | 12 |
13 #include <algorithm> | |
13 #include <string> | 14 #include <string> |
14 #include <vector> | 15 #include <vector> |
15 | 16 |
16 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 17 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
17 #include "webrtc/p2p/base/common.h" | 18 #include "webrtc/p2p/base/common.h" |
18 #include "webrtc/p2p/base/port.h" | 19 #include "webrtc/p2p/base/port.h" |
19 #include "webrtc/p2p/base/relayport.h" | 20 #include "webrtc/p2p/base/relayport.h" |
20 #include "webrtc/p2p/base/stunport.h" | 21 #include "webrtc/p2p/base/stunport.h" |
21 #include "webrtc/p2p/base/tcpport.h" | 22 #include "webrtc/p2p/base/tcpport.h" |
22 #include "webrtc/p2p/base/turnport.h" | 23 #include "webrtc/p2p/base/turnport.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_TCP | | 64 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_TCP | |
64 PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY; | 65 PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY; |
65 | 66 |
66 // BasicPortAllocator | 67 // BasicPortAllocator |
67 BasicPortAllocator::BasicPortAllocator( | 68 BasicPortAllocator::BasicPortAllocator( |
68 rtc::NetworkManager* network_manager, | 69 rtc::NetworkManager* network_manager, |
69 rtc::PacketSocketFactory* socket_factory) | 70 rtc::PacketSocketFactory* socket_factory) |
70 : network_manager_(network_manager), | 71 : network_manager_(network_manager), |
71 socket_factory_(socket_factory), | 72 socket_factory_(socket_factory), |
72 stun_servers_() { | 73 stun_servers_() { |
73 ASSERT(socket_factory_ != NULL); | 74 ASSERT(network_manager_ != nullptr); |
75 ASSERT(socket_factory_ != nullptr); | |
74 Construct(); | 76 Construct(); |
75 } | 77 } |
76 | 78 |
77 BasicPortAllocator::BasicPortAllocator( | 79 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager) |
78 rtc::NetworkManager* network_manager) | |
79 : network_manager_(network_manager), | 80 : network_manager_(network_manager), |
80 socket_factory_(NULL), | 81 socket_factory_(nullptr), |
81 stun_servers_() { | 82 stun_servers_() { |
83 ASSERT(network_manager_ != nullptr); | |
82 Construct(); | 84 Construct(); |
83 } | 85 } |
84 | 86 |
85 BasicPortAllocator::BasicPortAllocator( | 87 BasicPortAllocator::BasicPortAllocator( |
86 rtc::NetworkManager* network_manager, | 88 rtc::NetworkManager* network_manager, |
87 rtc::PacketSocketFactory* socket_factory, | 89 rtc::PacketSocketFactory* socket_factory, |
88 const ServerAddresses& stun_servers) | 90 const ServerAddresses& stun_servers) |
89 : network_manager_(network_manager), | 91 : network_manager_(network_manager), |
90 socket_factory_(socket_factory), | 92 socket_factory_(socket_factory), |
91 stun_servers_(stun_servers) { | 93 stun_servers_(stun_servers) { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 } | 322 } |
321 // If the adapter enumeration is disabled, we'll just bind to any address | 323 // If the adapter enumeration is disabled, we'll just bind to any address |
322 // instead of specific NIC. This is to ensure the same routing for http | 324 // instead of specific NIC. This is to ensure the same routing for http |
323 // traffic by OS is also used here to avoid any local or public IP leakage | 325 // traffic by OS is also used here to avoid any local or public IP leakage |
324 // during stun process. | 326 // during stun process. |
325 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) { | 327 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) { |
326 network_manager->GetAnyAddressNetworks(networks); | 328 network_manager->GetAnyAddressNetworks(networks); |
327 } else { | 329 } else { |
328 network_manager->GetNetworks(networks); | 330 network_manager->GetNetworks(networks); |
329 } | 331 } |
332 networks->erase(std::remove_if(networks->begin(), networks->end(), | |
333 [this](rtc::Network* network) { | |
334 return allocator_->network_ignore_mask() & | |
335 network->type(); | |
336 }), | |
337 networks->end()); | |
pthatcher1
2015/12/17 22:02:03
Could be slightly more readable as:
auto filtered
| |
330 } | 338 } |
331 | 339 |
332 // For each network, see if we have a sequence that covers it already. If not, | 340 // For each network, see if we have a sequence that covers it already. If not, |
333 // create a new sequence to create the appropriate ports. | 341 // create a new sequence to create the appropriate ports. |
334 void BasicPortAllocatorSession::DoAllocate() { | 342 void BasicPortAllocatorSession::DoAllocate() { |
335 bool done_signal_needed = false; | 343 bool done_signal_needed = false; |
336 std::vector<rtc::Network*> networks; | 344 std::vector<rtc::Network*> networks; |
337 GetNetworks(&networks); | 345 GetNetworks(&networks); |
338 | 346 |
339 if (networks.empty()) { | 347 if (networks.empty()) { |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1177 ServerAddresses servers; | 1185 ServerAddresses servers; |
1178 for (size_t i = 0; i < relays.size(); ++i) { | 1186 for (size_t i = 0; i < relays.size(); ++i) { |
1179 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { | 1187 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { |
1180 servers.insert(relays[i].ports.front().address); | 1188 servers.insert(relays[i].ports.front().address); |
1181 } | 1189 } |
1182 } | 1190 } |
1183 return servers; | 1191 return servers; |
1184 } | 1192 } |
1185 | 1193 |
1186 } // namespace cricket | 1194 } // namespace cricket |
OLD | NEW |