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