Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "remoting/host/it2me/it2me_host.h" | 5 #include "remoting/host/it2me/it2me_host.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 matched = true; | 171 matched = true; |
| 172 break; | 172 break; |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 if (!matched) { | 175 if (!matched) { |
| 176 SetState(kInvalidDomainError, ""); | 176 SetState(kInvalidDomainError, ""); |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Check the port range policy. | |
| 182 PortRange port_range; | |
| 183 if (!PortRange::Parse(udp_port_range_string_, &port_range)) { | |
|
Sergey Ulanov
2017/05/25 19:34:53
It looks like PolicyWatcher is supposed to verify
Gus Smith
2017/05/25 21:39:09
OK - I'll change it back. Originally I did the par
| |
| 184 std::string error_message = | |
| 185 "Invalid RemoteAccessHostUdpPortRange policy value."; | |
| 186 LOG(ERROR) << error_message; | |
| 187 SetState(kError, error_message); | |
| 188 return; | |
| 189 } | |
| 190 | |
| 181 // Generate a key pair for the Host to use. | 191 // Generate a key pair for the Host to use. |
| 182 // TODO(wez): Move this to the worker thread. | 192 // TODO(wez): Move this to the worker thread. |
| 183 host_key_pair_ = RsaKeyPair::Generate(); | 193 host_key_pair_ = RsaKeyPair::Generate(); |
| 184 | 194 |
| 185 // Request registration of the host for support. | 195 // Request registration of the host for support. |
| 186 std::unique_ptr<RegisterSupportHostRequest> register_request( | 196 std::unique_ptr<RegisterSupportHostRequest> register_request( |
| 187 new RegisterSupportHostRequest( | 197 new RegisterSupportHostRequest( |
| 188 signal_strategy_.get(), host_key_pair_, directory_bot_jid_, | 198 signal_strategy_.get(), host_key_pair_, directory_bot_jid_, |
| 189 base::Bind(&It2MeHost::OnReceivedSupportID, base::Unretained(this)))); | 199 base::Bind(&It2MeHost::OnReceivedSupportID, base::Unretained(this)))); |
| 190 | 200 |
| 191 // Beyond this point nothing can fail, so save the config and request. | 201 // Beyond this point nothing can fail, so save the config and request. |
| 192 register_request_ = std::move(register_request); | 202 register_request_ = std::move(register_request); |
| 193 | 203 |
| 194 // If NAT traversal is off then limit port range to allow firewall pin-holing. | |
| 195 HOST_LOG << "NAT state: " << nat_traversal_enabled_; | |
| 196 protocol::NetworkSettings network_settings( | 204 protocol::NetworkSettings network_settings( |
| 197 nat_traversal_enabled_ ? | 205 nat_traversal_enabled_ ? |
| 198 protocol::NetworkSettings::NAT_TRAVERSAL_FULL : | 206 protocol::NetworkSettings::NAT_TRAVERSAL_FULL : |
| 199 protocol::NetworkSettings::NAT_TRAVERSAL_DISABLED); | 207 protocol::NetworkSettings::NAT_TRAVERSAL_DISABLED); |
| 208 network_settings.port_range = port_range; | |
| 209 | |
| 210 // If NAT traversal is off then limit port range to allow firewall pin-holing. | |
| 211 HOST_LOG << "NAT state: " << nat_traversal_enabled_; | |
| 200 if (!nat_traversal_enabled_) { | 212 if (!nat_traversal_enabled_) { |
| 201 network_settings.port_range.min_port = | 213 network_settings.port_range.min_port = |
| 202 protocol::NetworkSettings::kDefaultMinPort; | 214 protocol::NetworkSettings::kDefaultMinPort; |
| 203 network_settings.port_range.max_port = | 215 network_settings.port_range.max_port = |
| 204 protocol::NetworkSettings::kDefaultMaxPort; | 216 protocol::NetworkSettings::kDefaultMaxPort; |
| 205 } | 217 } |
| 206 | 218 |
| 207 scoped_refptr<protocol::TransportContext> transport_context = | 219 scoped_refptr<protocol::TransportContext> transport_context = |
| 208 new protocol::TransportContext( | 220 new protocol::TransportContext( |
| 209 signal_strategy_.get(), | 221 signal_strategy_.get(), |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 const base::ListValue* client_domain_list; | 335 const base::ListValue* client_domain_list; |
| 324 if (policies->GetList(policy::key::kRemoteAccessHostClientDomainList, | 336 if (policies->GetList(policy::key::kRemoteAccessHostClientDomainList, |
| 325 &client_domain_list)) { | 337 &client_domain_list)) { |
| 326 std::vector<std::string> client_domain_list_vector; | 338 std::vector<std::string> client_domain_list_vector; |
| 327 for (const auto& value : *client_domain_list) { | 339 for (const auto& value : *client_domain_list) { |
| 328 client_domain_list_vector.push_back(value.GetString()); | 340 client_domain_list_vector.push_back(value.GetString()); |
| 329 } | 341 } |
| 330 UpdateClientDomainListPolicy(std::move(client_domain_list_vector)); | 342 UpdateClientDomainListPolicy(std::move(client_domain_list_vector)); |
| 331 } | 343 } |
| 332 | 344 |
| 345 std::string port_range_string; | |
| 346 if (policies->GetString(policy::key::kRemoteAccessHostUdpPortRange, | |
| 347 &port_range_string)) { | |
| 348 UpdateHostUdpPortRangePolicy(port_range_string); | |
| 349 } | |
| 350 | |
| 333 policy_received_ = true; | 351 policy_received_ = true; |
| 334 | 352 |
| 335 if (!pending_connect_.is_null()) { | 353 if (!pending_connect_.is_null()) { |
| 336 base::ResetAndReturn(&pending_connect_).Run(); | 354 base::ResetAndReturn(&pending_connect_).Run(); |
| 337 } | 355 } |
| 338 } | 356 } |
| 339 | 357 |
| 340 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { | 358 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { |
| 341 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 359 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
| 342 | 360 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 << base::JoinString(client_domain_list, ", "); | 397 << base::JoinString(client_domain_list, ", "); |
| 380 | 398 |
| 381 // When setting a client domain policy, disconnect any existing session. | 399 // When setting a client domain policy, disconnect any existing session. |
| 382 if (!client_domain_list.empty() && IsRunning()) { | 400 if (!client_domain_list.empty() && IsRunning()) { |
| 383 DisconnectOnNetworkThread(); | 401 DisconnectOnNetworkThread(); |
| 384 } | 402 } |
| 385 | 403 |
| 386 required_client_domain_list_ = std::move(client_domain_list); | 404 required_client_domain_list_ = std::move(client_domain_list); |
| 387 } | 405 } |
| 388 | 406 |
| 407 void It2MeHost::UpdateHostUdpPortRangePolicy(std::string port_range_string) { | |
| 408 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | |
| 409 | |
| 410 VLOG(2) << "UpdateHostUdpPortRangePolicy: " << port_range_string; | |
| 411 | |
| 412 if (IsRunning()) { | |
| 413 DisconnectOnNetworkThread(); | |
| 414 } | |
| 415 | |
| 416 udp_port_range_string_ = port_range_string; | |
| 417 } | |
| 418 | |
| 389 void It2MeHost::SetState(It2MeHostState state, | 419 void It2MeHost::SetState(It2MeHostState state, |
| 390 const std::string& error_message) { | 420 const std::string& error_message) { |
| 391 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 421 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
| 392 | 422 |
| 393 switch (state_) { | 423 switch (state_) { |
| 394 case kDisconnected: | 424 case kDisconnected: |
| 395 DCHECK(state == kStarting || | 425 DCHECK(state == kStarting || |
| 396 state == kError) << state; | 426 state == kError) << state; |
| 397 break; | 427 break; |
| 398 case kStarting: | 428 case kStarting: |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 std::unique_ptr<SignalStrategy> signal_strategy, | 606 std::unique_ptr<SignalStrategy> signal_strategy, |
| 577 const std::string& username, | 607 const std::string& username, |
| 578 const std::string& directory_bot_jid) { | 608 const std::string& directory_bot_jid) { |
| 579 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); | 609 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); |
| 580 return new It2MeHost( | 610 return new It2MeHost( |
| 581 std::move(context), base::MakeUnique<It2MeConfirmationDialogFactory>(), | 611 std::move(context), base::MakeUnique<It2MeConfirmationDialogFactory>(), |
| 582 observer, std::move(signal_strategy), username, directory_bot_jid); | 612 observer, std::move(signal_strategy), username, directory_bot_jid); |
| 583 } | 613 } |
| 584 | 614 |
| 585 } // namespace remoting | 615 } // namespace remoting |
| OLD | NEW |