Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: trunk/src/remoting/host/remoting_me2me_host.cc

Issue 268483003: Revert 267234 "New policies: enable/disable relay; port range" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 18 matching lines...) Expand all
29 #include "media/base/media.h" 29 #include "media/base/media.h"
30 #include "net/base/network_change_notifier.h" 30 #include "net/base/network_change_notifier.h"
31 #include "net/socket/client_socket_factory.h" 31 #include "net/socket/client_socket_factory.h"
32 #include "net/socket/ssl_server_socket.h" 32 #include "net/socket/ssl_server_socket.h"
33 #include "net/url_request/url_fetcher.h" 33 #include "net/url_request/url_fetcher.h"
34 #include "remoting/base/auto_thread_task_runner.h" 34 #include "remoting/base/auto_thread_task_runner.h"
35 #include "remoting/base/breakpad.h" 35 #include "remoting/base/breakpad.h"
36 #include "remoting/base/constants.h" 36 #include "remoting/base/constants.h"
37 #include "remoting/base/logging.h" 37 #include "remoting/base/logging.h"
38 #include "remoting/base/rsa_key_pair.h" 38 #include "remoting/base/rsa_key_pair.h"
39 #include "remoting/base/util.h"
40 #include "remoting/host/branding.h" 39 #include "remoting/host/branding.h"
41 #include "remoting/host/chromoting_host.h" 40 #include "remoting/host/chromoting_host.h"
42 #include "remoting/host/chromoting_host_context.h" 41 #include "remoting/host/chromoting_host_context.h"
43 #include "remoting/host/chromoting_messages.h" 42 #include "remoting/host/chromoting_messages.h"
44 #include "remoting/host/config_file_watcher.h" 43 #include "remoting/host/config_file_watcher.h"
45 #include "remoting/host/config_watcher.h" 44 #include "remoting/host/config_watcher.h"
46 #include "remoting/host/desktop_environment.h" 45 #include "remoting/host/desktop_environment.h"
47 #include "remoting/host/desktop_session_connector.h" 46 #include "remoting/host/desktop_session_connector.h"
48 #include "remoting/host/dns_blackhole_checker.h" 47 #include "remoting/host/dns_blackhole_checker.h"
49 #include "remoting/host/heartbeat_sender.h" 48 #include "remoting/host/heartbeat_sender.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 void ShutdownOnUiThread(); 220 void ShutdownOnUiThread();
222 221
223 // Applies the host config, returning true if successful. 222 // Applies the host config, returning true if successful.
224 bool ApplyConfig(scoped_ptr<JsonHostConfig> config); 223 bool ApplyConfig(scoped_ptr<JsonHostConfig> config);
225 224
226 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); 225 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies);
227 bool OnHostDomainPolicyUpdate(const std::string& host_domain); 226 bool OnHostDomainPolicyUpdate(const std::string& host_domain);
228 bool OnUsernamePolicyUpdate(bool curtain_required, 227 bool OnUsernamePolicyUpdate(bool curtain_required,
229 bool username_match_required); 228 bool username_match_required);
230 bool OnNatPolicyUpdate(bool nat_traversal_enabled); 229 bool OnNatPolicyUpdate(bool nat_traversal_enabled);
231 bool OnRelayPolicyUpdate(bool allow_relay);
232 bool OnUdpPortPolicyUpdate(const std::string& udp_port_range);
233 void OnCurtainPolicyUpdate(bool curtain_required); 230 void OnCurtainPolicyUpdate(bool curtain_required);
234 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); 231 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix);
235 bool OnHostTokenUrlPolicyUpdate( 232 bool OnHostTokenUrlPolicyUpdate(
236 const GURL& token_url, 233 const GURL& token_url,
237 const GURL& token_validation_url, 234 const GURL& token_validation_url,
238 const std::string& token_validation_cert_issuer); 235 const std::string& token_validation_cert_issuer);
239 bool OnPairingPolicyUpdate(bool pairing_enabled); 236 bool OnPairingPolicyUpdate(bool pairing_enabled);
240 bool OnGnubbyAuthPolicyUpdate(bool enable_gnubby_auth); 237 bool OnGnubbyAuthPolicyUpdate(bool enable_gnubby_auth);
241 238
242 void StartHost(); 239 void StartHost();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 280
284 std::string host_id_; 281 std::string host_id_;
285 protocol::SharedSecretHash host_secret_hash_; 282 protocol::SharedSecretHash host_secret_hash_;
286 scoped_refptr<RsaKeyPair> key_pair_; 283 scoped_refptr<RsaKeyPair> key_pair_;
287 std::string oauth_refresh_token_; 284 std::string oauth_refresh_token_;
288 std::string serialized_config_; 285 std::string serialized_config_;
289 std::string host_owner_; 286 std::string host_owner_;
290 bool use_service_account_; 287 bool use_service_account_;
291 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; 288 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_;
292 bool allow_nat_traversal_; 289 bool allow_nat_traversal_;
293 bool allow_relay_;
294 int min_udp_port_;
295 int max_udp_port_;
296 std::string talkgadget_prefix_; 290 std::string talkgadget_prefix_;
297 bool allow_pairing_; 291 bool allow_pairing_;
298 292
299 bool curtain_required_; 293 bool curtain_required_;
300 ThirdPartyAuthConfig third_party_auth_config_; 294 ThirdPartyAuthConfig third_party_auth_config_;
301 bool enable_gnubby_auth_; 295 bool enable_gnubby_auth_;
302 296
303 scoped_ptr<OAuthTokenGetter> oauth_token_getter_; 297 scoped_ptr<OAuthTokenGetter> oauth_token_getter_;
304 scoped_ptr<XmppSignalStrategy> signal_strategy_; 298 scoped_ptr<XmppSignalStrategy> signal_strategy_;
305 scoped_ptr<SignalingConnector> signaling_connector_; 299 scoped_ptr<SignalingConnector> signaling_connector_;
(...skipping 17 matching lines...) Expand all
323 317
324 scoped_ptr<PairingRegistry::Delegate> pairing_registry_delegate_; 318 scoped_ptr<PairingRegistry::Delegate> pairing_registry_delegate_;
325 }; 319 };
326 320
327 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, 321 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context,
328 int* exit_code_out) 322 int* exit_code_out)
329 : context_(context.Pass()), 323 : context_(context.Pass()),
330 state_(HOST_INITIALIZING), 324 state_(HOST_INITIALIZING),
331 use_service_account_(false), 325 use_service_account_(false),
332 allow_nat_traversal_(true), 326 allow_nat_traversal_(true),
333 allow_relay_(true),
334 min_udp_port_(0),
335 max_udp_port_(0),
336 allow_pairing_(true), 327 allow_pairing_(true),
337 curtain_required_(false), 328 curtain_required_(false),
338 enable_gnubby_auth_(false), 329 enable_gnubby_auth_(false),
339 #if defined(REMOTING_MULTI_PROCESS) 330 #if defined(REMOTING_MULTI_PROCESS)
340 desktop_session_connector_(NULL), 331 desktop_session_connector_(NULL),
341 #endif // defined(REMOTING_MULTI_PROCESS) 332 #endif // defined(REMOTING_MULTI_PROCESS)
342 self_(this), 333 self_(this),
343 exit_code_out_(exit_code_out), 334 exit_code_out_(exit_code_out),
344 signal_parent_(false) { 335 signal_parent_(false) {
345 StartOnUiThread(); 336 StartOnUiThread();
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 } 829 }
839 if (policies->GetBoolean( 830 if (policies->GetBoolean(
840 policy_hack::PolicyWatcher::kHostMatchUsernamePolicyName, 831 policy_hack::PolicyWatcher::kHostMatchUsernamePolicyName,
841 &bool_value)) { 832 &bool_value)) {
842 restart_required |= OnUsernamePolicyUpdate(curtain_required, bool_value); 833 restart_required |= OnUsernamePolicyUpdate(curtain_required, bool_value);
843 } 834 }
844 if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName, 835 if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName,
845 &bool_value)) { 836 &bool_value)) {
846 restart_required |= OnNatPolicyUpdate(bool_value); 837 restart_required |= OnNatPolicyUpdate(bool_value);
847 } 838 }
848 if (policies->GetBoolean(policy_hack::PolicyWatcher::kRelayPolicyName,
849 &bool_value)) {
850 restart_required |= OnRelayPolicyUpdate(bool_value);
851 }
852 std::string udp_port_range;
853 if (policies->GetString(policy_hack::PolicyWatcher::kUdpPortRangePolicyName,
854 &udp_port_range)) {
855 restart_required |= OnUdpPortPolicyUpdate(udp_port_range);
856 }
857
858 if (policies->GetString( 839 if (policies->GetString(
859 policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName, 840 policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName,
860 &string_value)) { 841 &string_value)) {
861 restart_required |= OnHostTalkGadgetPrefixPolicyUpdate(string_value); 842 restart_required |= OnHostTalkGadgetPrefixPolicyUpdate(string_value);
862 } 843 }
863 std::string token_url_string, token_validation_url_string; 844 std::string token_url_string, token_validation_url_string;
864 std::string token_validation_cert_issuer; 845 std::string token_validation_cert_issuer;
865 if (policies->GetString( 846 if (policies->GetString(
866 policy_hack::PolicyWatcher::kHostTokenUrlPolicyName, 847 policy_hack::PolicyWatcher::kHostTokenUrlPolicyName,
867 &token_url_string) && 848 &token_url_string) &&
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 if (nat_traversal_enabled) 935 if (nat_traversal_enabled)
955 HOST_LOG << "Policy enables NAT traversal."; 936 HOST_LOG << "Policy enables NAT traversal.";
956 else 937 else
957 HOST_LOG << "Policy disables NAT traversal."; 938 HOST_LOG << "Policy disables NAT traversal.";
958 allow_nat_traversal_ = nat_traversal_enabled; 939 allow_nat_traversal_ = nat_traversal_enabled;
959 return true; 940 return true;
960 } 941 }
961 return false; 942 return false;
962 } 943 }
963 944
964 bool HostProcess::OnRelayPolicyUpdate(bool allow_relay) {
965 // Returns true if the host has to be restarted after this policy update.
966 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
967
968 if (allow_relay_ != allow_relay) {
969 if (allow_relay)
970 HOST_LOG << "Policy enables use of relay server.";
971 else
972 HOST_LOG << "Policy disables use of relay server.";
973 allow_relay_ = allow_relay;
974 return true;
975 }
976 return false;
977 }
978
979 bool HostProcess::OnUdpPortPolicyUpdate(const std::string& udp_port_range) {
980 // Returns true if the host has to be restarted after this policy update.
981 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
982
983 // Use default values if policy setting is empty or invalid.
984 int min_udp_port = 0;
985 int max_udp_port = 0;
986 if (!udp_port_range.empty() &&
987 !NetworkSettings::ParsePortRange(udp_port_range, &min_udp_port,
988 &max_udp_port)) {
989 LOG(WARNING) << "Invalid port range policy: \"" << udp_port_range
990 << "\". Using default values.";
991 }
992
993 if (min_udp_port_ != min_udp_port || max_udp_port_ != max_udp_port) {
994 if (min_udp_port != 0 && max_udp_port != 0) {
995 HOST_LOG << "Policy restricts UDP port range to [" << min_udp_port
996 << ", " << max_udp_port << "]";
997 } else {
998 HOST_LOG << "Policy does not restrict UDP port range.";
999 }
1000 min_udp_port_ = min_udp_port;
1001 max_udp_port_ = max_udp_port;
1002 return true;
1003 }
1004 return false;
1005 }
1006
1007 void HostProcess::OnCurtainPolicyUpdate(bool curtain_required) { 945 void HostProcess::OnCurtainPolicyUpdate(bool curtain_required) {
1008 // Returns true if the host has to be restarted after this policy update. 946 // Returns true if the host has to be restarted after this policy update.
1009 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 947 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
1010 948
1011 #if defined(OS_MACOSX) 949 #if defined(OS_MACOSX)
1012 if (curtain_required) { 950 if (curtain_required) {
1013 // When curtain mode is in effect on Mac, the host process runs in the 951 // When curtain mode is in effect on Mac, the host process runs in the
1014 // user's switched-out session, but launchd will also run an instance at 952 // user's switched-out session, but launchd will also run an instance at
1015 // the console login screen. Even if no user is currently logged-on, we 953 // the console login screen. Even if no user is currently logged-on, we
1016 // can't support remote-access to the login screen because the current host 954 // can't support remote-access to the login screen because the current host
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 new OAuthTokenGetter::OAuthCredentials( 1080 new OAuthTokenGetter::OAuthCredentials(
1143 xmpp_server_config_.username, oauth_refresh_token_, 1081 xmpp_server_config_.username, oauth_refresh_token_,
1144 use_service_account_)); 1082 use_service_account_));
1145 1083
1146 oauth_token_getter_.reset(new OAuthTokenGetter( 1084 oauth_token_getter_.reset(new OAuthTokenGetter(
1147 oauth_credentials.Pass(), context_->url_request_context_getter())); 1085 oauth_credentials.Pass(), context_->url_request_context_getter()));
1148 1086
1149 signaling_connector_->EnableOAuth(oauth_token_getter_.get()); 1087 signaling_connector_->EnableOAuth(oauth_token_getter_.get());
1150 } 1088 }
1151 1089
1152 uint32 network_flags = allow_nat_traversal_ ? 1090 NetworkSettings network_settings(
1153 NetworkSettings::NAT_TRAVERSAL_STUN : 0; 1091 allow_nat_traversal_ ?
1154 1092 NetworkSettings::NAT_TRAVERSAL_ENABLED :
1155 if (allow_relay_) 1093 NetworkSettings::NAT_TRAVERSAL_DISABLED);
1156 network_flags |= NetworkSettings::NAT_TRAVERSAL_RELAY; 1094 if (!allow_nat_traversal_) {
1157
1158 if (allow_relay_ || allow_nat_traversal_)
1159 network_flags |= NetworkSettings::NAT_TRAVERSAL_OUTGOING;
1160
1161 NetworkSettings network_settings(network_flags);
1162
1163 if (min_udp_port_ && max_udp_port_) {
1164 network_settings.min_port = min_udp_port_;
1165 network_settings.max_port = max_udp_port_;
1166 } else if (!allow_nat_traversal_) {
1167 // For legacy reasons we have to restrict the port range to a set of default
1168 // values when nat traversal is disabled, even if the port range was not
1169 // set in policy.
1170 network_settings.min_port = NetworkSettings::kDefaultMinPort; 1095 network_settings.min_port = NetworkSettings::kDefaultMinPort;
1171 network_settings.max_port = NetworkSettings::kDefaultMaxPort; 1096 network_settings.max_port = NetworkSettings::kDefaultMaxPort;
1172 } 1097 }
1173 1098
1174 host_.reset(new ChromotingHost( 1099 host_.reset(new ChromotingHost(
1175 signal_strategy_.get(), 1100 signal_strategy_.get(),
1176 desktop_environment_factory_.get(), 1101 desktop_environment_factory_.get(),
1177 CreateHostSessionManager(signal_strategy_.get(), network_settings, 1102 CreateHostSessionManager(signal_strategy_.get(), network_settings,
1178 context_->url_request_context_getter()), 1103 context_->url_request_context_getter()),
1179 context_->audio_task_runner(), 1104 context_->audio_task_runner(),
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 return exit_code; 1278 return exit_code;
1354 } 1279 }
1355 1280
1356 } // namespace remoting 1281 } // namespace remoting
1357 1282
1358 #if !defined(OS_WIN) 1283 #if !defined(OS_WIN)
1359 int main(int argc, char** argv) { 1284 int main(int argc, char** argv) {
1360 return remoting::HostMain(argc, argv); 1285 return remoting::HostMain(argc, argv);
1361 } 1286 }
1362 #endif // !defined(OS_WIN) 1287 #endif // !defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698