Commit 0e6c76d5 authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[remoting] Remove GTURN dead code

GTURN is no longer supported in M77 hosts and clients. This CL removes
some dead code I found that handles GTURN candidates.

Bug: 983282
Change-Id: I99d2b180ef000d5676df4db7865d4b2cfe9da407
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1710087
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Auto-Submit: Yuwei Huang <yuweih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#679880}
parent 0122eb58
...@@ -44,10 +44,6 @@ struct IceConfig { ...@@ -44,10 +44,6 @@ struct IceConfig {
std::vector<rtc::SocketAddress> stun_servers; std::vector<rtc::SocketAddress> stun_servers;
// Legacy GTURN relay servers.
std::vector<std::string> relay_servers;
std::string relay_token;
// Standard TURN servers // Standard TURN servers
std::vector<cricket::RelayServerConfig> turn_servers; std::vector<cricket::RelayServerConfig> turn_servers;
......
...@@ -10,35 +10,9 @@ ...@@ -10,35 +10,9 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "net/base/escape.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "remoting/protocol/network_settings.h" #include "remoting/protocol/network_settings.h"
#include "remoting/protocol/transport_context.h" #include "remoting/protocol/transport_context.h"
namespace {
typedef std::map<std::string, std::string> StringMap;
// Parses the lines in the result of the HTTP request that are of the form
// 'a=b' and returns them in a map.
StringMap ParseMap(const std::string& string) {
StringMap map;
base::StringPairs pairs;
base::SplitStringIntoKeyValuePairs(string, '=', '\n', &pairs);
for (auto& pair : pairs) {
map[pair.first] = pair.second;
}
return map;
}
const int kNumRetries = 5;
} // namespace
namespace remoting { namespace remoting {
namespace protocol { namespace protocol {
...@@ -110,11 +84,6 @@ void PortAllocatorSession::GetPortConfigurations() { ...@@ -110,11 +84,6 @@ void PortAllocatorSession::GetPortConfigurations() {
void PortAllocatorSession::OnIceConfig(const IceConfig& ice_config) { void PortAllocatorSession::OnIceConfig(const IceConfig& ice_config) {
ice_config_ = ice_config; ice_config_ = ice_config;
ConfigReady(GetPortConfiguration().release()); ConfigReady(GetPortConfiguration().release());
if (relay_enabled() && !ice_config_.relay_servers.empty() &&
!ice_config_.relay_token.empty()) {
TryCreateRelaySession();
}
} }
std::unique_ptr<cricket::PortConfiguration> std::unique_ptr<cricket::PortConfiguration>
...@@ -136,109 +105,5 @@ PortAllocatorSession::GetPortConfiguration() { ...@@ -136,109 +105,5 @@ PortAllocatorSession::GetPortConfiguration() {
return config; return config;
} }
void PortAllocatorSession::TryCreateRelaySession() {
DCHECK(!ice_config_.relay_servers.empty());
DCHECK(!ice_config_.relay_token.empty());
if (attempts_ == kNumRetries) {
LOG(ERROR) << "PortAllocator: maximum number of requests reached; "
<< "giving up on relay.";
return;
}
// Choose the next host to try.
std::string host =
ice_config_.relay_servers[attempts_ % ice_config_.relay_servers.size()];
attempts_++;
DCHECK(!username().empty());
DCHECK(!password().empty());
std::string url = "https://" + host + "/create_session?username=" +
net::EscapeUrlEncodedData(username(), false) +
"&password=" +
net::EscapeUrlEncodedData(password(), false) + "&sn=1";
net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation("CRD_relay_session_request", R"(
semantics {
sender: "Chrome Remote Desktop"
description:
"Request is sent by Chrome Remote Desktop to allocate relay "
"session. Returned relay session credentials are used over UDP to "
"connect to Google-owned relay servers, which is required for NAT "
"traversal."
trigger:
"Start of each Chrome Remote Desktop and during connection when "
"peer-to-peer transport needs to be reconnected."
data:
"A temporary authentication token issued by Google services (over "
"XMPP connection)."
destination: GOOGLE_OWNED_SERVICE
}
policy {
cookies_allowed: NO
setting:
"This feature cannot be disabled by settings. You can block Chrome "
"Remote Desktop as specified here: "
"https://support.google.com/chrome/?p=remote_desktop"
chrome_policy {
RemoteAccessHostFirewallTraversal {
policy_options {mode: MANDATORY}
RemoteAccessHostFirewallTraversal: false
}
}
}
comments:
"Above specified policy is only applicable on the host side and "
"doesn't have effect in Android and iOS client apps. The product "
"is shipped separately from Chromium, except on Chrome OS."
)");
std::unique_ptr<UrlRequest> url_request =
transport_context_->url_request_factory()->CreateUrlRequest(
UrlRequest::Type::GET, url, traffic_annotation);
url_request->AddHeader("X-Talk-Google-Relay-Auth: " +
ice_config_.relay_token);
url_request->AddHeader("X-Google-Relay-Auth: " + ice_config_.relay_token);
url_request->AddHeader("X-Stream-Type: chromoting");
url_request->Start(base::Bind(&PortAllocatorSession::OnSessionRequestResult,
base::Unretained(this)));
url_requests_.insert(std::move(url_request));
}
void PortAllocatorSession::OnSessionRequestResult(
const UrlRequest::Result& result) {
if (!result.success || result.status != net::HTTP_OK) {
LOG(WARNING) << "Received error when allocating relay session: "
<< result.status;
TryCreateRelaySession();
return;
}
StringMap map = ParseMap(result.response_body);
if (!username().empty() && map["username"] != username()) {
LOG(WARNING) << "Received unexpected username value from relay server.";
}
if (!password().empty() && map["password"] != password()) {
LOG(WARNING) << "Received unexpected password value from relay server.";
}
std::unique_ptr<cricket::PortConfiguration> config = GetPortConfiguration();
std::string relay_ip = map["relay.ip"];
std::string relay_port = map["relay.udp_port"];
unsigned relay_port_int;
if (!relay_ip.empty() && !relay_port.empty() &&
base::StringToUint(relay_port, &relay_port_int)) {
cricket::RelayServerConfig relay_config(cricket::RELAY_GTURN);
rtc::SocketAddress address(relay_ip, relay_port_int);
relay_config.ports.push_back(
cricket::ProtocolAddress(address, cricket::PROTO_UDP));
config->AddRelay(relay_config);
}
ConfigReady(config.release());
}
} // namespace protocol } // namespace protocol
} // namespace remoting } // namespace remoting
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <vector> #include <vector>
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "remoting/base/url_request.h"
#include "remoting/protocol/ice_config.h" #include "remoting/protocol/ice_config.h"
#include "remoting/protocol/transport_context.h" #include "remoting/protocol/transport_context.h"
#include "third_party/webrtc/p2p/client/basic_port_allocator.h" #include "third_party/webrtc/p2p/client/basic_port_allocator.h"
...@@ -60,24 +59,14 @@ class PortAllocatorSession : public cricket::BasicPortAllocatorSession { ...@@ -60,24 +59,14 @@ class PortAllocatorSession : public cricket::BasicPortAllocatorSession {
// Callback for TransportContext::GetIceConfig(). // Callback for TransportContext::GetIceConfig().
void OnIceConfig(const IceConfig& ice_config); void OnIceConfig(const IceConfig& ice_config);
// Creates PortConfiguration that inclues STUN and TURN servers from // Creates PortConfiguration that includes STUN and TURN servers from
// |ice_config_|. // |ice_config_|.
std::unique_ptr<cricket::PortConfiguration> GetPortConfiguration(); std::unique_ptr<cricket::PortConfiguration> GetPortConfiguration();
// Attempts to allocate relay session.
void TryCreateRelaySession();
// Result handler for UrlRequest objects in |url_requests_|.
void OnSessionRequestResult(const UrlRequest::Result& result);
scoped_refptr<TransportContext> transport_context_; scoped_refptr<TransportContext> transport_context_;
IceConfig ice_config_; IceConfig ice_config_;
int attempts_ = 0;
std::set<std::unique_ptr<UrlRequest>> url_requests_;
base::WeakPtrFactory<PortAllocatorSession> weak_factory_; base::WeakPtrFactory<PortAllocatorSession> weak_factory_;
}; };
......
...@@ -8,7 +8,7 @@ Refer to README.md for content description and update process. ...@@ -8,7 +8,7 @@ Refer to README.md for content description and update process.
--> -->
<annotations> <annotations>
<item id="CRD_relay_session_request" hash_code="24058523" type="0" content_hash_code="36997811" os_list="linux,windows" file_path="remoting/protocol/port_allocator.cc"/> <item id="CRD_relay_session_request" hash_code="24058523" type="0" deprecated="2019-07-22" content_hash_code="36997811" file_path=""/>
<item id="accounts_image_fetcher" hash_code="98658519" type="0" content_hash_code="45432230" os_list="linux,windows" file_path="components/signin/internal/identity_manager/account_fetcher_service.cc"/> <item id="accounts_image_fetcher" hash_code="98658519" type="0" content_hash_code="45432230" os_list="linux,windows" file_path="components/signin/internal/identity_manager/account_fetcher_service.cc"/>
<item id="adb_client_socket" hash_code="87775794" type="0" content_hash_code="56654828" os_list="linux,windows" file_path="chrome/browser/devtools/device/adb/adb_client_socket.cc"/> <item id="adb_client_socket" hash_code="87775794" type="0" content_hash_code="56654828" os_list="linux,windows" file_path="chrome/browser/devtools/device/adb/adb_client_socket.cc"/>
<item id="affiliation_lookup" hash_code="111904019" type="0" content_hash_code="81061452" os_list="linux,windows" file_path="components/password_manager/core/browser/android_affiliation/affiliation_fetcher.cc"/> <item id="affiliation_lookup" hash_code="111904019" type="0" content_hash_code="81061452" os_list="linux,windows" file_path="components/password_manager/core/browser/android_affiliation/affiliation_fetcher.cc"/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment