OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 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_P2P_BASE_TURNSERVER_H_ | 11 #ifndef WEBRTC_P2P_BASE_TURNSERVER_H_ |
12 #define WEBRTC_P2P_BASE_TURNSERVER_H_ | 12 #define WEBRTC_P2P_BASE_TURNSERVER_H_ |
13 | 13 |
14 #include <list> | 14 #include <list> |
15 #include <map> | 15 #include <map> |
16 #include <memory> | 16 #include <memory> |
17 #include <set> | 17 #include <set> |
18 #include <string> | 18 #include <string> |
| 19 #include <vector> |
19 | 20 |
20 #include "webrtc/p2p/base/portinterface.h" | 21 #include "webrtc/p2p/base/portinterface.h" |
| 22 #include "webrtc/base/asyncinvoker.h" |
21 #include "webrtc/base/asyncpacketsocket.h" | 23 #include "webrtc/base/asyncpacketsocket.h" |
22 #include "webrtc/base/messagequeue.h" | 24 #include "webrtc/base/messagequeue.h" |
23 #include "webrtc/base/sigslot.h" | 25 #include "webrtc/base/sigslot.h" |
24 #include "webrtc/base/socketaddress.h" | 26 #include "webrtc/base/socketaddress.h" |
25 | 27 |
26 namespace rtc { | 28 namespace rtc { |
27 class ByteBufferWriter; | 29 class ByteBufferWriter; |
28 class PacketSocketFactory; | 30 class PacketSocketFactory; |
29 class Thread; | 31 class Thread; |
30 } | 32 } |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 void SendErrorResponseWithAlternateServer(TurnServerConnection* conn, | 253 void SendErrorResponseWithAlternateServer(TurnServerConnection* conn, |
252 const StunMessage* req, | 254 const StunMessage* req, |
253 const rtc::SocketAddress& addr); | 255 const rtc::SocketAddress& addr); |
254 | 256 |
255 void SendStun(TurnServerConnection* conn, StunMessage* msg); | 257 void SendStun(TurnServerConnection* conn, StunMessage* msg); |
256 void Send(TurnServerConnection* conn, const rtc::ByteBufferWriter& buf); | 258 void Send(TurnServerConnection* conn, const rtc::ByteBufferWriter& buf); |
257 | 259 |
258 void OnAllocationDestroyed(TurnServerAllocation* allocation); | 260 void OnAllocationDestroyed(TurnServerAllocation* allocation); |
259 void DestroyInternalSocket(rtc::AsyncPacketSocket* socket); | 261 void DestroyInternalSocket(rtc::AsyncPacketSocket* socket); |
260 | 262 |
| 263 // Just clears |sockets_to_delete_|; called asynchronously. |
| 264 void FreeSockets(); |
| 265 |
261 typedef std::map<rtc::AsyncPacketSocket*, | 266 typedef std::map<rtc::AsyncPacketSocket*, |
262 ProtocolType> InternalSocketMap; | 267 ProtocolType> InternalSocketMap; |
263 typedef std::map<rtc::AsyncSocket*, | 268 typedef std::map<rtc::AsyncSocket*, |
264 ProtocolType> ServerSocketMap; | 269 ProtocolType> ServerSocketMap; |
265 | 270 |
266 rtc::Thread* thread_; | 271 rtc::Thread* thread_; |
267 std::string nonce_key_; | 272 std::string nonce_key_; |
268 std::string realm_; | 273 std::string realm_; |
269 std::string software_; | 274 std::string software_; |
270 TurnAuthInterface* auth_hook_; | 275 TurnAuthInterface* auth_hook_; |
271 TurnRedirectInterface* redirect_hook_; | 276 TurnRedirectInterface* redirect_hook_; |
272 // otu - one-time-use. Server will respond with 438 if it's | 277 // otu - one-time-use. Server will respond with 438 if it's |
273 // sees the same nonce in next transaction. | 278 // sees the same nonce in next transaction. |
274 bool enable_otu_nonce_; | 279 bool enable_otu_nonce_; |
275 bool reject_private_addresses_ = false; | 280 bool reject_private_addresses_ = false; |
276 // Check for permission when receiving an external packet. | 281 // Check for permission when receiving an external packet. |
277 bool enable_permission_checks_ = true; | 282 bool enable_permission_checks_ = true; |
278 | 283 |
279 InternalSocketMap server_sockets_; | 284 InternalSocketMap server_sockets_; |
280 ServerSocketMap server_listen_sockets_; | 285 ServerSocketMap server_listen_sockets_; |
| 286 // Used when we need to delete a socket asynchronously. |
| 287 std::vector<std::unique_ptr<rtc::AsyncPacketSocket>> sockets_to_delete_; |
281 std::unique_ptr<rtc::PacketSocketFactory> external_socket_factory_; | 288 std::unique_ptr<rtc::PacketSocketFactory> external_socket_factory_; |
282 rtc::SocketAddress external_addr_; | 289 rtc::SocketAddress external_addr_; |
283 | 290 |
284 AllocationMap allocations_; | 291 AllocationMap allocations_; |
285 | 292 |
| 293 rtc::AsyncInvoker invoker_; |
| 294 |
286 // For testing only. If this is non-zero, the next NONCE will be generated | 295 // For testing only. If this is non-zero, the next NONCE will be generated |
287 // from this value, and it will be reset to 0 after generating the NONCE. | 296 // from this value, and it will be reset to 0 after generating the NONCE. |
288 int64_t ts_for_next_nonce_ = 0; | 297 int64_t ts_for_next_nonce_ = 0; |
289 | 298 |
290 friend class TurnServerAllocation; | 299 friend class TurnServerAllocation; |
291 }; | 300 }; |
292 | 301 |
293 } // namespace cricket | 302 } // namespace cricket |
294 | 303 |
295 #endif // WEBRTC_P2P_BASE_TURNSERVER_H_ | 304 #endif // WEBRTC_P2P_BASE_TURNSERVER_H_ |
OLD | NEW |