| 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 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 default_local_ipv6_address_ = ipv6; | 350 default_local_ipv6_address_ = ipv6; |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 | 353 |
| 354 bool NetworkManagerBase::GetDefaultLocalAddress(int family, | 354 bool NetworkManagerBase::GetDefaultLocalAddress(int family, |
| 355 IPAddress* ipaddr) const { | 355 IPAddress* ipaddr) const { |
| 356 if (family == AF_INET && !default_local_ipv4_address_.IsNil()) { | 356 if (family == AF_INET && !default_local_ipv4_address_.IsNil()) { |
| 357 *ipaddr = default_local_ipv4_address_; | 357 *ipaddr = default_local_ipv4_address_; |
| 358 return true; | 358 return true; |
| 359 } else if (family == AF_INET6 && !default_local_ipv6_address_.IsNil()) { | 359 } else if (family == AF_INET6 && !default_local_ipv6_address_.IsNil()) { |
| 360 *ipaddr = default_local_ipv6_address_; | 360 Network* ipv6_network = GetNetworkFromAddress(default_local_ipv6_address_); |
| 361 if (ipv6_network) { |
| 362 // If the default ipv6 network's BestIP is different than |
| 363 // default_local_ipv6_address_, use it instead. |
| 364 // This is to prevent potential IP address leakage. See WebRTC bug 5376. |
| 365 *ipaddr = ipv6_network->GetBestIP(); |
| 366 } else { |
| 367 *ipaddr = default_local_ipv6_address_; |
| 368 } |
| 361 return true; | 369 return true; |
| 362 } | 370 } |
| 363 return false; | 371 return false; |
| 364 } | 372 } |
| 365 | 373 |
| 374 Network* NetworkManagerBase::GetNetworkFromAddress( |
| 375 const rtc::IPAddress& ip) const { |
| 376 for (Network* network : networks_) { |
| 377 const auto& ips = network->GetIPs(); |
| 378 if (std::find_if(ips.begin(), ips.end(), |
| 379 [ip](const InterfaceAddress& existing_ip) { |
| 380 return ip == static_cast<rtc::IPAddress>(existing_ip); |
| 381 }) != ips.end()) { |
| 382 return network; |
| 383 } |
| 384 } |
| 385 return nullptr; |
| 386 } |
| 387 |
| 366 BasicNetworkManager::BasicNetworkManager() | 388 BasicNetworkManager::BasicNetworkManager() |
| 367 : thread_(NULL), sent_first_update_(false), start_count_(0), | 389 : thread_(NULL), sent_first_update_(false), start_count_(0), |
| 368 ignore_non_default_routes_(false) { | 390 ignore_non_default_routes_(false) { |
| 369 } | 391 } |
| 370 | 392 |
| 371 BasicNetworkManager::~BasicNetworkManager() { | 393 BasicNetworkManager::~BasicNetworkManager() { |
| 372 } | 394 } |
| 373 | 395 |
| 374 void BasicNetworkManager::OnNetworksChanged() { | 396 void BasicNetworkManager::OnNetworksChanged() { |
| 375 LOG(LS_VERBOSE) << "Network change was observed at the network manager"; | 397 LOG(LS_VERBOSE) << "Network change was observed at the network manager"; |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 std::stringstream ss; | 938 std::stringstream ss; |
| 917 // Print out the first space-terminated token of the network desc, plus | 939 // Print out the first space-terminated token of the network desc, plus |
| 918 // the IP address. | 940 // the IP address. |
| 919 ss << "Net[" << description_.substr(0, description_.find(' ')) | 941 ss << "Net[" << description_.substr(0, description_.find(' ')) |
| 920 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ | 942 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ |
| 921 << ":" << AdapterTypeToString(type_) << "]"; | 943 << ":" << AdapterTypeToString(type_) << "]"; |
| 922 return ss.str(); | 944 return ss.str(); |
| 923 } | 945 } |
| 924 | 946 |
| 925 } // namespace rtc | 947 } // namespace rtc |
| OLD | NEW |