OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket/socks_client_socket.h" | 5 #include "net/socket/socks_client_socket.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
9 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
10 #include "net/base/net_log.h" | 11 #include "net/base/net_log.h" |
11 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
12 #include "net/base/sys_addrinfo.h" | 13 #include "net/base/sys_addrinfo.h" |
13 #include "net/socket/client_socket_handle.h" | 14 #include "net/socket/client_socket_handle.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 // Every SOCKS server requests a user-id from the client. It is optional | 18 // Every SOCKS server requests a user-id from the client. It is optional |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); | 274 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); |
274 return rv; | 275 return rv; |
275 } | 276 } |
276 | 277 |
277 int SOCKSClientSocket::DoResolveHost() { | 278 int SOCKSClientSocket::DoResolveHost() { |
278 next_state_ = STATE_RESOLVE_HOST_COMPLETE; | 279 next_state_ = STATE_RESOLVE_HOST_COMPLETE; |
279 // SOCKS4 only supports IPv4 addresses, so only try getting the IPv4 | 280 // SOCKS4 only supports IPv4 addresses, so only try getting the IPv4 |
280 // addresses for the target host. | 281 // addresses for the target host. |
281 host_request_info_.set_address_family(ADDRESS_FAMILY_IPV4); | 282 host_request_info_.set_address_family(ADDRESS_FAMILY_IPV4); |
282 return host_resolver_.Resolve( | 283 return host_resolver_.Resolve( |
283 host_request_info_, &addresses_, &io_callback_, net_log_); | 284 host_request_info_, &addresses_, |
| 285 base::Bind(&SOCKSClientSocket::OnIOComplete, base::Unretained(this)), |
| 286 net_log_); |
284 } | 287 } |
285 | 288 |
286 int SOCKSClientSocket::DoResolveHostComplete(int result) { | 289 int SOCKSClientSocket::DoResolveHostComplete(int result) { |
287 if (result != OK) { | 290 if (result != OK) { |
288 // Resolving the hostname failed; fail the request rather than automatically | 291 // Resolving the hostname failed; fail the request rather than automatically |
289 // falling back to SOCKS4a (since it can be confusing to see invalid IP | 292 // falling back to SOCKS4a (since it can be confusing to see invalid IP |
290 // addresses being sent to the SOCKS4 server when it doesn't support 4A.) | 293 // addresses being sent to the SOCKS4 server when it doesn't support 4A.) |
291 return result; | 294 return result; |
292 } | 295 } |
293 | 296 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 431 |
429 int SOCKSClientSocket::GetPeerAddress(AddressList* address) const { | 432 int SOCKSClientSocket::GetPeerAddress(AddressList* address) const { |
430 return transport_->socket()->GetPeerAddress(address); | 433 return transport_->socket()->GetPeerAddress(address); |
431 } | 434 } |
432 | 435 |
433 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const { | 436 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const { |
434 return transport_->socket()->GetLocalAddress(address); | 437 return transport_->socket()->GetLocalAddress(address); |
435 } | 438 } |
436 | 439 |
437 } // namespace net | 440 } // namespace net |
OLD | NEW |