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

Side by Side Diff: webrtc/p2p/base/tcpport.cc

Issue 1979463003: Revert of Allow the localhost IP address even if it does not match the tcp port address (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 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 | « webrtc/base/virtualsocketserver.cc ('k') | webrtc/p2p/base/tcpport_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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 pretending_to_be_writable_ = false; 380 pretending_to_be_writable_ = false;
381 ASSERT(write_state() == STATE_WRITABLE); 381 ASSERT(write_state() == STATE_WRITABLE);
382 } 382 }
383 383
384 void TCPConnection::OnConnect(rtc::AsyncPacketSocket* socket) { 384 void TCPConnection::OnConnect(rtc::AsyncPacketSocket* socket) {
385 ASSERT(socket == socket_.get()); 385 ASSERT(socket == socket_.get());
386 // Do not use this connection if the socket bound to a different address than 386 // Do not use this connection if the socket bound to a different address than
387 // the one we asked for. This is seen in Chrome, where TCP sockets cannot be 387 // the one we asked for. This is seen in Chrome, where TCP sockets cannot be
388 // given a binding address, and the platform is expected to pick the 388 // given a binding address, and the platform is expected to pick the
389 // correct local address. 389 // correct local address.
390 const rtc::SocketAddress& socket_addr = socket->GetLocalAddress(); 390 const rtc::IPAddress& socket_ip = socket->GetLocalAddress().ipaddr();
391 if (socket_addr.ipaddr() == port()->ip()) { 391 if (socket_ip == port()->ip() || IPIsAny(port()->ip())) {
392 LOG_J(LS_VERBOSE, this) << "Connection established to " 392 if (socket_ip == port()->ip()) {
393 << socket->GetRemoteAddress().ToSensitiveString(); 393 LOG_J(LS_VERBOSE, this) << "Connection established to "
394 } else if (IPIsAny(port()->ip())) { 394 << socket->GetRemoteAddress().ToSensitiveString();
395 LOG(LS_WARNING) << "Socket is bound to a different address:" 395 } else {
396 << socket_addr.ipaddr().ToString() 396 LOG(LS_WARNING) << "Socket is bound to a different address:"
397 << ", rather then the local port:" 397 << socket->GetLocalAddress().ipaddr().ToString()
398 << port()->ip().ToString() 398 << ", rather then the local port:"
399 << ". Still allowing it since it's any address" 399 << port()->ip().ToString()
400 << ", possibly caused by multi-routes being disabled."; 400 << ". Still allowing it since it's any address"
401 } else if (socket_addr.IsLoopbackIP()) { 401 << ", possibly caused by multi-routes being disabled.";
402 LOG(LS_WARNING) << "Socket is bound to a different address:" 402 }
403 << socket_addr.ipaddr().ToString() 403 set_connected(true);
404 << ", rather then the local port:" 404 connection_pending_ = false;
405 << port()->ip().ToString()
406 << ". Still allowing it since it's localhost.";
407 } else { 405 } else {
408 LOG_J(LS_WARNING, this) << "Dropping connection as TCP socket bound to IP " 406 LOG_J(LS_WARNING, this) << "Dropping connection as TCP socket bound to IP "
409 << socket_addr.ipaddr().ToSensitiveString() 407 << socket_ip.ToSensitiveString()
410 << ", different from the local candidate IP " 408 << ", different from the local candidate IP "
411 << port()->ip().ToSensitiveString(); 409 << port()->ip().ToSensitiveString();
412 OnClose(socket, 0); 410 OnClose(socket, 0);
413 return;
414 } 411 }
415
416 // Connection is established successfully.
417 set_connected(true);
418 connection_pending_ = false;
419 } 412 }
420 413
421 void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) { 414 void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) {
422 ASSERT(socket == socket_.get()); 415 ASSERT(socket == socket_.get());
423 LOG_J(LS_INFO, this) << "Connection closed with error " << error; 416 LOG_J(LS_INFO, this) << "Connection closed with error " << error;
424 417
425 // Guard against the condition where IPC socket will call OnClose for every 418 // Guard against the condition where IPC socket will call OnClose for every
426 // packet it can't send. 419 // packet it can't send.
427 if (connected()) { 420 if (connected()) {
428 set_connected(false); 421 set_connected(false);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) { 505 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) {
513 if (outgoing_) { 506 if (outgoing_) {
514 socket->SignalConnect.connect(this, &TCPConnection::OnConnect); 507 socket->SignalConnect.connect(this, &TCPConnection::OnConnect);
515 } 508 }
516 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket); 509 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket);
517 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend); 510 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend);
518 socket->SignalClose.connect(this, &TCPConnection::OnClose); 511 socket->SignalClose.connect(this, &TCPConnection::OnClose);
519 } 512 }
520 513
521 } // namespace cricket 514 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/base/virtualsocketserver.cc ('k') | webrtc/p2p/base/tcpport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698