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 #include "webrtc/base/autodetectproxy.h" | 11 #include "webrtc/base/autodetectproxy.h" |
| 12 #include "webrtc/base/checks.h" |
12 #include "webrtc/base/httpcommon.h" | 13 #include "webrtc/base/httpcommon.h" |
13 #include "webrtc/base/httpcommon-inl.h" | 14 #include "webrtc/base/httpcommon-inl.h" |
14 #include "webrtc/base/nethelpers.h" | 15 #include "webrtc/base/nethelpers.h" |
15 | 16 |
16 namespace rtc { | 17 namespace rtc { |
17 | 18 |
18 static const ProxyType TEST_ORDER[] = { | 19 static const ProxyType TEST_ORDER[] = { |
19 PROXY_HTTPS, PROXY_SOCKS5, PROXY_UNKNOWN | 20 PROXY_HTTPS, PROXY_SOCKS5, PROXY_UNKNOWN |
20 }; | 21 }; |
21 | 22 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 probe.append("\r\n" | 230 probe.append("\r\n" |
230 "Host: www.google.com\r\n" | 231 "Host: www.google.com\r\n" |
231 "Content-Length: 0\r\n" | 232 "Content-Length: 0\r\n" |
232 "Proxy-Connection: Keep-Alive\r\n" | 233 "Proxy-Connection: Keep-Alive\r\n" |
233 "\r\n"); | 234 "\r\n"); |
234 break; | 235 break; |
235 case PROXY_SOCKS5: | 236 case PROXY_SOCKS5: |
236 probe.assign("\005\001\000", 3); | 237 probe.assign("\005\001\000", 3); |
237 break; | 238 break; |
238 default: | 239 default: |
239 ASSERT(false); | 240 RTC_NOTREACHED(); |
240 return; | 241 return; |
241 } | 242 } |
242 | 243 |
243 LOG(LS_VERBOSE) << "AutoDetectProxy probing type " << TEST_ORDER[next_] | 244 LOG(LS_VERBOSE) << "AutoDetectProxy probing type " << TEST_ORDER[next_] |
244 << " sending " << probe.size() << " bytes"; | 245 << " sending " << probe.size() << " bytes"; |
245 socket_->Send(probe.data(), probe.size()); | 246 socket_->Send(probe.data(), probe.size()); |
246 } | 247 } |
247 | 248 |
248 void AutoDetectProxy::OnReadEvent(AsyncSocket * socket) { | 249 void AutoDetectProxy::OnReadEvent(AsyncSocket * socket) { |
249 char data[257]; | 250 char data[257]; |
(...skipping 14 matching lines...) Expand all Loading... |
264 return; | 265 return; |
265 } | 266 } |
266 break; | 267 break; |
267 case PROXY_SOCKS5: | 268 case PROXY_SOCKS5: |
268 if ((len >= 2) && (data[0] == '\x05')) { | 269 if ((len >= 2) && (data[0] == '\x05')) { |
269 Complete(PROXY_SOCKS5); | 270 Complete(PROXY_SOCKS5); |
270 return; | 271 return; |
271 } | 272 } |
272 break; | 273 break; |
273 default: | 274 default: |
274 ASSERT(false); | 275 RTC_NOTREACHED(); |
275 return; | 276 return; |
276 } | 277 } |
277 | 278 |
278 ++next_; | 279 ++next_; |
279 Next(); | 280 Next(); |
280 } | 281 } |
281 | 282 |
282 void AutoDetectProxy::OnTimeout() { | 283 void AutoDetectProxy::OnTimeout() { |
283 LOG(LS_VERBOSE) << "Timed out waiting for AsyncResolver."; | 284 LOG(LS_VERBOSE) << "Timed out waiting for AsyncResolver."; |
284 // If a resolver timed out we shouldn't try to use it again since it may be | 285 // If a resolver timed out we shouldn't try to use it again since it may be |
285 // in the middle of resolving the last address. | 286 // in the middle of resolving the last address. |
286 if (resolver_) { | 287 if (resolver_) { |
287 resolver_->SignalDone.disconnect(this); | 288 resolver_->SignalDone.disconnect(this); |
288 resolver_->Destroy(false); | 289 resolver_->Destroy(false); |
289 resolver_ = nullptr; | 290 resolver_ = nullptr; |
290 } | 291 } |
291 ++next_; | 292 ++next_; |
292 Next(); | 293 Next(); |
293 } | 294 } |
294 | 295 |
295 void AutoDetectProxy::OnCloseEvent(AsyncSocket * socket, int error) { | 296 void AutoDetectProxy::OnCloseEvent(AsyncSocket * socket, int error) { |
296 LOG(LS_VERBOSE) << "AutoDetectProxy closed with error: " << error; | 297 LOG(LS_VERBOSE) << "AutoDetectProxy closed with error: " << error; |
297 ++next_; | 298 ++next_; |
298 Next(); | 299 Next(); |
299 } | 300 } |
300 | 301 |
301 } // namespace rtc | 302 } // namespace rtc |
OLD | NEW |