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 #include "content/renderer/p2p/port_allocator.h" | 5 #include "content/renderer/p2p/port_allocator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 if (!base::StringToInt(string, value) || *value <= 0 || *value >= 65536) { | 44 if (!base::StringToInt(string, value) || *value <= 0 || *value >= 65536) { |
45 LOG(ERROR) << "Received invalid port number from relay server: " << string; | 45 LOG(ERROR) << "Received invalid port number from relay server: " << string; |
46 return false; | 46 return false; |
47 } | 47 } |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 P2PPortAllocator::Config::Config() | 53 P2PPortAllocator::Config::Config() |
54 : stun_server_port(0), | 54 : legacy_relay(true), |
55 legacy_relay(true), | |
56 disable_tcp_transport(false) { | 55 disable_tcp_transport(false) { |
57 } | 56 } |
58 | 57 |
59 P2PPortAllocator::Config::~Config() { | 58 P2PPortAllocator::Config::~Config() { |
60 } | 59 } |
61 | 60 |
62 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() | 61 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() |
63 : port(0) { | 62 : port(0) { |
64 } | 63 } |
65 | 64 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 return; | 251 return; |
253 } | 252 } |
254 } | 253 } |
255 | 254 |
256 AddConfig(); | 255 AddConfig(); |
257 } | 256 } |
258 | 257 |
259 void P2PPortAllocatorSession::AddConfig() { | 258 void P2PPortAllocatorSession::AddConfig() { |
260 const P2PPortAllocator::Config& config = allocator_->config_; | 259 const P2PPortAllocator::Config& config = allocator_->config_; |
261 cricket::PortConfiguration* port_config = new cricket::PortConfiguration( | 260 cricket::PortConfiguration* port_config = new cricket::PortConfiguration( |
262 rtc::SocketAddress(config.stun_server, config.stun_server_port), | 261 config.stun_servers, std::string(), std::string()); |
263 std::string(), std::string()); | |
264 | 262 |
265 for (size_t i = 0; i < config.relays.size(); ++i) { | 263 for (size_t i = 0; i < config.relays.size(); ++i) { |
266 cricket::RelayCredentials credentials(config.relays[i].username, | 264 cricket::RelayCredentials credentials(config.relays[i].username, |
267 config.relays[i].password); | 265 config.relays[i].password); |
268 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); | 266 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); |
269 cricket::ProtocolType protocol; | 267 cricket::ProtocolType protocol; |
270 if (!cricket::StringToProto(config.relays[i].transport_type.c_str(), | 268 if (!cricket::StringToProto(config.relays[i].transport_type.c_str(), |
271 &protocol)) { | 269 &protocol)) { |
272 DLOG(WARNING) << "Ignoring TURN server " | 270 DLOG(WARNING) << "Ignoring TURN server " |
273 << config.relays[i].server_address << ". " | 271 << config.relays[i].server_address << ". " |
274 << "Reason= Incorrect " | 272 << "Reason= Incorrect " |
275 << config.relays[i].transport_type | 273 << config.relays[i].transport_type |
276 << " transport parameter."; | 274 << " transport parameter."; |
277 continue; | 275 continue; |
278 } | 276 } |
279 | 277 |
280 relay_server.ports.push_back(cricket::ProtocolAddress( | 278 relay_server.ports.push_back(cricket::ProtocolAddress( |
281 rtc::SocketAddress(config.relays[i].server_address, | 279 rtc::SocketAddress(config.relays[i].server_address, |
282 config.relays[i].port), | 280 config.relays[i].port), |
283 protocol, | 281 protocol, |
284 config.relays[i].secure)); | 282 config.relays[i].secure)); |
285 relay_server.credentials = credentials; | 283 relay_server.credentials = credentials; |
286 port_config->AddRelay(relay_server); | 284 port_config->AddRelay(relay_server); |
287 } | 285 } |
288 ConfigReady(port_config); | 286 ConfigReady(port_config); |
289 } | 287 } |
290 | 288 |
291 } // namespace content | 289 } // namespace content |
OLD | NEW |