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

Side by Side Diff: remoting/host/it2me/it2me_host.cc

Issue 2912143002: Host port range policy is no longer ignored in it2me host. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « remoting/host/it2me/it2me_host.h ('k') | remoting/host/it2me/it2me_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 // Request registration of the host for support. 185 // Request registration of the host for support.
186 std::unique_ptr<RegisterSupportHostRequest> register_request( 186 std::unique_ptr<RegisterSupportHostRequest> register_request(
187 new RegisterSupportHostRequest( 187 new RegisterSupportHostRequest(
188 signal_strategy_.get(), host_key_pair_, directory_bot_jid_, 188 signal_strategy_.get(), host_key_pair_, directory_bot_jid_,
189 base::Bind(&It2MeHost::OnReceivedSupportID, base::Unretained(this)))); 189 base::Bind(&It2MeHost::OnReceivedSupportID, base::Unretained(this))));
190 190
191 // Beyond this point nothing can fail, so save the config and request. 191 // Beyond this point nothing can fail, so save the config and request.
192 register_request_ = std::move(register_request); 192 register_request_ = std::move(register_request);
193 193
194 // If NAT traversal is off then limit port range to allow firewall pin-holing.
195 HOST_LOG << "NAT state: " << nat_traversal_enabled_; 194 HOST_LOG << "NAT state: " << nat_traversal_enabled_;
195
196 protocol::NetworkSettings network_settings( 196 protocol::NetworkSettings network_settings(
197 nat_traversal_enabled_ ? 197 nat_traversal_enabled_ ?
198 protocol::NetworkSettings::NAT_TRAVERSAL_FULL : 198 protocol::NetworkSettings::NAT_TRAVERSAL_FULL :
199 protocol::NetworkSettings::NAT_TRAVERSAL_DISABLED); 199 protocol::NetworkSettings::NAT_TRAVERSAL_DISABLED);
200 if (!nat_traversal_enabled_) { 200
201 if (!udp_port_range_.is_null()) {
202 network_settings.port_range = udp_port_range_;
203 } else if (!nat_traversal_enabled_) {
204 // For legacy reasons we have to restrict the port range to a set of default
205 // values when nat traversal is disabled, even if the port range was not
206 // set in policy.
201 network_settings.port_range.min_port = 207 network_settings.port_range.min_port =
202 protocol::NetworkSettings::kDefaultMinPort; 208 protocol::NetworkSettings::kDefaultMinPort;
203 network_settings.port_range.max_port = 209 network_settings.port_range.max_port =
204 protocol::NetworkSettings::kDefaultMaxPort; 210 protocol::NetworkSettings::kDefaultMaxPort;
205 } 211 }
206 212
207 scoped_refptr<protocol::TransportContext> transport_context = 213 scoped_refptr<protocol::TransportContext> transport_context =
208 new protocol::TransportContext( 214 new protocol::TransportContext(
209 signal_strategy_.get(), 215 signal_strategy_.get(),
210 base::WrapUnique(new protocol::ChromiumPortAllocatorFactory()), 216 base::WrapUnique(new protocol::ChromiumPortAllocatorFactory()),
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 const base::ListValue* client_domain_list; 329 const base::ListValue* client_domain_list;
324 if (policies->GetList(policy::key::kRemoteAccessHostClientDomainList, 330 if (policies->GetList(policy::key::kRemoteAccessHostClientDomainList,
325 &client_domain_list)) { 331 &client_domain_list)) {
326 std::vector<std::string> client_domain_list_vector; 332 std::vector<std::string> client_domain_list_vector;
327 for (const auto& value : *client_domain_list) { 333 for (const auto& value : *client_domain_list) {
328 client_domain_list_vector.push_back(value.GetString()); 334 client_domain_list_vector.push_back(value.GetString());
329 } 335 }
330 UpdateClientDomainListPolicy(std::move(client_domain_list_vector)); 336 UpdateClientDomainListPolicy(std::move(client_domain_list_vector));
331 } 337 }
332 338
339 std::string port_range_string;
340 if (policies->GetString(policy::key::kRemoteAccessHostUdpPortRange,
341 &port_range_string)) {
342 UpdateHostUdpPortRangePolicy(port_range_string);
343 }
344
333 policy_received_ = true; 345 policy_received_ = true;
334 346
335 if (!pending_connect_.is_null()) { 347 if (!pending_connect_.is_null()) {
336 base::ResetAndReturn(&pending_connect_).Run(); 348 base::ResetAndReturn(&pending_connect_).Run();
337 } 349 }
338 } 350 }
339 351
340 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { 352 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) {
341 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); 353 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
342 354
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 << base::JoinString(client_domain_list, ", "); 391 << base::JoinString(client_domain_list, ", ");
380 392
381 // When setting a client domain policy, disconnect any existing session. 393 // When setting a client domain policy, disconnect any existing session.
382 if (!client_domain_list.empty() && IsRunning()) { 394 if (!client_domain_list.empty() && IsRunning()) {
383 DisconnectOnNetworkThread(); 395 DisconnectOnNetworkThread();
384 } 396 }
385 397
386 required_client_domain_list_ = std::move(client_domain_list); 398 required_client_domain_list_ = std::move(client_domain_list);
387 } 399 }
388 400
401 void It2MeHost::UpdateHostUdpPortRangePolicy(
402 const std::string& port_range_string) {
403 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
404
405 VLOG(2) << "UpdateHostUdpPortRangePolicy: " << port_range_string;
406
407 if (IsRunning()) {
408 DisconnectOnNetworkThread();
409 }
410
411 if (!PortRange::Parse(port_range_string, &udp_port_range_)) {
412 // PolicyWatcher verifies that the value is formatted correctly.
413 LOG(FATAL) << "Invalid port range: " << port_range_string;
414 }
415 }
416
389 void It2MeHost::SetState(It2MeHostState state, 417 void It2MeHost::SetState(It2MeHostState state,
390 const std::string& error_message) { 418 const std::string& error_message) {
391 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); 419 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
392 420
393 switch (state_) { 421 switch (state_) {
394 case kDisconnected: 422 case kDisconnected:
395 DCHECK(state == kStarting || 423 DCHECK(state == kStarting ||
396 state == kError) << state; 424 state == kError) << state;
397 break; 425 break;
398 case kStarting: 426 case kStarting:
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 std::unique_ptr<SignalStrategy> signal_strategy, 604 std::unique_ptr<SignalStrategy> signal_strategy,
577 const std::string& username, 605 const std::string& username,
578 const std::string& directory_bot_jid) { 606 const std::string& directory_bot_jid) {
579 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); 607 DCHECK(context->ui_task_runner()->BelongsToCurrentThread());
580 return new It2MeHost( 608 return new It2MeHost(
581 std::move(context), base::MakeUnique<It2MeConfirmationDialogFactory>(), 609 std::move(context), base::MakeUnique<It2MeConfirmationDialogFactory>(),
582 observer, std::move(signal_strategy), username, directory_bot_jid); 610 observer, std::move(signal_strategy), username, directory_bot_jid);
583 } 611 }
584 612
585 } // namespace remoting 613 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/it2me/it2me_host.h ('k') | remoting/host/it2me/it2me_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698