| 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 if ((filter & CF_REFLEXIVE) && !c.address().IsPrivateIP()) { | 555 if ((filter & CF_REFLEXIVE) && !c.address().IsPrivateIP()) { |
| 556 // We allow host candidates if the filter allows server-reflexive | 556 // We allow host candidates if the filter allows server-reflexive |
| 557 // candidates and the candidate is a public IP. Because we don't generate | 557 // candidates and the candidate is a public IP. Because we don't generate |
| 558 // server-reflexive candidates if they have the same IP as the host | 558 // server-reflexive candidates if they have the same IP as the host |
| 559 // candidate (i.e. when the host candidate is a public IP), filtering to | 559 // candidate (i.e. when the host candidate is a public IP), filtering to |
| 560 // only server-reflexive candidates won't work right when the host | 560 // only server-reflexive candidates won't work right when the host |
| 561 // candidates have public IPs. | 561 // candidates have public IPs. |
| 562 return true; | 562 return true; |
| 563 } | 563 } |
| 564 | 564 |
| 565 // If PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE is specified and it's |
| 566 // loopback address, we should allow it as it's for demo page connectivity |
| 567 // when no TURN/STUN specified. |
| 568 if (c.address().IsLoopbackIP() && |
| 569 (flags() & PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE) != 0) { |
| 570 return true; |
| 571 } |
| 572 |
| 565 // This is just to prevent the case when binding to any address (all 0s), if | 573 // This is just to prevent the case when binding to any address (all 0s), if |
| 566 // somehow the host candidate address is not all 0s. Either because local | 574 // somehow the host candidate address is not all 0s. Either because local |
| 567 // installed proxy changes the address or a packet has been sent for any | 575 // installed proxy changes the address or a packet has been sent for any |
| 568 // reason before getsockname is called. | 576 // reason before getsockname is called. |
| 569 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) { | 577 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) { |
| 570 LOG(LS_WARNING) << "Received non-0 host address: " | 578 LOG(LS_WARNING) << "Received non-0 host address: " |
| 571 << c.address().ToString() | 579 << c.address().ToString() |
| 572 << " when adapter enumeration is disabled"; | 580 << " when adapter enumeration is disabled"; |
| 573 return false; | 581 return false; |
| 574 } | 582 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 | 825 |
| 818 void AllocationSequence::CreateUDPPorts() { | 826 void AllocationSequence::CreateUDPPorts() { |
| 819 if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP)) { | 827 if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP)) { |
| 820 LOG(LS_VERBOSE) << "AllocationSequence: UDP ports disabled, skipping."; | 828 LOG(LS_VERBOSE) << "AllocationSequence: UDP ports disabled, skipping."; |
| 821 return; | 829 return; |
| 822 } | 830 } |
| 823 | 831 |
| 824 // TODO(mallinath) - Remove UDPPort creating socket after shared socket | 832 // TODO(mallinath) - Remove UDPPort creating socket after shared socket |
| 825 // is enabled completely. | 833 // is enabled completely. |
| 826 UDPPort* port = NULL; | 834 UDPPort* port = NULL; |
| 835 bool emit_localhost_for_anyaddress = |
| 836 IsFlagSet(PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); |
| 827 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) { | 837 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) { |
| 828 port = UDPPort::Create(session_->network_thread(), | 838 port = UDPPort::Create( |
| 829 session_->socket_factory(), network_, | 839 session_->network_thread(), session_->socket_factory(), network_, |
| 830 udp_socket_.get(), | 840 udp_socket_.get(), session_->username(), session_->password(), |
| 831 session_->username(), session_->password(), | 841 session_->allocator()->origin(), emit_localhost_for_anyaddress); |
| 832 session_->allocator()->origin()); | |
| 833 } else { | 842 } else { |
| 834 port = UDPPort::Create(session_->network_thread(), | 843 port = UDPPort::Create( |
| 835 session_->socket_factory(), | 844 session_->network_thread(), session_->socket_factory(), network_, ip_, |
| 836 network_, ip_, | 845 session_->allocator()->min_port(), session_->allocator()->max_port(), |
| 837 session_->allocator()->min_port(), | 846 session_->username(), session_->password(), |
| 838 session_->allocator()->max_port(), | 847 session_->allocator()->origin(), emit_localhost_for_anyaddress); |
| 839 session_->username(), session_->password(), | |
| 840 session_->allocator()->origin()); | |
| 841 } | 848 } |
| 842 | 849 |
| 843 if (port) { | 850 if (port) { |
| 844 // If shared socket is enabled, STUN candidate will be allocated by the | 851 // If shared socket is enabled, STUN candidate will be allocated by the |
| 845 // UDPPort. | 852 // UDPPort. |
| 846 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { | 853 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { |
| 847 udp_port_ = port; | 854 udp_port_ = port; |
| 848 port->SignalDestroyed.connect(this, &AllocationSequence::OnPortDestroyed); | 855 port->SignalDestroyed.connect(this, &AllocationSequence::OnPortDestroyed); |
| 849 | 856 |
| 850 // If STUN is not disabled, setting stun server address to port. | 857 // If STUN is not disabled, setting stun server address to port. |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 ServerAddresses servers; | 1133 ServerAddresses servers; |
| 1127 for (size_t i = 0; i < relays.size(); ++i) { | 1134 for (size_t i = 0; i < relays.size(); ++i) { |
| 1128 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { | 1135 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { |
| 1129 servers.insert(relays[i].ports.front().address); | 1136 servers.insert(relays[i].ports.front().address); |
| 1130 } | 1137 } |
| 1131 } | 1138 } |
| 1132 return servers; | 1139 return servers; |
| 1133 } | 1140 } |
| 1134 | 1141 |
| 1135 } // namespace cricket | 1142 } // namespace cricket |
| OLD | NEW |