Index: webrtc/p2p/base/turnport.cc |
diff --git a/webrtc/p2p/base/turnport.cc b/webrtc/p2p/base/turnport.cc |
index ff0c2922de28334f285e4592aefb9dc78d6db4ad..d6707a5b700231319ee8bed62eb5d4ace6feb242 100644 |
--- a/webrtc/p2p/base/turnport.cc |
+++ b/webrtc/p2p/base/turnport.cc |
@@ -291,7 +291,7 @@ void TurnPort::PrepareAddress() { |
if (!IsCompatibleAddress(server_address_.address)) { |
LOG(LS_ERROR) << "IP address family does not match: " |
<< "server: " << server_address_.address.family() |
- << "local: " << ip().family(); |
+ << " local: " << ip().family(); |
OnAllocateError(); |
return; |
} |
@@ -438,14 +438,10 @@ void TurnPort::OnAllocateMismatch() { |
++allocate_mismatch_retries_; |
} |
-Connection* TurnPort::CreateConnection(const Candidate& address, |
+Connection* TurnPort::CreateConnection(const Candidate& remote_candidate, |
CandidateOrigin origin) { |
// TURN-UDP can only connect to UDP candidates. |
- if (!SupportsProtocol(address.protocol())) { |
- return NULL; |
- } |
- |
- if (!IsCompatibleAddress(address.address())) { |
+ if (!SupportsProtocol(remote_candidate.protocol())) { |
return NULL; |
} |
@@ -454,14 +450,17 @@ Connection* TurnPort::CreateConnection(const Candidate& address, |
} |
// Create an entry, if needed, so we can get our permissions set up correctly. |
- CreateOrRefreshEntry(address.address()); |
+ CreateOrRefreshEntry(remote_candidate.address()); |
// A TURN port will have two candiates, STUN and TURN. STUN may not |
// present in all cases. If present stun candidate will be added first |
// and TURN candidate later. |
for (size_t index = 0; index < Candidates().size(); ++index) { |
- if (Candidates()[index].type() == RELAY_PORT_TYPE) { |
- ProxyConnection* conn = new ProxyConnection(this, index, address); |
+ const Candidate& local_candidate = Candidates()[index]; |
+ if (local_candidate.type() == RELAY_PORT_TYPE && |
+ AddressFamilyMatch(local_candidate, remote_candidate)) { |
+ ProxyConnection* conn = |
+ new ProxyConnection(this, index, remote_candidate); |
AddOrReplaceConnection(conn); |
return conn; |
} |
@@ -478,6 +477,12 @@ bool TurnPort::DestroyConnection(const rtc::SocketAddress& address) { |
return false; |
} |
+bool TurnPort::AddressFamilyMatch(const Candidate& local_candidate, |
+ const Candidate& remote_candidate) const { |
pthatcher1
2016/06/21 05:26:54
This can just be a static function. It doesn't ne
honghaiz3
2016/06/21 18:36:06
Just inlined it.
|
+ return local_candidate.address().family() == |
+ remote_candidate.address().family(); |
+} |
+ |
int TurnPort::SetOption(rtc::Socket::Option opt, int value) { |
if (!socket_) { |
// If socket is not created yet, these options will be applied during socket |