OLD | NEW |
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 is an application of a minimal host process in a Chromoting | 5 // This is an application of a minimal host process in a Chromoting |
6 // system. It serves the purpose of gluing different pieces together | 6 // system. It serves the purpose of gluing different pieces together |
7 // to make a functional host process for testing. | 7 // to make a functional host process for testing. |
8 // | 8 // |
9 // It peforms the following functionality: | 9 // It peforms the following functionality: |
10 // 1. Connect to the GTalk network and register the machine as a host. | 10 // 1. Connect to the GTalk network and register the machine as a host. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #elif defined(OS_MACOSX) | 55 #elif defined(OS_MACOSX) |
56 #include "base/mac/scoped_nsautorelease_pool.h" | 56 #include "base/mac/scoped_nsautorelease_pool.h" |
57 #elif defined(OS_WIN) | 57 #elif defined(OS_WIN) |
58 // TODO(garykac) Make simple host into a proper GUI app on Windows so that we | 58 // TODO(garykac) Make simple host into a proper GUI app on Windows so that we |
59 // have an hModule for the dialog resource. | 59 // have an hModule for the dialog resource. |
60 HMODULE g_hModule = NULL; | 60 HMODULE g_hModule = NULL; |
61 #endif | 61 #endif |
62 | 62 |
63 using remoting::protocol::CandidateSessionConfig; | 63 using remoting::protocol::CandidateSessionConfig; |
64 using remoting::protocol::ChannelConfig; | 64 using remoting::protocol::ChannelConfig; |
| 65 using remoting::protocol::SharedSecretHash; |
65 using remoting::protocol::NetworkSettings; | 66 using remoting::protocol::NetworkSettings; |
66 | 67 |
67 namespace { | 68 namespace { |
68 | 69 |
69 const FilePath::CharType kDefaultConfigPath[] = | 70 const FilePath::CharType kDefaultConfigPath[] = |
70 FILE_PATH_LITERAL(".ChromotingConfig.json"); | 71 FILE_PATH_LITERAL(".ChromotingConfig.json"); |
71 | 72 |
72 const char kHomeDrive[] = "HOMEDRIVE"; | 73 const char kHomeDrive[] = "HOMEDRIVE"; |
73 const char kHomePath[] = "HOMEPATH"; | 74 const char kHomePath[] = "HOMEPATH"; |
74 | 75 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 115 |
115 if (!config->GetString(kHostIdConfigPath, &host_id_)) { | 116 if (!config->GetString(kHostIdConfigPath, &host_id_)) { |
116 LOG(ERROR) << "host_id is not defined in the config."; | 117 LOG(ERROR) << "host_id is not defined in the config."; |
117 return 1; | 118 return 1; |
118 } | 119 } |
119 | 120 |
120 if (!key_pair_.Load(config)) { | 121 if (!key_pair_.Load(config)) { |
121 return 1; | 122 return 1; |
122 } | 123 } |
123 | 124 |
| 125 std::string host_secret_hash_string; |
| 126 if (!config->GetString(kHostSecretHashConfigPath, |
| 127 &host_secret_hash_string)) { |
| 128 LOG(ERROR) << "host_secret_hash is not defined in the config."; |
| 129 return false; |
| 130 } |
| 131 |
| 132 if (!host_secret_hash_.Parse(host_secret_hash_string)) { |
| 133 LOG(ERROR) << "Invalid host_secret_hash."; |
| 134 return false; |
| 135 } |
| 136 |
124 // Use an XMPP connection to the Talk network for session signalling. | 137 // Use an XMPP connection to the Talk network for session signalling. |
125 if (!config->GetString(kXmppLoginConfigPath, &xmpp_login_) || | 138 if (!config->GetString(kXmppLoginConfigPath, &xmpp_login_) || |
126 !config->GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_)) { | 139 !config->GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_)) { |
127 LOG(ERROR) << "XMPP credentials are not defined in the config."; | 140 LOG(ERROR) << "XMPP credentials are not defined in the config."; |
128 return 1; | 141 return 1; |
129 } | 142 } |
130 if (!config->GetString(kXmppAuthServiceConfigPath, &xmpp_auth_service_)) { | 143 if (!config->GetString(kXmppAuthServiceConfigPath, &xmpp_auth_service_)) { |
131 // For the simple host, we assume we always use the ClientLogin token for | 144 // For the simple host, we assume we always use the ClientLogin token for |
132 // chromiumsync because we do not have an HTTP stack with which we can | 145 // chromiumsync because we do not have an HTTP stack with which we can |
133 // easily request an OAuth2 access token even if we had a RefreshToken for | 146 // easily request an OAuth2 access token even if we had a RefreshToken for |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 signal_strategy_.get(), &key_pair_, | 248 signal_strategy_.get(), &key_pair_, |
236 base::Bind(&SimpleHost::SetIT2MeAccessCode, host_, &key_pair_))); | 249 base::Bind(&SimpleHost::SetIT2MeAccessCode, host_, &key_pair_))); |
237 } else { | 250 } else { |
238 heartbeat_sender_.reset( | 251 heartbeat_sender_.reset( |
239 new HeartbeatSender(host_id_, signal_strategy_.get(), &key_pair_)); | 252 new HeartbeatSender(host_id_, signal_strategy_.get(), &key_pair_)); |
240 } | 253 } |
241 | 254 |
242 host_->Start(); | 255 host_->Start(); |
243 | 256 |
244 // Create a Me2Me authenticator factory. | 257 // Create a Me2Me authenticator factory. |
245 // | |
246 // TODO(sergeyu): Currently empty PIN is used. This is a temporary | |
247 // hack pending us adding a way to set a PIN. crbug.com/105214 . | |
248 if (!is_it2me_) { | 258 if (!is_it2me_) { |
249 scoped_ptr<protocol::AuthenticatorFactory> factory( | 259 scoped_ptr<protocol::AuthenticatorFactory> factory( |
250 new protocol::Me2MeHostAuthenticatorFactory( | 260 new protocol::Me2MeHostAuthenticatorFactory( |
251 xmpp_login_, key_pair_.GenerateCertificate(), | 261 xmpp_login_, key_pair_.GenerateCertificate(), |
252 *key_pair_.private_key(), "")); | 262 *key_pair_.private_key(), host_secret_hash_)); |
253 host_->SetAuthenticatorFactory(factory.Pass()); | 263 host_->SetAuthenticatorFactory(factory.Pass()); |
254 } | 264 } |
255 } | 265 } |
256 | 266 |
257 MessageLoop message_loop_; | 267 MessageLoop message_loop_; |
258 base::Thread file_io_thread_; | 268 base::Thread file_io_thread_; |
259 ChromotingHostContext context_; | 269 ChromotingHostContext context_; |
260 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 270 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
261 | 271 |
262 FilePath config_path_; | 272 FilePath config_path_; |
263 bool fake_; | 273 bool fake_; |
264 bool is_it2me_; | 274 bool is_it2me_; |
265 NetworkSettings network_settings_; | 275 NetworkSettings network_settings_; |
266 scoped_ptr<CandidateSessionConfig> protocol_config_; | 276 scoped_ptr<CandidateSessionConfig> protocol_config_; |
267 | 277 |
268 std::string host_id_; | 278 std::string host_id_; |
269 HostKeyPair key_pair_; | 279 HostKeyPair key_pair_; |
| 280 SharedSecretHash host_secret_hash_; |
270 std::string xmpp_login_; | 281 std::string xmpp_login_; |
271 std::string xmpp_auth_token_; | 282 std::string xmpp_auth_token_; |
272 std::string xmpp_auth_service_; | 283 std::string xmpp_auth_service_; |
273 | 284 |
274 scoped_ptr<SignalStrategy> signal_strategy_; | 285 scoped_ptr<SignalStrategy> signal_strategy_; |
275 scoped_ptr<SignalingConnector> signaling_connector_; | 286 scoped_ptr<SignalingConnector> signaling_connector_; |
276 scoped_ptr<DesktopEnvironment> desktop_environment_; | 287 scoped_ptr<DesktopEnvironment> desktop_environment_; |
277 scoped_ptr<LogToServer> log_to_server_; | 288 scoped_ptr<LogToServer> log_to_server_; |
278 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_; | 289 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_; |
279 scoped_ptr<RegisterSupportHostRequest> register_request_; | 290 scoped_ptr<RegisterSupportHostRequest> register_request_; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 max_port < 0 || max_port > 65535) { | 370 max_port < 0 || max_port > 65535) { |
360 LOG(ERROR) << "Invalid max-port value: " << max_port | 371 LOG(ERROR) << "Invalid max-port value: " << max_port |
361 << ". Expected integer in range [0, 65535]."; | 372 << ". Expected integer in range [0, 65535]."; |
362 return 1; | 373 return 1; |
363 } | 374 } |
364 simple_host.network_settings()->max_port = max_port; | 375 simple_host.network_settings()->max_port = max_port; |
365 } | 376 } |
366 | 377 |
367 return simple_host.Run(); | 378 return simple_host.Run(); |
368 } | 379 } |
OLD | NEW |