| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ | 5 #ifndef NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ |
| 6 #define NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ | 6 #define NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // This ClientSocket is used to setup a SOCKSv5 handshake with a socks proxy. | 25 // This ClientSocket is used to setup a SOCKSv5 handshake with a socks proxy. |
| 26 // Currently no SOCKSv5 authentication is supported. | 26 // Currently no SOCKSv5 authentication is supported. |
| 27 class SOCKS5ClientSocket : public ClientSocket { | 27 class SOCKS5ClientSocket : public ClientSocket { |
| 28 public: | 28 public: |
| 29 // Takes ownership of the |transport_socket|, which should already be | 29 // Takes ownership of the |transport_socket|, which should already be |
| 30 // connected by the time Connect() is called. | 30 // connected by the time Connect() is called. |
| 31 // | 31 // |
| 32 // |req_info| contains the hostname and port to which the socket above will | 32 // |req_info| contains the hostname and port to which the socket above will |
| 33 // communicate to via the SOCKS layer. | 33 // communicate to via the SOCKS layer. |
| 34 // |
| 35 // SOCKS5 supports three modes of specifying connection endpoints: |
| 36 // (1) as an IPv4 address. |
| 37 // (2) as an IPv6 address. |
| 38 // (3) as a hostname string. |
| 39 // |
| 40 // To select mode (3), pass NULL for |host_resolver|. |
| 41 // |
| 42 // Otherwise if a non-NULL |host_resolver| is given, Connect() will first |
| 43 // try to resolve the hostname using |host_resolver|, and pass that |
| 44 // resolved address to the proxy server. If the resolve failed, Connect() |
| 45 // will fall-back to mode (3) and simply send the unresolved hosname string |
| 46 // to the SOCKS v5 proxy server. |
| 47 // |
| 48 // Passing NULL for |host_resolver| is the recommended default. |
| 34 SOCKS5ClientSocket(ClientSocket* transport_socket, | 49 SOCKS5ClientSocket(ClientSocket* transport_socket, |
| 35 const HostResolver::RequestInfo& req_info, | 50 const HostResolver::RequestInfo& req_info, |
| 36 HostResolver* host_resolver); | 51 HostResolver* host_resolver); |
| 37 | 52 |
| 38 // On destruction Disconnect() is called. | 53 // On destruction Disconnect() is called. |
| 39 virtual ~SOCKS5ClientSocket(); | 54 virtual ~SOCKS5ClientSocket(); |
| 40 | 55 |
| 41 // ClientSocket methods: | 56 // ClientSocket methods: |
| 42 | 57 |
| 43 // Does the SOCKS handshake and completes the protocol. | 58 // Does the SOCKS handshake and completes the protocol. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // This becomes true when the SOCKS handshake has completed and the | 150 // This becomes true when the SOCKS handshake has completed and the |
| 136 // overlying connection is free to communicate. | 151 // overlying connection is free to communicate. |
| 137 bool completed_handshake_; | 152 bool completed_handshake_; |
| 138 | 153 |
| 139 // These contain the bytes sent / received by the SOCKS handshake. | 154 // These contain the bytes sent / received by the SOCKS handshake. |
| 140 size_t bytes_sent_; | 155 size_t bytes_sent_; |
| 141 size_t bytes_received_; | 156 size_t bytes_received_; |
| 142 | 157 |
| 143 size_t read_header_size; | 158 size_t read_header_size; |
| 144 | 159 |
| 145 // Used to resolve the hostname to which the SOCKS proxy will connect. | 160 // If non-NULL, we will use this host resolver to resolve DNS client-side |
| 146 SingleRequestHostResolver host_resolver_; | 161 // (and fall back to proxy-side resolving if it fails). |
| 162 // Otherwise, we will do proxy-side DNS resolving. |
| 163 scoped_ptr<SingleRequestHostResolver> host_resolver_; |
| 147 AddressList addresses_; | 164 AddressList addresses_; |
| 148 HostResolver::RequestInfo host_request_info_; | 165 HostResolver::RequestInfo host_request_info_; |
| 149 | 166 |
| 150 scoped_refptr<LoadLog> load_log_; | 167 scoped_refptr<LoadLog> load_log_; |
| 151 | 168 |
| 152 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocket); | 169 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocket); |
| 153 }; | 170 }; |
| 154 | 171 |
| 155 } // namespace net | 172 } // namespace net |
| 156 | 173 |
| 157 #endif // NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ | 174 #endif // NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ |
| OLD | NEW |