OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "net/ftp/ftp_network_transaction.h" | 5 #include "net/ftp/ftp_network_transaction.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/histogram.h" | 8 #include "base/histogram.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "net/base/connection_type_histograms.h" | 10 #include "net/base/connection_type_histograms.h" |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 int FtpNetworkTransaction::ProcessResponseQUIT( | 1097 int FtpNetworkTransaction::ProcessResponseQUIT( |
1098 const FtpCtrlResponse& response) { | 1098 const FtpCtrlResponse& response) { |
1099 ctrl_socket_->Disconnect(); | 1099 ctrl_socket_->Disconnect(); |
1100 return last_error_; | 1100 return last_error_; |
1101 } | 1101 } |
1102 | 1102 |
1103 // Data Connection | 1103 // Data Connection |
1104 | 1104 |
1105 int FtpNetworkTransaction::DoDataConnect() { | 1105 int FtpNetworkTransaction::DoDataConnect() { |
1106 next_state_ = STATE_DATA_CONNECT_COMPLETE; | 1106 next_state_ = STATE_DATA_CONNECT_COMPLETE; |
1107 AddressList data_addresses; | 1107 AddressList data_address; |
1108 // TODO(phajdan.jr): Use exactly same IP address as the control socket. | 1108 // Connect to the same host as the control socket to prevent PASV port |
1109 // If the DNS name resolves to several different IPs, and they are different | 1109 // scanning attacks. |
1110 // physical servers, this will break. However, that configuration is very rare | 1110 int rv = ctrl_socket_->GetPeerAddress(&data_address); |
1111 // in practice. | 1111 if (rv != OK) |
1112 data_addresses.Copy(addresses_.head()); | 1112 return Stop(rv); |
1113 data_addresses.SetPort(data_connection_port_); | 1113 data_address.SetPort(data_connection_port_); |
1114 data_socket_.reset(socket_factory_->CreateTCPClientSocket(data_addresses)); | 1114 data_socket_.reset(socket_factory_->CreateTCPClientSocket(data_address)); |
1115 return data_socket_->Connect(&io_callback_, load_log_); | 1115 return data_socket_->Connect(&io_callback_, load_log_); |
1116 } | 1116 } |
1117 | 1117 |
1118 int FtpNetworkTransaction::DoDataConnectComplete(int result) { | 1118 int FtpNetworkTransaction::DoDataConnectComplete(int result) { |
1119 RecordDataConnectionError(result); | 1119 RecordDataConnectionError(result); |
1120 if (retr_failed_) { | 1120 if (retr_failed_) { |
1121 next_state_ = STATE_CTRL_WRITE_CWD; | 1121 next_state_ = STATE_CTRL_WRITE_CWD; |
1122 } else { | 1122 } else { |
1123 next_state_ = STATE_CTRL_WRITE_SIZE; | 1123 next_state_ = STATE_CTRL_WRITE_SIZE; |
1124 } | 1124 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 if (!had_error_type[type]) { | 1230 if (!had_error_type[type]) { |
1231 had_error_type[type] = true; | 1231 had_error_type[type] = true; |
1232 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", | 1232 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", |
1233 type, NUM_OF_NET_ERROR_TYPES); | 1233 type, NUM_OF_NET_ERROR_TYPES); |
1234 } | 1234 } |
1235 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", | 1235 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", |
1236 type, NUM_OF_NET_ERROR_TYPES); | 1236 type, NUM_OF_NET_ERROR_TYPES); |
1237 } | 1237 } |
1238 | 1238 |
1239 } // namespace net | 1239 } // namespace net |
OLD | NEW |