blob: 16ef3bd8edb99b6d44e30edda9833104efa71fd6 [file] [log] [blame]
[email protected]9eb7b11b2012-03-28 20:19:311// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]3cd17242009-06-23 02:59:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "net/socket/socks_client_socket.h"
6
7#include "base/basictypes.h"
[email protected]aa22b242011-11-16 18:58:298#include "base/bind.h"
[email protected]3cd17242009-06-23 02:59:029#include "base/compiler_specific.h"
[email protected]9eb7b11b2012-03-28 20:19:3110#include "base/sys_byteorder.h"
[email protected]3cd17242009-06-23 02:59:0211#include "net/base/io_buffer.h"
[email protected]9e743cd2010-03-16 07:03:5312#include "net/base/net_log.h"
[email protected]3cd17242009-06-23 02:59:0213#include "net/base/net_util.h"
[email protected]a796bcec2010-03-22 17:17:2614#include "net/socket/client_socket_handle.h"
[email protected]3cd17242009-06-23 02:59:0215
16namespace net {
17
18// Every SOCKS server requests a user-id from the client. It is optional
19// and we send an empty string.
20static const char kEmptyUserId[] = "";
21
[email protected]3cd17242009-06-23 02:59:0222// For SOCKS4, the client sends 8 bytes plus the size of the user-id.
[email protected]76a51ac82009-06-28 07:58:5823static const unsigned int kWriteHeaderSize = 8;
[email protected]3cd17242009-06-23 02:59:0224
[email protected]034d3892011-03-29 04:07:2125// For SOCKS4 the server sends 8 bytes for acknowledgement.
[email protected]76a51ac82009-06-28 07:58:5826static const unsigned int kReadHeaderSize = 8;
[email protected]3cd17242009-06-23 02:59:0227
28// Server Response codes for SOCKS.
29static const uint8 kServerResponseOk = 0x5A;
30static const uint8 kServerResponseRejected = 0x5B;
31static const uint8 kServerResponseNotReachable = 0x5C;
32static const uint8 kServerResponseMismatchedUserId = 0x5D;
33
34static const uint8 kSOCKSVersion4 = 0x04;
35static const uint8 kSOCKSStreamRequest = 0x01;
36
[email protected]034d3892011-03-29 04:07:2137// A struct holding the essential details of the SOCKS4 Server Request.
[email protected]3cd17242009-06-23 02:59:0238// The port in the header is stored in network byte order.
39struct SOCKS4ServerRequest {
40 uint8 version;
41 uint8 command;
42 uint16 nw_port;
43 uint8 ip[4];
44};
45COMPILE_ASSERT(sizeof(SOCKS4ServerRequest) == kWriteHeaderSize,
46 socks4_server_request_struct_wrong_size);
47
[email protected]034d3892011-03-29 04:07:2148// A struct holding details of the SOCKS4 Server Response.
[email protected]3cd17242009-06-23 02:59:0249struct SOCKS4ServerResponse {
50 uint8 reserved_null;
51 uint8 code;
52 uint16 port;
53 uint8 ip[4];
54};
55COMPILE_ASSERT(sizeof(SOCKS4ServerResponse) == kReadHeaderSize,
56 socks4_server_response_struct_wrong_size);
57
[email protected]a796bcec2010-03-22 17:17:2658SOCKSClientSocket::SOCKSClientSocket(ClientSocketHandle* transport_socket,
[email protected]3cd17242009-06-23 02:59:0259 const HostResolver::RequestInfo& req_info,
60 HostResolver* host_resolver)
[email protected]83039bb2011-12-09 18:43:5561 : transport_(transport_socket),
[email protected]3cd17242009-06-23 02:59:0262 next_state_(STATE_NONE),
[email protected]3cd17242009-06-23 02:59:0263 completed_handshake_(false),
64 bytes_sent_(0),
65 bytes_received_(0),
[email protected]76a51ac82009-06-28 07:58:5866 host_resolver_(host_resolver),
[email protected]a2006ece2010-04-23 16:44:0267 host_request_info_(req_info),
68 net_log_(transport_socket->socket()->NetLog()) {
[email protected]3cd17242009-06-23 02:59:0269}
70
[email protected]3268023f2011-05-05 00:08:1071SOCKSClientSocket::SOCKSClientSocket(StreamSocket* transport_socket,
[email protected]a796bcec2010-03-22 17:17:2672 const HostResolver::RequestInfo& req_info,
73 HostResolver* host_resolver)
[email protected]83039bb2011-12-09 18:43:5574 : transport_(new ClientSocketHandle()),
[email protected]a796bcec2010-03-22 17:17:2675 next_state_(STATE_NONE),
[email protected]a796bcec2010-03-22 17:17:2676 completed_handshake_(false),
77 bytes_sent_(0),
78 bytes_received_(0),
79 host_resolver_(host_resolver),
[email protected]a2006ece2010-04-23 16:44:0280 host_request_info_(req_info),
81 net_log_(transport_socket->NetLog()) {
[email protected]a796bcec2010-03-22 17:17:2682 transport_->set_socket(transport_socket);
83}
84
[email protected]3cd17242009-06-23 02:59:0285SOCKSClientSocket::~SOCKSClientSocket() {
86 Disconnect();
87}
88
[email protected]83039bb2011-12-09 18:43:5589int SOCKSClientSocket::Connect(const CompletionCallback& callback) {
[email protected]3cd17242009-06-23 02:59:0290 DCHECK(transport_.get());
[email protected]a796bcec2010-03-22 17:17:2691 DCHECK(transport_->socket());
[email protected]3cd17242009-06-23 02:59:0292 DCHECK_EQ(STATE_NONE, next_state_);
[email protected]83039bb2011-12-09 18:43:5593 DCHECK(user_callback_.is_null());
[email protected]3cd17242009-06-23 02:59:0294
95 // If already connected, then just return OK.
96 if (completed_handshake_)
97 return OK;
98
99 next_state_ = STATE_RESOLVE_HOST;
[email protected]5a05c47a2009-11-02 23:25:19100
[email protected]3aa4af042012-06-14 21:02:31101 net_log_.BeginEvent(NetLog::TYPE_SOCKS_CONNECT);
[email protected]3cd17242009-06-23 02:59:02102
103 int rv = DoLoop(OK);
[email protected]5a05c47a2009-11-02 23:25:19104 if (rv == ERR_IO_PENDING) {
[email protected]83039bb2011-12-09 18:43:55105 user_callback_ = callback;
[email protected]5a05c47a2009-11-02 23:25:19106 } else {
[email protected]d7fd1782011-02-08 19:16:43107 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SOCKS_CONNECT, rv);
[email protected]5a05c47a2009-11-02 23:25:19108 }
[email protected]3cd17242009-06-23 02:59:02109 return rv;
110}
111
112void SOCKSClientSocket::Disconnect() {
113 completed_handshake_ = false;
[email protected]16a02742010-01-07 22:50:10114 host_resolver_.Cancel();
[email protected]a796bcec2010-03-22 17:17:26115 transport_->socket()->Disconnect();
[email protected]16a02742010-01-07 22:50:10116
117 // Reset other states to make sure they aren't mistakenly used later.
118 // These are the states initialized by Connect().
119 next_state_ = STATE_NONE;
[email protected]dbf036f2011-12-06 23:33:24120 user_callback_.Reset();
[email protected]3cd17242009-06-23 02:59:02121}
122
123bool SOCKSClientSocket::IsConnected() const {
[email protected]a796bcec2010-03-22 17:17:26124 return completed_handshake_ && transport_->socket()->IsConnected();
[email protected]3cd17242009-06-23 02:59:02125}
126
127bool SOCKSClientSocket::IsConnectedAndIdle() const {
[email protected]a796bcec2010-03-22 17:17:26128 return completed_handshake_ && transport_->socket()->IsConnectedAndIdle();
[email protected]3cd17242009-06-23 02:59:02129}
130
[email protected]e4be2dd2010-12-14 00:44:39131const BoundNetLog& SOCKSClientSocket::NetLog() const {
132 return net_log_;
133}
134
[email protected]9b5614a2010-08-25 20:29:45135void SOCKSClientSocket::SetSubresourceSpeculation() {
136 if (transport_.get() && transport_->socket()) {
137 transport_->socket()->SetSubresourceSpeculation();
138 } else {
139 NOTREACHED();
140 }
141}
142
143void SOCKSClientSocket::SetOmniboxSpeculation() {
144 if (transport_.get() && transport_->socket()) {
145 transport_->socket()->SetOmniboxSpeculation();
146 } else {
147 NOTREACHED();
148 }
149}
150
[email protected]0f873e82010-09-02 16:09:01151bool SOCKSClientSocket::WasEverUsed() const {
152 if (transport_.get() && transport_->socket()) {
153 return transport_->socket()->WasEverUsed();
154 }
155 NOTREACHED();
156 return false;
157}
158
[email protected]7f7e92392010-10-26 18:29:29159bool SOCKSClientSocket::UsingTCPFastOpen() const {
160 if (transport_.get() && transport_->socket()) {
161 return transport_->socket()->UsingTCPFastOpen();
162 }
163 NOTREACHED();
164 return false;
165}
166
[email protected]5e6efa52011-06-27 17:26:41167int64 SOCKSClientSocket::NumBytesRead() const {
168 if (transport_.get() && transport_->socket()) {
169 return transport_->socket()->NumBytesRead();
170 }
171 NOTREACHED();
172 return -1;
173}
174
175base::TimeDelta SOCKSClientSocket::GetConnectTimeMicros() const {
176 if (transport_.get() && transport_->socket()) {
177 return transport_->socket()->GetConnectTimeMicros();
178 }
179 NOTREACHED();
180 return base::TimeDelta::FromMicroseconds(-1);
181}
182
[email protected]2d88e7d2012-07-19 17:55:17183bool SOCKSClientSocket::WasNpnNegotiated() const {
184 if (transport_.get() && transport_->socket()) {
185 return transport_->socket()->WasNpnNegotiated();
186 }
187 NOTREACHED();
188 return false;
189}
190
[email protected]33661e482012-04-03 16:16:26191NextProto SOCKSClientSocket::GetNegotiatedProtocol() const {
192 if (transport_.get() && transport_->socket()) {
193 return transport_->socket()->GetNegotiatedProtocol();
194 }
195 NOTREACHED();
196 return kProtoUnknown;
197}
198
[email protected]2d88e7d2012-07-19 17:55:17199bool SOCKSClientSocket::GetSSLInfo(SSLInfo* ssl_info) {
200 if (transport_.get() && transport_->socket()) {
201 return transport_->socket()->GetSSLInfo(ssl_info);
202 }
203 NOTREACHED();
204 return false;
205
206}
207
[email protected]3cd17242009-06-23 02:59:02208// Read is called by the transport layer above to read. This can only be done
209// if the SOCKS handshake is complete.
210int SOCKSClientSocket::Read(IOBuffer* buf, int buf_len,
[email protected]3f55aa12011-12-07 02:03:33211 const CompletionCallback& callback) {
212 DCHECK(completed_handshake_);
213 DCHECK_EQ(STATE_NONE, next_state_);
[email protected]83039bb2011-12-09 18:43:55214 DCHECK(user_callback_.is_null());
[email protected]3cd17242009-06-23 02:59:02215
[email protected]a796bcec2010-03-22 17:17:26216 return transport_->socket()->Read(buf, buf_len, callback);
[email protected]3cd17242009-06-23 02:59:02217}
218
219// Write is called by the transport layer. This can only be done if the
220// SOCKS handshake is complete.
221int SOCKSClientSocket::Write(IOBuffer* buf, int buf_len,
[email protected]83039bb2011-12-09 18:43:55222 const CompletionCallback& callback) {
[email protected]3cd17242009-06-23 02:59:02223 DCHECK(completed_handshake_);
224 DCHECK_EQ(STATE_NONE, next_state_);
[email protected]83039bb2011-12-09 18:43:55225 DCHECK(user_callback_.is_null());
[email protected]3cd17242009-06-23 02:59:02226
[email protected]a796bcec2010-03-22 17:17:26227 return transport_->socket()->Write(buf, buf_len, callback);
[email protected]3cd17242009-06-23 02:59:02228}
229
[email protected]d3f66572009-09-09 22:38:04230bool SOCKSClientSocket::SetReceiveBufferSize(int32 size) {
[email protected]a796bcec2010-03-22 17:17:26231 return transport_->socket()->SetReceiveBufferSize(size);
[email protected]d3f66572009-09-09 22:38:04232}
233
234bool SOCKSClientSocket::SetSendBufferSize(int32 size) {
[email protected]a796bcec2010-03-22 17:17:26235 return transport_->socket()->SetSendBufferSize(size);
[email protected]d3f66572009-09-09 22:38:04236}
237
[email protected]3cd17242009-06-23 02:59:02238void SOCKSClientSocket::DoCallback(int result) {
239 DCHECK_NE(ERR_IO_PENDING, result);
[email protected]83039bb2011-12-09 18:43:55240 DCHECK(!user_callback_.is_null());
[email protected]3cd17242009-06-23 02:59:02241
242 // Since Run() may result in Read being called,
243 // clear user_callback_ up front.
[email protected]83039bb2011-12-09 18:43:55244 CompletionCallback c = user_callback_;
245 user_callback_.Reset();
246 DVLOG(1) << "Finished setting up SOCKS handshake";
247 c.Run(result);
[email protected]3cd17242009-06-23 02:59:02248}
249
250void SOCKSClientSocket::OnIOComplete(int result) {
251 DCHECK_NE(STATE_NONE, next_state_);
252 int rv = DoLoop(result);
[email protected]5a05c47a2009-11-02 23:25:19253 if (rv != ERR_IO_PENDING) {
[email protected]d7fd1782011-02-08 19:16:43254 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SOCKS_CONNECT, rv);
[email protected]3cd17242009-06-23 02:59:02255 DoCallback(rv);
[email protected]5a05c47a2009-11-02 23:25:19256 }
[email protected]3cd17242009-06-23 02:59:02257}
258
259int SOCKSClientSocket::DoLoop(int last_io_result) {
260 DCHECK_NE(next_state_, STATE_NONE);
261 int rv = last_io_result;
262 do {
263 State state = next_state_;
264 next_state_ = STATE_NONE;
265 switch (state) {
266 case STATE_RESOLVE_HOST:
267 DCHECK_EQ(OK, rv);
268 rv = DoResolveHost();
269 break;
270 case STATE_RESOLVE_HOST_COMPLETE:
271 rv = DoResolveHostComplete(rv);
272 break;
273 case STATE_HANDSHAKE_WRITE:
274 DCHECK_EQ(OK, rv);
275 rv = DoHandshakeWrite();
276 break;
277 case STATE_HANDSHAKE_WRITE_COMPLETE:
278 rv = DoHandshakeWriteComplete(rv);
279 break;
280 case STATE_HANDSHAKE_READ:
281 DCHECK_EQ(OK, rv);
282 rv = DoHandshakeRead();
283 break;
284 case STATE_HANDSHAKE_READ_COMPLETE:
285 rv = DoHandshakeReadComplete(rv);
286 break;
287 default:
288 NOTREACHED() << "bad state";
289 rv = ERR_UNEXPECTED;
290 break;
291 }
292 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
293 return rv;
294}
295
296int SOCKSClientSocket::DoResolveHost() {
[email protected]3cd17242009-06-23 02:59:02297 next_state_ = STATE_RESOLVE_HOST_COMPLETE;
[email protected]034d3892011-03-29 04:07:21298 // SOCKS4 only supports IPv4 addresses, so only try getting the IPv4
299 // addresses for the target host.
300 host_request_info_.set_address_family(ADDRESS_FAMILY_IPV4);
[email protected]ec08bb22009-08-12 00:25:12301 return host_resolver_.Resolve(
[email protected]aa22b242011-11-16 18:58:29302 host_request_info_, &addresses_,
303 base::Bind(&SOCKSClientSocket::OnIOComplete, base::Unretained(this)),
304 net_log_);
[email protected]3cd17242009-06-23 02:59:02305}
306
307int SOCKSClientSocket::DoResolveHostComplete(int result) {
[email protected]034d3892011-03-29 04:07:21308 if (result != OK) {
309 // Resolving the hostname failed; fail the request rather than automatically
310 // falling back to SOCKS4a (since it can be confusing to see invalid IP
311 // addresses being sent to the SOCKS4 server when it doesn't support 4A.)
312 return result;
[email protected]3cd17242009-06-23 02:59:02313 }
314
[email protected]034d3892011-03-29 04:07:21315 next_state_ = STATE_HANDSHAKE_WRITE;
[email protected]3cd17242009-06-23 02:59:02316 return OK;
317}
318
319// Builds the buffer that is to be sent to the server.
[email protected]76a51ac82009-06-28 07:58:58320const std::string SOCKSClientSocket::BuildHandshakeWriteBuffer() const {
[email protected]76a51ac82009-06-28 07:58:58321 SOCKS4ServerRequest request;
322 request.version = kSOCKSVersion4;
323 request.command = kSOCKSStreamRequest;
[email protected]9eb7b11b2012-03-28 20:19:31324 request.nw_port = base::HostToNet16(host_request_info_.port());
[email protected]3cd17242009-06-23 02:59:02325
[email protected]7054e78f2012-05-07 21:44:56326 DCHECK(!addresses_.empty());
327 const IPEndPoint& endpoint = addresses_.front();
[email protected]3cd17242009-06-23 02:59:02328
[email protected]034d3892011-03-29 04:07:21329 // We disabled IPv6 results when resolving the hostname, so none of the
330 // results in the list will be IPv6.
331 // TODO(eroman): we only ever use the first address in the list. It would be
332 // more robust to try all the IP addresses we have before
333 // failing the connect attempt.
[email protected]e466aaf2012-12-13 01:46:44334 CHECK_EQ(ADDRESS_FAMILY_IPV4, endpoint.GetFamily());
[email protected]7054e78f2012-05-07 21:44:56335 CHECK_LE(endpoint.address().size(), sizeof(request.ip));
336 memcpy(&request.ip, &endpoint.address()[0], endpoint.address().size());
[email protected]034d3892011-03-29 04:07:21337
[email protected]7054e78f2012-05-07 21:44:56338 DVLOG(1) << "Resolved Host is : " << endpoint.ToStringWithoutPort();
[email protected]3cd17242009-06-23 02:59:02339
[email protected]76a51ac82009-06-28 07:58:58340 std::string handshake_data(reinterpret_cast<char*>(&request),
341 sizeof(request));
342 handshake_data.append(kEmptyUserId, arraysize(kEmptyUserId));
[email protected]3cd17242009-06-23 02:59:02343
[email protected]76a51ac82009-06-28 07:58:58344 return handshake_data;
[email protected]3cd17242009-06-23 02:59:02345}
346
347// Writes the SOCKS handshake data to the underlying socket connection.
348int SOCKSClientSocket::DoHandshakeWrite() {
349 next_state_ = STATE_HANDSHAKE_WRITE_COMPLETE;
350
[email protected]76a51ac82009-06-28 07:58:58351 if (buffer_.empty()) {
352 buffer_ = BuildHandshakeWriteBuffer();
[email protected]3cd17242009-06-23 02:59:02353 bytes_sent_ = 0;
354 }
355
[email protected]76a51ac82009-06-28 07:58:58356 int handshake_buf_len = buffer_.size() - bytes_sent_;
357 DCHECK_GT(handshake_buf_len, 0);
358 handshake_buf_ = new IOBuffer(handshake_buf_len);
359 memcpy(handshake_buf_->data(), &buffer_[bytes_sent_],
360 handshake_buf_len);
[email protected]83039bb2011-12-09 18:43:55361 return transport_->socket()->Write(
362 handshake_buf_, handshake_buf_len,
363 base::Bind(&SOCKSClientSocket::OnIOComplete, base::Unretained(this)));
[email protected]3cd17242009-06-23 02:59:02364}
365
366int SOCKSClientSocket::DoHandshakeWriteComplete(int result) {
[email protected]3cd17242009-06-23 02:59:02367 if (result < 0)
368 return result;
369
[email protected]76a51ac82009-06-28 07:58:58370 // We ignore the case when result is 0, since the underlying Write
371 // may return spurious writes while waiting on the socket.
372
[email protected]3cd17242009-06-23 02:59:02373 bytes_sent_ += result;
[email protected]76a51ac82009-06-28 07:58:58374 if (bytes_sent_ == buffer_.size()) {
[email protected]3cd17242009-06-23 02:59:02375 next_state_ = STATE_HANDSHAKE_READ;
[email protected]76a51ac82009-06-28 07:58:58376 buffer_.clear();
377 } else if (bytes_sent_ < buffer_.size()) {
[email protected]3cd17242009-06-23 02:59:02378 next_state_ = STATE_HANDSHAKE_WRITE;
379 } else {
380 return ERR_UNEXPECTED;
381 }
382
383 return OK;
384}
385
386int SOCKSClientSocket::DoHandshakeRead() {
[email protected]3cd17242009-06-23 02:59:02387 next_state_ = STATE_HANDSHAKE_READ_COMPLETE;
388
[email protected]76a51ac82009-06-28 07:58:58389 if (buffer_.empty()) {
[email protected]3cd17242009-06-23 02:59:02390 bytes_received_ = 0;
391 }
392
[email protected]76a51ac82009-06-28 07:58:58393 int handshake_buf_len = kReadHeaderSize - bytes_received_;
394 handshake_buf_ = new IOBuffer(handshake_buf_len);
[email protected]a796bcec2010-03-22 17:17:26395 return transport_->socket()->Read(handshake_buf_, handshake_buf_len,
[email protected]83039bb2011-12-09 18:43:55396 base::Bind(&SOCKSClientSocket::OnIOComplete,
397 base::Unretained(this)));
[email protected]3cd17242009-06-23 02:59:02398}
399
400int SOCKSClientSocket::DoHandshakeReadComplete(int result) {
[email protected]3cd17242009-06-23 02:59:02401 if (result < 0)
402 return result;
[email protected]76a51ac82009-06-28 07:58:58403
404 // The underlying socket closed unexpectedly.
405 if (result == 0)
406 return ERR_CONNECTION_CLOSED;
407
[email protected]d5a309592010-02-05 02:22:52408 if (bytes_received_ + result > kReadHeaderSize) {
[email protected]9e743cd2010-03-16 07:03:53409 // TODO(eroman): Describe failure in NetLog.
[email protected]d5a309592010-02-05 02:22:52410 return ERR_SOCKS_CONNECTION_FAILED;
411 }
[email protected]3cd17242009-06-23 02:59:02412
[email protected]76a51ac82009-06-28 07:58:58413 buffer_.append(handshake_buf_->data(), result);
[email protected]3cd17242009-06-23 02:59:02414 bytes_received_ += result;
[email protected]76a51ac82009-06-28 07:58:58415 if (bytes_received_ < kReadHeaderSize) {
[email protected]3cd17242009-06-23 02:59:02416 next_state_ = STATE_HANDSHAKE_READ;
417 return OK;
418 }
419
[email protected]76a51ac82009-06-28 07:58:58420 const SOCKS4ServerResponse* response =
421 reinterpret_cast<const SOCKS4ServerResponse*>(buffer_.data());
[email protected]3cd17242009-06-23 02:59:02422
423 if (response->reserved_null != 0x00) {
424 LOG(ERROR) << "Unknown response from SOCKS server.";
[email protected]d5a309592010-02-05 02:22:52425 return ERR_SOCKS_CONNECTION_FAILED;
[email protected]3cd17242009-06-23 02:59:02426 }
427
[email protected]3cd17242009-06-23 02:59:02428 switch (response->code) {
429 case kServerResponseOk:
430 completed_handshake_ = true;
431 return OK;
432 case kServerResponseRejected:
433 LOG(ERROR) << "SOCKS request rejected or failed";
[email protected]d5a309592010-02-05 02:22:52434 return ERR_SOCKS_CONNECTION_FAILED;
[email protected]3cd17242009-06-23 02:59:02435 case kServerResponseNotReachable:
436 LOG(ERROR) << "SOCKS request failed because client is not running "
437 << "identd (or not reachable from the server)";
[email protected]d5a309592010-02-05 02:22:52438 return ERR_SOCKS_CONNECTION_HOST_UNREACHABLE;
[email protected]3cd17242009-06-23 02:59:02439 case kServerResponseMismatchedUserId:
440 LOG(ERROR) << "SOCKS request failed because client's identd could "
441 << "not confirm the user ID string in the request";
[email protected]d5a309592010-02-05 02:22:52442 return ERR_SOCKS_CONNECTION_FAILED;
[email protected]3cd17242009-06-23 02:59:02443 default:
444 LOG(ERROR) << "SOCKS server sent unknown response";
[email protected]d5a309592010-02-05 02:22:52445 return ERR_SOCKS_CONNECTION_FAILED;
[email protected]3cd17242009-06-23 02:59:02446 }
447
448 // Note: we ignore the last 6 bytes as specified by the SOCKS protocol
449}
450
[email protected]a3528692012-06-08 00:11:42451int SOCKSClientSocket::GetPeerAddress(IPEndPoint* address) const {
[email protected]a796bcec2010-03-22 17:17:26452 return transport_->socket()->GetPeerAddress(address);
[email protected]3cd17242009-06-23 02:59:02453}
[email protected]3cd17242009-06-23 02:59:02454
[email protected]e7f74da2011-04-19 23:49:35455int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const {
456 return transport_->socket()->GetLocalAddress(address);
457}
458
[email protected]3cd17242009-06-23 02:59:02459} // namespace net