| 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/base/net_log.h" |
| 18 #include "net/socket/client_socket.h" | 19 #include "net/socket/client_socket.h" |
| 19 #include "testing/gtest/include/gtest/gtest_prod.h" | 20 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 20 | 21 |
| 21 namespace net { | 22 namespace net { |
| 22 | 23 |
| 23 class LoadLog; | 24 class BoundNetLog; |
| 24 | 25 |
| 25 // This ClientSocket is used to setup a SOCKSv5 handshake with a socks proxy. | 26 // This ClientSocket is used to setup a SOCKSv5 handshake with a socks proxy. |
| 26 // Currently no SOCKSv5 authentication is supported. | 27 // Currently no SOCKSv5 authentication is supported. |
| 27 class SOCKS5ClientSocket : public ClientSocket { | 28 class SOCKS5ClientSocket : public ClientSocket { |
| 28 public: | 29 public: |
| 29 // Takes ownership of the |transport_socket|, which should already be | 30 // Takes ownership of the |transport_socket|, which should already be |
| 30 // connected by the time Connect() is called. | 31 // connected by the time Connect() is called. |
| 31 // | 32 // |
| 32 // |req_info| contains the hostname and port to which the socket above will | 33 // |req_info| contains the hostname and port to which the socket above will |
| 33 // communicate to via the SOCKS layer. | 34 // communicate to via the SOCKS layer. |
| 34 // | 35 // |
| 35 // Although SOCKS 5 supports 3 different modes of addressing, we will | 36 // Although SOCKS 5 supports 3 different modes of addressing, we will |
| 36 // always pass it a hostname. This means the DNS resolving is done | 37 // always pass it a hostname. This means the DNS resolving is done |
| 37 // proxy side. | 38 // proxy side. |
| 38 SOCKS5ClientSocket(ClientSocket* transport_socket, | 39 SOCKS5ClientSocket(ClientSocket* transport_socket, |
| 39 const HostResolver::RequestInfo& req_info); | 40 const HostResolver::RequestInfo& req_info); |
| 40 | 41 |
| 41 // On destruction Disconnect() is called. | 42 // On destruction Disconnect() is called. |
| 42 virtual ~SOCKS5ClientSocket(); | 43 virtual ~SOCKS5ClientSocket(); |
| 43 | 44 |
| 44 // ClientSocket methods: | 45 // ClientSocket methods: |
| 45 | 46 |
| 46 // Does the SOCKS handshake and completes the protocol. | 47 // Does the SOCKS handshake and completes the protocol. |
| 47 virtual int Connect(CompletionCallback* callback, LoadLog* load_log); | 48 virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log); |
| 48 virtual void Disconnect(); | 49 virtual void Disconnect(); |
| 49 virtual bool IsConnected() const; | 50 virtual bool IsConnected() const; |
| 50 virtual bool IsConnectedAndIdle() const; | 51 virtual bool IsConnectedAndIdle() const; |
| 51 | 52 |
| 52 // Socket methods: | 53 // Socket methods: |
| 53 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 54 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 54 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 55 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 55 | 56 |
| 56 virtual bool SetReceiveBufferSize(int32 size); | 57 virtual bool SetReceiveBufferSize(int32 size); |
| 57 virtual bool SetSendBufferSize(int32 size); | 58 virtual bool SetSendBufferSize(int32 size); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 bool completed_handshake_; | 127 bool completed_handshake_; |
| 127 | 128 |
| 128 // These contain the bytes sent / received by the SOCKS handshake. | 129 // These contain the bytes sent / received by the SOCKS handshake. |
| 129 size_t bytes_sent_; | 130 size_t bytes_sent_; |
| 130 size_t bytes_received_; | 131 size_t bytes_received_; |
| 131 | 132 |
| 132 size_t read_header_size; | 133 size_t read_header_size; |
| 133 | 134 |
| 134 HostResolver::RequestInfo host_request_info_; | 135 HostResolver::RequestInfo host_request_info_; |
| 135 | 136 |
| 136 scoped_refptr<LoadLog> load_log_; | 137 BoundNetLog net_log_; |
| 137 | 138 |
| 138 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocket); | 139 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocket); |
| 139 }; | 140 }; |
| 140 | 141 |
| 141 } // namespace net | 142 } // namespace net |
| 142 | 143 |
| 143 #endif // NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ | 144 #endif // NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ |
| OLD | NEW |