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

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

Issue 2901033002: Host port range policy is no longer ignored in it2me host (Closed)
Patch Set: Host port range policy is no longer ignored in it2me host Created 3 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
« 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_;
196 protocol::NetworkSettings network_settings( 194 protocol::NetworkSettings network_settings(
197 nat_traversal_enabled_ ? 195 nat_traversal_enabled_ ?
198 protocol::NetworkSettings::NAT_TRAVERSAL_FULL : 196 protocol::NetworkSettings::NAT_TRAVERSAL_FULL :
199 protocol::NetworkSettings::NAT_TRAVERSAL_DISABLED); 197 protocol::NetworkSettings::NAT_TRAVERSAL_DISABLED);
198 network_settings.port_range = udp_port_range_;
199
200 // If NAT traversal is off then limit port range to allow firewall pin-holing.
201 HOST_LOG << "NAT state: " << nat_traversal_enabled_;
200 if (!nat_traversal_enabled_) { 202 if (!nat_traversal_enabled_) {
201 network_settings.port_range.min_port = 203 network_settings.port_range.min_port =
Sergey Ulanov 2017/05/25 22:24:38 Setting port range here makes sense only if it isn
Gus Smith 2017/05/25 22:55:58 Done. I don't think I fully understand what should
Sergey Ulanov 2017/05/26 00:40:08 If an admin disables NAT traversal then they also
202 protocol::NetworkSettings::kDefaultMinPort; 204 protocol::NetworkSettings::kDefaultMinPort;
203 network_settings.port_range.max_port = 205 network_settings.port_range.max_port =
204 protocol::NetworkSettings::kDefaultMaxPort; 206 protocol::NetworkSettings::kDefaultMaxPort;
205 } 207 }
206 208
207 scoped_refptr<protocol::TransportContext> transport_context = 209 scoped_refptr<protocol::TransportContext> transport_context =
208 new protocol::TransportContext( 210 new protocol::TransportContext(
209 signal_strategy_.get(), 211 signal_strategy_.get(),
210 base::WrapUnique(new protocol::ChromiumPortAllocatorFactory()), 212 base::WrapUnique(new protocol::ChromiumPortAllocatorFactory()),
211 base::WrapUnique(new ChromiumUrlRequestFactory( 213 base::WrapUnique(new ChromiumUrlRequestFactory(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 const base::ListValue* client_domain_list; 325 const base::ListValue* client_domain_list;
324 if (policies->GetList(policy::key::kRemoteAccessHostClientDomainList, 326 if (policies->GetList(policy::key::kRemoteAccessHostClientDomainList,
325 &client_domain_list)) { 327 &client_domain_list)) {
326 std::vector<std::string> client_domain_list_vector; 328 std::vector<std::string> client_domain_list_vector;
327 for (const auto& value : *client_domain_list) { 329 for (const auto& value : *client_domain_list) {
328 client_domain_list_vector.push_back(value.GetString()); 330 client_domain_list_vector.push_back(value.GetString());
329 } 331 }
330 UpdateClientDomainListPolicy(std::move(client_domain_list_vector)); 332 UpdateClientDomainListPolicy(std::move(client_domain_list_vector));
331 } 333 }
332 334
335 std::string port_range_string;
336 if (policies->GetString(policy::key::kRemoteAccessHostUdpPortRange,
337 &port_range_string)) {
338 UpdateHostUdpPortRangePolicy(port_range_string);
339 }
340
333 policy_received_ = true; 341 policy_received_ = true;
334 342
335 if (!pending_connect_.is_null()) { 343 if (!pending_connect_.is_null()) {
336 base::ResetAndReturn(&pending_connect_).Run(); 344 base::ResetAndReturn(&pending_connect_).Run();
337 } 345 }
338 } 346 }
339 347
340 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { 348 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) {
341 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); 349 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
342 350
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 << base::JoinString(client_domain_list, ", "); 387 << base::JoinString(client_domain_list, ", ");
380 388
381 // When setting a client domain policy, disconnect any existing session. 389 // When setting a client domain policy, disconnect any existing session.
382 if (!client_domain_list.empty() && IsRunning()) { 390 if (!client_domain_list.empty() && IsRunning()) {
383 DisconnectOnNetworkThread(); 391 DisconnectOnNetworkThread();
384 } 392 }
385 393
386 required_client_domain_list_ = std::move(client_domain_list); 394 required_client_domain_list_ = std::move(client_domain_list);
387 } 395 }
388 396
397 void It2MeHost::UpdateHostUdpPortRangePolicy(
398 const std::string& port_range_string) {
399 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
400
401 VLOG(2) << "UpdateHostUdpPortRangePolicy: " << port_range_string;
402
403 if (IsRunning()) {
404 DisconnectOnNetworkThread();
405 }
406
407 if (!PortRange::Parse(port_range_string, &udp_port_range_)) {
408 // PolicyWatcher verifies that the value is formatted correctly.
409 LOG(FATAL) << "Invalid port range: " << port_range_string;
410 }
411 }
412
389 void It2MeHost::SetState(It2MeHostState state, 413 void It2MeHost::SetState(It2MeHostState state,
390 const std::string& error_message) { 414 const std::string& error_message) {
391 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); 415 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
392 416
393 switch (state_) { 417 switch (state_) {
394 case kDisconnected: 418 case kDisconnected:
395 DCHECK(state == kStarting || 419 DCHECK(state == kStarting ||
396 state == kError) << state; 420 state == kError) << state;
397 break; 421 break;
398 case kStarting: 422 case kStarting:
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 std::unique_ptr<SignalStrategy> signal_strategy, 600 std::unique_ptr<SignalStrategy> signal_strategy,
577 const std::string& username, 601 const std::string& username,
578 const std::string& directory_bot_jid) { 602 const std::string& directory_bot_jid) {
579 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); 603 DCHECK(context->ui_task_runner()->BelongsToCurrentThread());
580 return new It2MeHost( 604 return new It2MeHost(
581 std::move(context), base::MakeUnique<It2MeConfirmationDialogFactory>(), 605 std::move(context), base::MakeUnique<It2MeConfirmationDialogFactory>(),
582 observer, std::move(signal_strategy), username, directory_bot_jid); 606 observer, std::move(signal_strategy), username, directory_bot_jid);
583 } 607 }
584 608
585 } // namespace remoting 609 } // 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