aboutsummaryrefslogtreecommitdiff
path: root/p2p
diff options
context:
space:
mode:
authorEldar Rello <elrello@microsoft.com>2020-05-14 11:59:33 +0300
committerCommit Bot <commit-bot@chromium.org>2020-05-15 11:30:20 +0000
commitfa8019c3c33a1e75b7dfc8aa8d8ad6e07c2d80a8 (patch)
treeee042cdd715d232e20595ba475dac438a8532090 /p2p
parentf9c6b68057c0f0db67d751729fa77cd23546f8f5 (diff)
downloadwebrtc-fa8019c3c33a1e75b7dfc8aa8d8ad6e07c2d80a8.tar.gz
Clear address:port in icecandidateerror for tcp servers with private IP
Bug: chromium:1072401 Change-Id: I6af81a2b2b22b5f8d7edb8fb7f66f69b866db1c6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174753 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Eldar Rello <elrello@microsoft.com> Cr-Commit-Position: refs/heads/master@{#31275}
Diffstat (limited to 'p2p')
-rw-r--r--p2p/base/turn_port.cc17
-rw-r--r--p2p/client/basic_port_allocator.cc11
-rw-r--r--p2p/client/basic_port_allocator.h1
3 files changed, 21 insertions, 8 deletions
diff --git a/p2p/base/turn_port.cc b/p2p/base/turn_port.cc
index 2e8024dcb6..4d39f207b4 100644
--- a/p2p/base/turn_port.cc
+++ b/p2p/base/turn_port.cc
@@ -367,7 +367,7 @@ void TurnPort::PrepareAddress() {
<< server_address_.address.ToSensitiveString();
if (!CreateTurnClientSocket()) {
RTC_LOG(LS_ERROR) << "Failed to create TURN client socket";
- OnAllocateError(STUN_ERROR_GLOBAL_FAILURE,
+ OnAllocateError(SERVER_NOT_REACHABLE_ERROR,
"Failed to create TURN client socket.");
return;
}
@@ -883,12 +883,17 @@ void TurnPort::OnAllocateError(int error_code, const std::string& reason) {
// port initialization. This way it will not be blocking other port
// creation.
thread()->Post(RTC_FROM_HERE, this, MSG_ALLOCATE_ERROR);
+ std::string address = GetLocalAddress().HostAsSensitiveURIString();
+ int port = GetLocalAddress().port();
+ if (server_address_.proto == PROTO_TCP &&
+ server_address_.address.IsPrivateIP()) {
+ address.clear();
+ port = 0;
+ }
SignalCandidateError(
- this,
- IceCandidateErrorEvent(GetLocalAddress().HostAsSensitiveURIString(),
- GetLocalAddress().port(),
- ReconstructedServerUrl(true /* use_hostname */),
- error_code, reason));
+ this, IceCandidateErrorEvent(
+ address, port, ReconstructedServerUrl(true /* use_hostname */),
+ error_code, reason));
}
void TurnPort::OnRefreshError() {
diff --git a/p2p/client/basic_port_allocator.cc b/p2p/client/basic_port_allocator.cc
index 8aeef9361d..bb640d9498 100644
--- a/p2p/client/basic_port_allocator.cc
+++ b/p2p/client/basic_port_allocator.cc
@@ -979,8 +979,11 @@ void BasicPortAllocatorSession::OnCandidateError(
const IceCandidateErrorEvent& event) {
RTC_DCHECK_RUN_ON(network_thread_);
RTC_DCHECK(FindPort(port));
-
- SignalCandidateError(this, event);
+ if (event.address.empty()) {
+ candidate_error_events_.push_back(event);
+ } else {
+ SignalCandidateError(this, event);
+ }
}
Port* BasicPortAllocatorSession::GetBestTurnPortForNetwork(
@@ -1140,6 +1143,10 @@ void BasicPortAllocatorSession::MaybeSignalCandidatesAllocationDone() {
RTC_LOG(LS_INFO) << "All candidates gathered for " << content_name()
<< ":" << component() << ":" << generation();
}
+ for (const auto& event : candidate_error_events_) {
+ SignalCandidateError(this, event);
+ }
+ candidate_error_events_.clear();
SignalCandidatesAllocationDone(this);
}
}
diff --git a/p2p/client/basic_port_allocator.h b/p2p/client/basic_port_allocator.h
index b9f2b2ebd2..b27016a1dc 100644
--- a/p2p/client/basic_port_allocator.h
+++ b/p2p/client/basic_port_allocator.h
@@ -269,6 +269,7 @@ class RTC_EXPORT BasicPortAllocatorSession : public PortAllocatorSession,
std::vector<PortConfiguration*> configs_;
std::vector<AllocationSequence*> sequences_;
std::vector<PortData> ports_;
+ std::vector<IceCandidateErrorEvent> candidate_error_events_;
uint32_t candidate_filter_ = CF_ALL;
// Policy on how to prune turn ports, taken from the port allocator.
webrtc::PortPrunePolicy turn_port_prune_policy_;