| 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" |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "net/base/address_list.h" | 14 #include "net/base/address_list.h" |
| 15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 16 #include "net/base/host_resolver.h" | 16 #include "net/base/host_resolver.h" |
| 17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 18 #include "net/socket/client_socket.h" | 18 #include "net/socket/client_socket.h" |
| 19 #include "testing/gtest/include/gtest/gtest_prod.h" | 19 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | 22 |
| 23 class LoadLog; |
| 24 |
| 23 // 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. |
| 24 // Currently no SOCKSv5 authentication is supported. | 26 // Currently no SOCKSv5 authentication is supported. |
| 25 class SOCKS5ClientSocket : public ClientSocket { | 27 class SOCKS5ClientSocket : public ClientSocket { |
| 26 public: | 28 public: |
| 27 // Takes ownership of the |transport_socket|, which should already be | 29 // Takes ownership of the |transport_socket|, which should already be |
| 28 // connected by the time Connect() is called. | 30 // connected by the time Connect() is called. |
| 29 // | 31 // |
| 30 // |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 |
| 31 // communicate to via the SOCKS layer. | 33 // communicate to via the SOCKS layer. |
| 32 SOCKS5ClientSocket(ClientSocket* transport_socket, | 34 SOCKS5ClientSocket(ClientSocket* transport_socket, |
| 33 const HostResolver::RequestInfo& req_info, | 35 const HostResolver::RequestInfo& req_info, |
| 34 HostResolver* host_resolver); | 36 HostResolver* host_resolver); |
| 35 | 37 |
| 36 // On destruction Disconnect() is called. | 38 // On destruction Disconnect() is called. |
| 37 virtual ~SOCKS5ClientSocket(); | 39 virtual ~SOCKS5ClientSocket(); |
| 38 | 40 |
| 39 // ClientSocket methods: | 41 // ClientSocket methods: |
| 40 | 42 |
| 41 // Does the SOCKS handshake and completes the protocol. | 43 // Does the SOCKS handshake and completes the protocol. |
| 42 virtual int Connect(CompletionCallback* callback); | 44 virtual int Connect(CompletionCallback* callback, LoadLog* load_log); |
| 43 virtual void Disconnect(); | 45 virtual void Disconnect(); |
| 44 virtual bool IsConnected() const; | 46 virtual bool IsConnected() const; |
| 45 virtual bool IsConnectedAndIdle() const; | 47 virtual bool IsConnectedAndIdle() const; |
| 46 | 48 |
| 47 // Socket methods: | 49 // Socket methods: |
| 48 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 50 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 49 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 51 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 50 | 52 |
| 51 virtual bool SetReceiveBufferSize(int32 size); | 53 virtual bool SetReceiveBufferSize(int32 size); |
| 52 virtual bool SetSendBufferSize(int32 size); | 54 virtual bool SetSendBufferSize(int32 size); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 size_t bytes_sent_; | 140 size_t bytes_sent_; |
| 139 size_t bytes_received_; | 141 size_t bytes_received_; |
| 140 | 142 |
| 141 size_t read_header_size; | 143 size_t read_header_size; |
| 142 | 144 |
| 143 // Used to resolve the hostname to which the SOCKS proxy will connect. | 145 // Used to resolve the hostname to which the SOCKS proxy will connect. |
| 144 SingleRequestHostResolver host_resolver_; | 146 SingleRequestHostResolver host_resolver_; |
| 145 AddressList addresses_; | 147 AddressList addresses_; |
| 146 HostResolver::RequestInfo host_request_info_; | 148 HostResolver::RequestInfo host_request_info_; |
| 147 | 149 |
| 150 scoped_refptr<LoadLog> load_log_; |
| 151 |
| 148 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocket); | 152 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocket); |
| 149 }; | 153 }; |
| 150 | 154 |
| 151 } // namespace net | 155 } // namespace net |
| 152 | 156 |
| 153 #endif // NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ | 157 #endif // NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ |
| 154 | |
| OLD | NEW |