Chromium Code Reviews| Index: webrtc/p2p/base/stunport.cc |
| diff --git a/webrtc/p2p/base/stunport.cc b/webrtc/p2p/base/stunport.cc |
| index 1598fe43cea80a91c98b897cf48cb19c07ef2638..de006aa35ba7ae613c713cb1d591b5a6349f6a75 100644 |
| --- a/webrtc/p2p/base/stunport.cc |
| +++ b/webrtc/p2p/base/stunport.cc |
| @@ -13,6 +13,7 @@ |
| #include "webrtc/p2p/base/common.h" |
| #include "webrtc/p2p/base/portallocator.h" |
| #include "webrtc/p2p/base/stun.h" |
| +#include "webrtc/base/checks.h" |
| #include "webrtc/base/common.h" |
| #include "webrtc/base/helpers.h" |
| #include "webrtc/base/ipaddress.h" |
| @@ -166,15 +167,19 @@ UDPPort::UDPPort(rtc::Thread* thread, |
| const std::string& username, |
| const std::string& password, |
| const std::string& origin, |
| - bool emit_localhost_for_anyaddress) |
| - : Port(thread, factory, network, socket->GetLocalAddress().ipaddr(), |
| - username, password), |
| + bool emit_local_for_anyaddress) |
| + : Port(thread, |
| + factory, |
| + network, |
| + socket->GetLocalAddress().ipaddr(), |
| + username, |
| + password), |
| requests_(thread), |
| socket_(socket), |
| error_(0), |
| ready_(false), |
| stun_keepalive_delay_(KEEPALIVE_DELAY), |
| - emit_localhost_for_anyaddress_(emit_localhost_for_anyaddress) { |
| + emit_local_for_anyaddress_(emit_local_for_anyaddress) { |
| requests_.set_origin(origin); |
| } |
| @@ -187,7 +192,7 @@ UDPPort::UDPPort(rtc::Thread* thread, |
| const std::string& username, |
| const std::string& password, |
| const std::string& origin, |
| - bool emit_localhost_for_anyaddress) |
| + bool emit_local_for_anyaddress) |
| : Port(thread, |
| LOCAL_PORT_TYPE, |
| factory, |
| @@ -202,7 +207,7 @@ UDPPort::UDPPort(rtc::Thread* thread, |
| error_(0), |
| ready_(false), |
| stun_keepalive_delay_(KEEPALIVE_DELAY), |
| - emit_localhost_for_anyaddress_(emit_localhost_for_anyaddress) { |
| + emit_local_for_anyaddress_(emit_local_for_anyaddress) { |
| requests_.set_origin(origin); |
| } |
| @@ -295,11 +300,16 @@ void UDPPort::OnLocalAddressReady(rtc::AsyncPacketSocket* socket, |
| const rtc::SocketAddress& address) { |
| // When adapter enumeration is disabled and binding to the any address, the |
| // loopback address will be issued as a candidate instead if |
| - // |emit_localhost_for_anyaddress| is true. This is to allow connectivity on |
| + // |emit_local_for_anyaddress| is true. This is to allow connectivity on |
| // demo pages without STUN/TURN to work. |
| rtc::SocketAddress addr = address; |
| - if (addr.IsAnyIP() && emit_localhost_for_anyaddress_) { |
| - addr.SetIP(rtc::GetLoopbackIP(addr.family())); |
| + if (addr.IsAnyIP() && emit_local_for_anyaddress_ && |
| + Network()->default_address_provider()) { |
|
pthatcher1
2015/11/10 18:52:34
Actually, not it seems like it would make sense to
guoweis_webrtc
2015/11/10 20:37:29
should not be a network property.
|
| + rtc::IPAddress default_address; |
| + bool result = Network()->default_address_provider()->GetDefaultLocalAddress( |
| + address.family(), &default_address); |
| + RTC_DCHECK(result && !default_address.IsNil()); |
| + addr.SetIP(default_address); |
| } |
| AddAddress(addr, addr, rtc::SocketAddress(), UDP_PROTOCOL_NAME, "", "", |
| @@ -415,6 +425,15 @@ void UDPPort::OnStunBindingRequestSucceeded( |
| !HasCandidateWithAddress(stun_reflected_addr)) { |
| rtc::SocketAddress related_address = socket_->GetLocalAddress(); |
| + if (related_address.IsAnyIP() && emit_local_for_anyaddress_ && |
| + Network()->default_address_provider()) { |
| + rtc::IPAddress default_address; |
| + bool result = |
| + Network()->default_address_provider()->GetDefaultLocalAddress( |
| + related_address.family(), &default_address); |
| + RTC_DCHECK(result && !default_address.IsNil()); |
| + related_address.SetIP(default_address); |
|
pthatcher1
2015/11/10 18:52:34
Seems like we have duplicate logic here. Can we j
guoweis_webrtc
2015/11/10 20:37:30
Done.
|
| + } |
| if (!(candidate_filter() & CF_HOST)) { |
| // If candidate filter doesn't have CF_HOST specified, empty raddr to |
| // avoid local address leakage. |