OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 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 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 return NULL; | 113 return NULL; |
114 } | 114 } |
115 | 115 |
116 if (BindSocket(socket, local_address, 0, 0) < 0) { | 116 if (BindSocket(socket, local_address, 0, 0) < 0) { |
117 LOG(LS_ERROR) << "TCP bind failed with error " | 117 LOG(LS_ERROR) << "TCP bind failed with error " |
118 << socket->GetError(); | 118 << socket->GetError(); |
119 delete socket; | 119 delete socket; |
120 return NULL; | 120 return NULL; |
121 } | 121 } |
122 | 122 |
| 123 // If using a proxy, wrap the socket in a proxy socket. |
| 124 if (proxy_info.type == PROXY_SOCKS5) { |
| 125 socket = new AsyncSocksProxySocket( |
| 126 socket, proxy_info.address, proxy_info.username, proxy_info.password); |
| 127 } else if (proxy_info.type == PROXY_HTTPS) { |
| 128 socket = |
| 129 new AsyncHttpsProxySocket(socket, user_agent, proxy_info.address, |
| 130 proxy_info.username, proxy_info.password); |
| 131 } |
| 132 |
123 // Assert that at most one TLS option is used. | 133 // Assert that at most one TLS option is used. |
124 int tlsOpts = | 134 int tlsOpts = |
125 opts & (PacketSocketFactory::OPT_TLS | PacketSocketFactory::OPT_TLS_FAKE | | 135 opts & (PacketSocketFactory::OPT_TLS | PacketSocketFactory::OPT_TLS_FAKE | |
126 PacketSocketFactory::OPT_TLS_INSECURE); | 136 PacketSocketFactory::OPT_TLS_INSECURE); |
127 RTC_DCHECK((tlsOpts & (tlsOpts - 1)) == 0); | 137 RTC_DCHECK((tlsOpts & (tlsOpts - 1)) == 0); |
128 | 138 |
129 if ((tlsOpts & PacketSocketFactory::OPT_TLS) || | 139 if ((tlsOpts & PacketSocketFactory::OPT_TLS) || |
130 (tlsOpts & PacketSocketFactory::OPT_TLS_INSECURE)) { | 140 (tlsOpts & PacketSocketFactory::OPT_TLS_INSECURE)) { |
131 // Using TLS, wrap the socket in an SSL adapter. | 141 // Using TLS, wrap the socket in an SSL adapter. |
132 SSLAdapter* ssl_adapter = SSLAdapter::Create(socket); | 142 SSLAdapter* ssl_adapter = SSLAdapter::Create(socket); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 SocketFactory* BasicPacketSocketFactory::socket_factory() { | 206 SocketFactory* BasicPacketSocketFactory::socket_factory() { |
197 if (thread_) { | 207 if (thread_) { |
198 RTC_DCHECK(thread_ == Thread::Current()); | 208 RTC_DCHECK(thread_ == Thread::Current()); |
199 return thread_->socketserver(); | 209 return thread_->socketserver(); |
200 } else { | 210 } else { |
201 return socket_factory_; | 211 return socket_factory_; |
202 } | 212 } |
203 } | 213 } |
204 | 214 |
205 } // namespace rtc | 215 } // namespace rtc |
OLD | NEW |