56 lines
2.0 KiB
Diff
56 lines
2.0 KiB
Diff
diff --git a/net/socket/socks5_client_socket.cc b/net/socket/socks5_client_socket.cc
|
|
index 0390ad8c2cf484b9f80e9237259aab8ee2c75642..0286937c6c60c97e9aae6fbc1467347ca59fd115 100644
|
|
--- a/net/socket/socks5_client_socket.cc
|
|
+++ b/net/socket/socks5_client_socket.cc
|
|
@@ -239,6 +239,9 @@ int SOCKS5ClientSocket::DoLoop(int last_io_result) {
|
|
net_log_.EndEventWithNetErrorCode(NetLogEventType::SOCKS5_GREET_READ,
|
|
rv);
|
|
break;
|
|
+ case STATE_AUTH:
|
|
+ rv = DoAuth(rv);
|
|
+ break;
|
|
case STATE_HANDSHAKE_WRITE:
|
|
DCHECK_EQ(OK, rv);
|
|
net_log_.BeginEvent(NetLogEventType::SOCKS5_HANDSHAKE_WRITE);
|
|
@@ -268,8 +271,6 @@ int SOCKS5ClientSocket::DoLoop(int last_io_result) {
|
|
return rv;
|
|
}
|
|
|
|
-const char kSOCKS5GreetWriteData[] = { 0x05, 0x01, 0x00 }; // no authentication
|
|
-
|
|
int SOCKS5ClientSocket::DoGreetWrite() {
|
|
// Since we only have 1 byte to send the hostname length in, if the
|
|
// URL has a hostname longer than 255 characters we can't send it.
|
|
@@ -279,8 +280,12 @@ int SOCKS5ClientSocket::DoGreetWrite() {
|
|
}
|
|
|
|
if (buffer_.empty()) {
|
|
- buffer_ =
|
|
- std::string(kSOCKS5GreetWriteData, base::size(kSOCKS5GreetWriteData));
|
|
+ const char greeting[] = {
|
|
+ 0x05, // SOCKS version
|
|
+ 0x01, // number of authentication methods
|
|
+ static_cast<char>(auth_method()),
|
|
+ };
|
|
+ buffer_ = std::string(greeting, sizeof(greeting));
|
|
bytes_sent_ = 0;
|
|
}
|
|
|
|
@@ -339,14 +344,14 @@ int SOCKS5ClientSocket::DoGreetReadComplete(int result) {
|
|
"version", buffer_[0]);
|
|
return ERR_SOCKS_CONNECTION_FAILED;
|
|
}
|
|
- if (buffer_[1] != 0x00) {
|
|
+ if (buffer_[1] != auth_method()) {
|
|
net_log_.AddEventWithIntParams(NetLogEventType::SOCKS_UNEXPECTED_AUTH,
|
|
"method", buffer_[1]);
|
|
return ERR_SOCKS_CONNECTION_FAILED;
|
|
}
|
|
|
|
buffer_.clear();
|
|
- next_state_ = STATE_HANDSHAKE_WRITE;
|
|
+ next_state_ = STATE_AUTH;
|
|
return OK;
|
|
}
|
|
|