Chromium Code Reviews| Index: remoting/host/it2me/it2me_host.cc |
| diff --git a/remoting/host/it2me/it2me_host.cc b/remoting/host/it2me/it2me_host.cc |
| index 17e7143541fc2d8f58256a01957bdd7da893b722..9ece18882cde58a8d9c12e43e9cbc4438684a849 100644 |
| --- a/remoting/host/it2me/it2me_host.cc |
| +++ b/remoting/host/it2me/it2me_host.cc |
| @@ -191,13 +191,17 @@ void It2MeHost::FinishConnect() { |
| // Beyond this point nothing can fail, so save the config and request. |
| register_request_ = std::move(register_request); |
| - // If NAT traversal is off then limit port range to allow firewall pin-holing. |
| - HOST_LOG << "NAT state: " << nat_traversal_enabled_; |
| protocol::NetworkSettings network_settings( |
| nat_traversal_enabled_ ? |
| protocol::NetworkSettings::NAT_TRAVERSAL_FULL : |
| protocol::NetworkSettings::NAT_TRAVERSAL_DISABLED); |
| - if (!nat_traversal_enabled_) { |
| + |
| + // Update port range only if it has not already been set. |
|
Sergey Ulanov
2017/05/26 00:40:09
This comment doesn't look correct. The code sets p
Gus Smith
2017/05/26 15:59:11
Done.
|
| + // If NAT traversal is off then limit port range to allow firewall pin-holing. |
|
Sergey Ulanov
2017/05/26 00:40:09
Please remove this comment to avoid confusion. Ins
Gus Smith
2017/05/26 15:59:11
Done.
|
| + HOST_LOG << "NAT state: " << nat_traversal_enabled_; |
|
Sergey Ulanov
2017/05/26 00:40:09
This line is not related to port range. I'd prefer
Gus Smith
2017/05/26 15:59:11
Done.
|
| + if (!udp_port_range_.is_null()) { |
| + network_settings.port_range = udp_port_range_; |
| + } else if (!nat_traversal_enabled_) { |
| network_settings.port_range.min_port = |
| protocol::NetworkSettings::kDefaultMinPort; |
| network_settings.port_range.max_port = |
| @@ -330,6 +334,12 @@ void It2MeHost::OnPolicyUpdate( |
| UpdateClientDomainListPolicy(std::move(client_domain_list_vector)); |
| } |
| + std::string port_range_string; |
| + if (policies->GetString(policy::key::kRemoteAccessHostUdpPortRange, |
| + &port_range_string)) { |
| + UpdateHostUdpPortRangePolicy(port_range_string); |
| + } |
| + |
| policy_received_ = true; |
| if (!pending_connect_.is_null()) { |
| @@ -386,6 +396,22 @@ void It2MeHost::UpdateClientDomainListPolicy( |
| required_client_domain_list_ = std::move(client_domain_list); |
| } |
| +void It2MeHost::UpdateHostUdpPortRangePolicy( |
| + const std::string& port_range_string) { |
| + DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
| + |
| + VLOG(2) << "UpdateHostUdpPortRangePolicy: " << port_range_string; |
| + |
| + if (IsRunning()) { |
| + DisconnectOnNetworkThread(); |
| + } |
| + |
| + if (!PortRange::Parse(port_range_string, &udp_port_range_)) { |
| + // PolicyWatcher verifies that the value is formatted correctly. |
| + LOG(FATAL) << "Invalid port range: " << port_range_string; |
| + } |
| +} |
| + |
| void It2MeHost::SetState(It2MeHostState state, |
| const std::string& error_message) { |
| DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |