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

Side by Side Diff: webrtc/pc/iceserverparsing.cc

Issue 2926823003: Allow passing both hostname and IP of ICE server into PeerConnection. (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 | « webrtc/p2p/base/portallocator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } else { 203 } else {
204 hoststring = tokens[0]; 204 hoststring = tokens[0];
205 } 205 }
206 206
207 int port = kDefaultStunPort; 207 int port = kDefaultStunPort;
208 if (service_type == TURNS) { 208 if (service_type == TURNS) {
209 port = kDefaultStunTlsPort; 209 port = kDefaultStunTlsPort;
210 turn_transport_type = cricket::PROTO_TLS; 210 turn_transport_type = cricket::PROTO_TLS;
211 } 211 }
212 212
213 std::string address; 213 std::string hostname;
214 if (!ParseHostnameAndPortFromString(hoststring, &address, &port)) { 214 if (!ParseHostnameAndPortFromString(hoststring, &hostname, &port)) {
215 LOG(WARNING) << "Invalid hostname format: " << uri_without_transport; 215 LOG(WARNING) << "Invalid hostname format: " << uri_without_transport;
216 return RTCErrorType::SYNTAX_ERROR; 216 return RTCErrorType::SYNTAX_ERROR;
217 } 217 }
218 218
219 if (port <= 0 || port > 0xffff) { 219 if (port <= 0 || port > 0xffff) {
220 LOG(WARNING) << "Invalid port: " << port; 220 LOG(WARNING) << "Invalid port: " << port;
221 return RTCErrorType::SYNTAX_ERROR; 221 return RTCErrorType::SYNTAX_ERROR;
222 } 222 }
223 rtc::SocketAddress address(hostname, port);
224 if (!server.ip.IsNil()) {
225 if (!address.IsUnresolvedIP() && address.ipaddr() != server.ip) {
226 return RTCErrorType::INVALID_PARAMETER;
227 }
228 address.SetResolvedIP(server.ip);
229 }
223 230
224 switch (service_type) { 231 switch (service_type) {
225 case STUN: 232 case STUN:
226 case STUNS: 233 case STUNS:
227 stun_servers->insert(rtc::SocketAddress(address, port)); 234 stun_servers->insert(address);
228 break; 235 break;
229 case TURN: 236 case TURN:
230 case TURNS: { 237 case TURNS: {
231 if (username.empty() || server.password.empty()) { 238 if (username.empty() || server.password.empty()) {
232 // The WebRTC spec requires throwing an InvalidAccessError when username 239 // The WebRTC spec requires throwing an InvalidAccessError when username
233 // or credential are ommitted; this is the native equivalent. 240 // or credential are ommitted; this is the native equivalent.
234 return RTCErrorType::INVALID_PARAMETER; 241 return RTCErrorType::INVALID_PARAMETER;
235 } 242 }
236 cricket::RelayServerConfig config = cricket::RelayServerConfig( 243 cricket::RelayServerConfig config = cricket::RelayServerConfig(
237 address, port, username, server.password, turn_transport_type); 244 address, username, server.password, turn_transport_type);
238 if (server.tls_cert_policy == 245 if (server.tls_cert_policy ==
239 PeerConnectionInterface::kTlsCertPolicyInsecureNoCheck) { 246 PeerConnectionInterface::kTlsCertPolicyInsecureNoCheck) {
240 config.tls_cert_policy = 247 config.tls_cert_policy =
241 cricket::TlsCertPolicy::TLS_CERT_POLICY_INSECURE_NO_CHECK; 248 cricket::TlsCertPolicy::TLS_CERT_POLICY_INSECURE_NO_CHECK;
242 } 249 }
243 turn_servers->push_back(config); 250 turn_servers->push_back(config);
244 break; 251 break;
245 } 252 }
246 default: 253 default:
247 // We shouldn't get to this point with an invalid service_type, we should 254 // We shouldn't get to this point with an invalid service_type, we should
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // are performed in a well-defined order. 292 // are performed in a well-defined order.
286 int priority = static_cast<int>(turn_servers->size() - 1); 293 int priority = static_cast<int>(turn_servers->size() - 1);
287 for (cricket::RelayServerConfig& turn_server : *turn_servers) { 294 for (cricket::RelayServerConfig& turn_server : *turn_servers) {
288 // First in the list gets highest priority. 295 // First in the list gets highest priority.
289 turn_server.priority = priority--; 296 turn_server.priority = priority--;
290 } 297 }
291 return RTCErrorType::NONE; 298 return RTCErrorType::NONE;
292 } 299 }
293 300
294 } // namespace webrtc 301 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/p2p/base/portallocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698