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