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

Unified Diff: net/socket/socks5_client_socket.cc

Issue 567030: Add specific error codes for when SOCKS connect fails.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rename ERR_SOCKS_CONNECT_* --> ERR_SOCKS_CONNECTION_* Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/socket/socks5_client_socket_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/socks5_client_socket.cc
===================================================================
--- net/socket/socks5_client_socket.cc (revision 38060)
+++ net/socket/socks5_client_socket.cc (working copy)
@@ -223,7 +223,7 @@
LoadLog::AddStringLiteral(load_log_,
"Failed sending request because hostname is "
"longer than 255 characters");
- return ERR_INVALID_URL;
+ return ERR_SOCKS_CONNECTION_FAILED;
}
if (buffer_.empty()) {
@@ -266,8 +266,11 @@
if (result < 0)
return result;
- if (result == 0)
- return ERR_CONNECTION_CLOSED; // Unexpected socket close
+ if (result == 0) {
+ LoadLog::AddStringLiteral(
+ load_log_, "Connection unexpected closed while reading greeting.");
+ return ERR_SOCKS_CONNECTION_FAILED;
+ }
bytes_received_ += result;
buffer_.append(handshake_buf_->data(), result);
@@ -281,13 +284,13 @@
LoadLog::AddStringLiteral(load_log_, "Unexpected SOCKS version");
LoadLog::AddString(load_log_, StringPrintf(
"buffer_[0] = 0x%x", static_cast<int>(buffer_[0])));
- return ERR_INVALID_RESPONSE;
+ return ERR_SOCKS_CONNECTION_FAILED;
}
if (buffer_[1] != 0x00) {
LoadLog::AddStringLiteral(load_log_, "Unexpected authentication method");
LoadLog::AddString(load_log_, StringPrintf(
"buffer_[1] = 0x%x", static_cast<int>(buffer_[1])));
- return ERR_INVALID_RESPONSE; // Unknown error
+ return ERR_SOCKS_CONNECTION_FAILED;
}
buffer_.clear();
@@ -374,8 +377,11 @@
return result;
// The underlying socket closed unexpectedly.
- if (result == 0)
- return ERR_CONNECTION_CLOSED;
+ if (result == 0) {
+ LoadLog::AddStringLiteral(
+ load_log_, "Connection unexpected closed while reading handshake.");
+ return ERR_SOCKS_CONNECTION_FAILED;
+ }
buffer_.append(handshake_buf_->data(), result);
bytes_received_ += result;
@@ -389,7 +395,7 @@
"buffer_[0] = 0x%x; buffer_[2] = 0x%x",
static_cast<int>(buffer_[0]),
static_cast<int>(buffer_[2])));
- return ERR_INVALID_RESPONSE;
+ return ERR_SOCKS_CONNECTION_FAILED;
}
if (buffer_[1] != 0x00) {
LoadLog::AddStringLiteral(load_log_,
@@ -401,7 +407,7 @@
LoadLog::AddString(load_log_, StringPrintf(
"buffer_[1] = 0x%x", static_cast<int>(buffer_[1])));
}
- return ERR_FAILED;
+ return ERR_SOCKS_CONNECTION_FAILED;
}
// We check the type of IP/Domain the server returns and accordingly
@@ -421,7 +427,7 @@
LoadLog::AddStringLiteral(load_log_, "Unknown address type in response");
LoadLog::AddString(load_log_, StringPrintf(
"buffer_[3] = 0x%x", static_cast<int>(buffer_[3])));
- return ERR_INVALID_RESPONSE;
+ return ERR_SOCKS_CONNECTION_FAILED;
}
read_header_size += 2; // for the port.
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/socket/socks5_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698