OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_BASE_SOCKETADAPTERS_H_ | 11 #ifndef WEBRTC_BASE_SOCKETADAPTERS_H_ |
12 #define WEBRTC_BASE_SOCKETADAPTERS_H_ | 12 #define WEBRTC_BASE_SOCKETADAPTERS_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "webrtc/base/asyncsocket.h" | 17 #include "webrtc/base/asyncsocket.h" |
18 #include "webrtc/base/cryptstring.h" | 18 #include "webrtc/base/cryptstring.h" |
19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
20 | 20 |
21 namespace rtc { | 21 namespace rtc { |
22 | 22 |
23 struct HttpAuthContext; | 23 struct HttpAuthContext; |
24 class ByteBuffer; | 24 class ByteBufferReader; |
| 25 class ByteBufferWriter; |
25 | 26 |
26 /////////////////////////////////////////////////////////////////////////////// | 27 /////////////////////////////////////////////////////////////////////////////// |
27 | 28 |
28 // Implements a socket adapter that can buffer and process data internally, | 29 // Implements a socket adapter that can buffer and process data internally, |
29 // as in the case of connecting to a proxy, where you must speak the proxy | 30 // as in the case of connecting to a proxy, where you must speak the proxy |
30 // protocol before commencing normal socket behavior. | 31 // protocol before commencing normal socket behavior. |
31 class BufferedReadAdapter : public AsyncSocketAdapter { | 32 class BufferedReadAdapter : public AsyncSocketAdapter { |
32 public: | 33 public: |
33 BufferedReadAdapter(AsyncSocket* socket, size_t buffer_size); | 34 BufferedReadAdapter(AsyncSocket* socket, size_t buffer_size); |
34 ~BufferedReadAdapter() override; | 35 ~BufferedReadAdapter() override; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncSocksProxySocket); | 187 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncSocksProxySocket); |
187 }; | 188 }; |
188 | 189 |
189 // Implements a proxy server socket for the SOCKS protocol. | 190 // Implements a proxy server socket for the SOCKS protocol. |
190 class AsyncSocksProxyServerSocket : public AsyncProxyServerSocket { | 191 class AsyncSocksProxyServerSocket : public AsyncProxyServerSocket { |
191 public: | 192 public: |
192 explicit AsyncSocksProxyServerSocket(AsyncSocket* socket); | 193 explicit AsyncSocksProxyServerSocket(AsyncSocket* socket); |
193 | 194 |
194 private: | 195 private: |
195 void ProcessInput(char* data, size_t* len) override; | 196 void ProcessInput(char* data, size_t* len) override; |
196 void DirectSend(const ByteBuffer& buf); | 197 void DirectSend(const ByteBufferWriter& buf); |
197 | 198 |
198 void HandleHello(ByteBuffer* request); | 199 void HandleHello(ByteBufferReader* request); |
199 void SendHelloReply(uint8_t method); | 200 void SendHelloReply(uint8_t method); |
200 void HandleAuth(ByteBuffer* request); | 201 void HandleAuth(ByteBufferReader* request); |
201 void SendAuthReply(uint8_t result); | 202 void SendAuthReply(uint8_t result); |
202 void HandleConnect(ByteBuffer* request); | 203 void HandleConnect(ByteBufferReader* request); |
203 void SendConnectResult(int result, const SocketAddress& addr) override; | 204 void SendConnectResult(int result, const SocketAddress& addr) override; |
204 | 205 |
205 void Error(int error); | 206 void Error(int error); |
206 | 207 |
207 static const int kBufferSize = 1024; | 208 static const int kBufferSize = 1024; |
208 enum State { | 209 enum State { |
209 SS_HELLO, SS_AUTH, SS_CONNECT, SS_CONNECT_PENDING, SS_TUNNEL, SS_ERROR | 210 SS_HELLO, SS_AUTH, SS_CONNECT, SS_CONNECT_PENDING, SS_TUNNEL, SS_ERROR |
210 }; | 211 }; |
211 State state_; | 212 State state_; |
212 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncSocksProxyServerSocket); | 213 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncSocksProxyServerSocket); |
(...skipping 23 matching lines...) Expand all Loading... |
236 bool hex_mode_; | 237 bool hex_mode_; |
237 LogMultilineState lms_; | 238 LogMultilineState lms_; |
238 RTC_DISALLOW_COPY_AND_ASSIGN(LoggingSocketAdapter); | 239 RTC_DISALLOW_COPY_AND_ASSIGN(LoggingSocketAdapter); |
239 }; | 240 }; |
240 | 241 |
241 /////////////////////////////////////////////////////////////////////////////// | 242 /////////////////////////////////////////////////////////////////////////////// |
242 | 243 |
243 } // namespace rtc | 244 } // namespace rtc |
244 | 245 |
245 #endif // WEBRTC_BASE_SOCKETADAPTERS_H_ | 246 #endif // WEBRTC_BASE_SOCKETADAPTERS_H_ |
OLD | NEW |