blob: 95c7a4d3b77a284e1d87fa451acc519bd8ed94af [file] [log] [blame]
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +00001/*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Steve Anton10542f22019-01-11 09:11:00 -080011#ifndef P2P_BASE_TURN_SERVER_H_
12#define P2P_BASE_TURN_SERVER_H_
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000013
14#include <list>
15#include <map>
kwiberg3ec46792016-04-27 07:22:53 -070016#include <memory>
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000017#include <set>
18#include <string>
Steve Anton6c38cc72017-11-29 10:25:58 -080019#include <utility>
deadbeef824f5862016-08-24 15:06:53 -070020#include <vector>
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000021
Artem Titovd15a5752021-02-10 14:31:24 +010022#include "api/sequence_checker.h"
Steve Anton10542f22019-01-11 09:11:00 -080023#include "p2p/base/port_interface.h"
Steve Anton10542f22019-01-11 09:11:00 -080024#include "rtc_base/async_packet_socket.h"
Steve Anton10542f22019-01-11 09:11:00 -080025#include "rtc_base/socket_address.h"
Niels Möllerac9a2882021-10-20 15:25:09 +020026#include "rtc_base/ssl_adapter.h"
Artem Titove41c4332018-07-25 15:04:28 +020027#include "rtc_base/third_party/sigslot/sigslot.h"
Sebastian Jansson4db28b52020-01-08 14:07:15 +010028#include "rtc_base/thread.h"
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000029
30namespace rtc {
jbauchf1f87202016-03-30 06:43:37 -070031class ByteBufferWriter;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000032class PacketSocketFactory;
Jonas Olssona4d87372019-07-05 19:08:33 +020033} // namespace rtc
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000034
35namespace cricket {
36
37class StunMessage;
38class TurnMessage;
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +000039class TurnServer;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000040
41// The default server port for TURN, as specified in RFC5766.
42const int TURN_SERVER_PORT = 3478;
43
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +000044// Encapsulates the client's connection to the server.
45class TurnServerConnection {
46 public:
47 TurnServerConnection() : proto_(PROTO_UDP), socket_(NULL) {}
48 TurnServerConnection(const rtc::SocketAddress& src,
49 ProtocolType proto,
50 rtc::AsyncPacketSocket* socket);
51 const rtc::SocketAddress& src() const { return src_; }
52 rtc::AsyncPacketSocket* socket() { return socket_; }
53 bool operator==(const TurnServerConnection& t) const;
54 bool operator<(const TurnServerConnection& t) const;
55 std::string ToString() const;
56
57 private:
58 rtc::SocketAddress src_;
59 rtc::SocketAddress dst_;
60 cricket::ProtocolType proto_;
61 rtc::AsyncPacketSocket* socket_;
62};
63
64// Encapsulates a TURN allocation.
65// The object is created when an allocation request is received, and then
66// handles TURN messages (via HandleTurnMessage) and channel data messages
67// (via HandleChannelData) for this allocation when received by the server.
68// The object self-deletes and informs the server if its lifetime timer expires.
Tomas Gunnarssonabdb4702020-09-05 18:43:36 +020069class TurnServerAllocation : public rtc::MessageHandlerAutoCleanup,
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +000070 public sigslot::has_slots<> {
71 public:
72 TurnServerAllocation(TurnServer* server_,
73 rtc::Thread* thread,
74 const TurnServerConnection& conn,
75 rtc::AsyncPacketSocket* server_socket,
76 const std::string& key);
Steve Antonf2737d22017-10-31 16:27:34 -070077 ~TurnServerAllocation() override;
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +000078
79 TurnServerConnection* conn() { return &conn_; }
80 const std::string& key() const { return key_; }
81 const std::string& transaction_id() const { return transaction_id_; }
82 const std::string& username() const { return username_; }
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +000083 const std::string& last_nonce() const { return last_nonce_; }
Tommie83500e2022-06-03 14:28:59 +020084 void set_last_nonce(absl::string_view nonce) {
85 last_nonce_ = std::string(nonce);
86 }
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +000087
88 std::string ToString() const;
89
90 void HandleTurnMessage(const TurnMessage* msg);
91 void HandleChannelData(const char* data, size_t size);
92
93 sigslot::signal1<TurnServerAllocation*> SignalDestroyed;
94
95 private:
96 class Channel;
97 class Permission;
98 typedef std::list<Permission*> PermissionList;
99 typedef std::list<Channel*> ChannelList;
100
101 void HandleAllocateRequest(const TurnMessage* msg);
102 void HandleRefreshRequest(const TurnMessage* msg);
103 void HandleSendIndication(const TurnMessage* msg);
104 void HandleCreatePermissionRequest(const TurnMessage* msg);
105 void HandleChannelBindRequest(const TurnMessage* msg);
106
107 void OnExternalPacket(rtc::AsyncPacketSocket* socket,
Niels Möllere6933812018-11-05 13:01:41 +0100108 const char* data,
109 size_t size,
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000110 const rtc::SocketAddress& addr,
Niels Möllere6933812018-11-05 13:01:41 +0100111 const int64_t& packet_time_us);
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000112
Tommi408143d2022-06-01 15:29:31 +0200113 static int ComputeLifetime(const TurnMessage& msg);
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000114 bool HasPermission(const rtc::IPAddress& addr);
115 void AddPermission(const rtc::IPAddress& addr);
116 Permission* FindPermission(const rtc::IPAddress& addr) const;
117 Channel* FindChannel(int channel_id) const;
118 Channel* FindChannel(const rtc::SocketAddress& addr) const;
119
120 void SendResponse(TurnMessage* msg);
121 void SendBadRequestResponse(const TurnMessage* req);
Jonas Olssona4d87372019-07-05 19:08:33 +0200122 void SendErrorResponse(const TurnMessage* req,
123 int code,
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000124 const std::string& reason);
Jonas Olssona4d87372019-07-05 19:08:33 +0200125 void SendExternal(const void* data,
126 size_t size,
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000127 const rtc::SocketAddress& peer);
128
129 void OnPermissionDestroyed(Permission* perm);
130 void OnChannelDestroyed(Channel* channel);
Steve Antonf2737d22017-10-31 16:27:34 -0700131 void OnMessage(rtc::Message* msg) override;
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000132
Niels Möller76b51e22021-03-18 15:44:24 +0100133 TurnServer* const server_;
134 rtc::Thread* const thread_;
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000135 TurnServerConnection conn_;
kwiberg3ec46792016-04-27 07:22:53 -0700136 std::unique_ptr<rtc::AsyncPacketSocket> external_socket_;
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000137 std::string key_;
138 std::string transaction_id_;
139 std::string username_;
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000140 std::string last_nonce_;
141 PermissionList perms_;
142 ChannelList channels_;
143};
144
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000145// An interface through which the MD5 credential hash can be retrieved.
146class TurnAuthInterface {
147 public:
148 // Gets HA1 for the specified user and realm.
149 // HA1 = MD5(A1) = MD5(username:realm:password).
150 // Return true if the given username and realm are valid, or false if not.
Jonas Olssona4d87372019-07-05 19:08:33 +0200151 virtual bool GetKey(const std::string& username,
152 const std::string& realm,
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000153 std::string* key) = 0;
Henrik Kjellander3fe372d2016-05-12 08:10:52 +0200154 virtual ~TurnAuthInterface() = default;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000155};
156
157// An interface enables Turn Server to control redirection behavior.
158class TurnRedirectInterface {
159 public:
160 virtual bool ShouldRedirect(const rtc::SocketAddress& address,
161 rtc::SocketAddress* out) = 0;
162 virtual ~TurnRedirectInterface() {}
163};
164
Jonas Orelandbdcee282017-10-10 14:01:40 +0200165class StunMessageObserver {
166 public:
167 virtual void ReceivedMessage(const TurnMessage* msg) = 0;
168 virtual void ReceivedChannelData(const char* data, size_t size) = 0;
169 virtual ~StunMessageObserver() {}
170};
171
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000172// The core TURN server class. Give it a socket to listen on via
173// AddInternalServerSocket, and a factory to create external sockets via
174// SetExternalSocketFactory, and it's ready to go.
175// Not yet wired up: TCP support.
176class TurnServer : public sigslot::has_slots<> {
177 public:
deadbeef97943662016-07-12 11:04:50 -0700178 typedef std::map<TurnServerConnection, std::unique_ptr<TurnServerAllocation>>
179 AllocationMap;
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000180
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000181 explicit TurnServer(rtc::Thread* thread);
Steve Antonf2737d22017-10-31 16:27:34 -0700182 ~TurnServer() override;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000183
184 // Gets/sets the realm value to use for the server.
Seth Hampsonaed71642018-06-11 07:41:32 -0700185 const std::string& realm() const {
Niels Möller76b51e22021-03-18 15:44:24 +0100186 RTC_DCHECK_RUN_ON(thread_);
Seth Hampsonaed71642018-06-11 07:41:32 -0700187 return realm_;
188 }
189 void set_realm(const std::string& realm) {
Niels Möller76b51e22021-03-18 15:44:24 +0100190 RTC_DCHECK_RUN_ON(thread_);
Seth Hampsonaed71642018-06-11 07:41:32 -0700191 realm_ = realm;
192 }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000193
194 // Gets/sets the value for the SOFTWARE attribute for TURN messages.
Seth Hampsonaed71642018-06-11 07:41:32 -0700195 const std::string& software() const {
Niels Möller76b51e22021-03-18 15:44:24 +0100196 RTC_DCHECK_RUN_ON(thread_);
Seth Hampsonaed71642018-06-11 07:41:32 -0700197 return software_;
198 }
199 void set_software(const std::string& software) {
Niels Möller76b51e22021-03-18 15:44:24 +0100200 RTC_DCHECK_RUN_ON(thread_);
Seth Hampsonaed71642018-06-11 07:41:32 -0700201 software_ = software;
202 }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000203
Seth Hampsonaed71642018-06-11 07:41:32 -0700204 const AllocationMap& allocations() const {
Niels Möller76b51e22021-03-18 15:44:24 +0100205 RTC_DCHECK_RUN_ON(thread_);
Seth Hampsonaed71642018-06-11 07:41:32 -0700206 return allocations_;
207 }
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000208
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000209 // Sets the authentication callback; does not take ownership.
Seth Hampsonaed71642018-06-11 07:41:32 -0700210 void set_auth_hook(TurnAuthInterface* auth_hook) {
Niels Möller76b51e22021-03-18 15:44:24 +0100211 RTC_DCHECK_RUN_ON(thread_);
Seth Hampsonaed71642018-06-11 07:41:32 -0700212 auth_hook_ = auth_hook;
213 }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000214
215 void set_redirect_hook(TurnRedirectInterface* redirect_hook) {
Niels Möller76b51e22021-03-18 15:44:24 +0100216 RTC_DCHECK_RUN_ON(thread_);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000217 redirect_hook_ = redirect_hook;
218 }
219
Seth Hampsonaed71642018-06-11 07:41:32 -0700220 void set_enable_otu_nonce(bool enable) {
Niels Möller76b51e22021-03-18 15:44:24 +0100221 RTC_DCHECK_RUN_ON(thread_);
Seth Hampsonaed71642018-06-11 07:41:32 -0700222 enable_otu_nonce_ = enable;
223 }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000224
deadbeef376e1232015-11-25 09:00:08 -0800225 // If set to true, reject CreatePermission requests to RFC1918 addresses.
226 void set_reject_private_addresses(bool filter) {
Niels Möller76b51e22021-03-18 15:44:24 +0100227 RTC_DCHECK_RUN_ON(thread_);
deadbeef376e1232015-11-25 09:00:08 -0800228 reject_private_addresses_ = filter;
229 }
230
Taylor Brandstetteref184702016-06-23 17:35:47 -0700231 void set_enable_permission_checks(bool enable) {
Niels Möller76b51e22021-03-18 15:44:24 +0100232 RTC_DCHECK_RUN_ON(thread_);
Taylor Brandstetteref184702016-06-23 17:35:47 -0700233 enable_permission_checks_ = enable;
234 }
235
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000236 // Starts listening for packets from internal clients.
Jonas Olssona4d87372019-07-05 19:08:33 +0200237 void AddInternalSocket(rtc::AsyncPacketSocket* socket, ProtocolType proto);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000238 // Starts listening for the connections on this socket. When someone tries
239 // to connect, the connection will be accepted and a new internal socket
240 // will be added.
Niels Möllerac9a2882021-10-20 15:25:09 +0200241 void AddInternalServerSocket(
242 rtc::Socket* socket,
243 ProtocolType proto,
244 std::unique_ptr<rtc::SSLAdapterFactory> ssl_adapter_factory = nullptr);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000245 // Specifies the factory to use for creating external sockets.
246 void SetExternalSocketFactory(rtc::PacketSocketFactory* factory,
247 const rtc::SocketAddress& address);
honghaizc463e202016-02-01 15:19:08 -0800248 // For testing only.
honghaiz34b11eb2016-03-16 08:55:44 -0700249 std::string SetTimestampForNextNonce(int64_t timestamp) {
Niels Möller76b51e22021-03-18 15:44:24 +0100250 RTC_DCHECK_RUN_ON(thread_);
honghaizc463e202016-02-01 15:19:08 -0800251 ts_for_next_nonce_ = timestamp;
252 return GenerateNonce(timestamp);
253 }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000254
Jonas Olssona4d87372019-07-05 19:08:33 +0200255 void SetStunMessageObserver(std::unique_ptr<StunMessageObserver> observer) {
Niels Möller76b51e22021-03-18 15:44:24 +0100256 RTC_DCHECK_RUN_ON(thread_);
Jonas Orelandbdcee282017-10-10 14:01:40 +0200257 stun_message_observer_ = std::move(observer);
258 }
259
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000260 private:
Niels Möller76b51e22021-03-18 15:44:24 +0100261 // All private member functions and variables should have access restricted to
262 // thread_. But compile-time annotations are missing for members access from
263 // TurnServerAllocation (via friend declaration), and the On* methods, which
264 // are called via sigslot.
265 std::string GenerateNonce(int64_t now) const RTC_RUN_ON(thread_);
Niels Möllere6933812018-11-05 13:01:41 +0100266 void OnInternalPacket(rtc::AsyncPacketSocket* socket,
267 const char* data,
268 size_t size,
269 const rtc::SocketAddress& address,
270 const int64_t& packet_time_us);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000271
Niels Möllerd0b88792021-08-12 10:32:30 +0200272 void OnNewInternalConnection(rtc::Socket* socket);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000273
274 // Accept connections on this server socket.
Niels Möllerd0b88792021-08-12 10:32:30 +0200275 void AcceptConnection(rtc::Socket* server_socket) RTC_RUN_ON(thread_);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000276 void OnInternalSocketClose(rtc::AsyncPacketSocket* socket, int err);
277
Jonas Olssona4d87372019-07-05 19:08:33 +0200278 void HandleStunMessage(TurnServerConnection* conn,
279 const char* data,
Niels Möller76b51e22021-03-18 15:44:24 +0100280 size_t size) RTC_RUN_ON(thread_);
281 void HandleBindingRequest(TurnServerConnection* conn, const StunMessage* msg)
282 RTC_RUN_ON(thread_);
Jonas Olssona4d87372019-07-05 19:08:33 +0200283 void HandleAllocateRequest(TurnServerConnection* conn,
284 const TurnMessage* msg,
Niels Möller76b51e22021-03-18 15:44:24 +0100285 const std::string& key) RTC_RUN_ON(thread_);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000286
Niels Möller76b51e22021-03-18 15:44:24 +0100287 bool GetKey(const StunMessage* msg, std::string* key) RTC_RUN_ON(thread_);
Jonas Olssona4d87372019-07-05 19:08:33 +0200288 bool CheckAuthorization(TurnServerConnection* conn,
Harald Alvestrand07d83c82021-03-02 08:09:53 +0000289 StunMessage* msg,
Jonas Olssona4d87372019-07-05 19:08:33 +0200290 const char* data,
291 size_t size,
Niels Möller76b51e22021-03-18 15:44:24 +0100292 const std::string& key) RTC_RUN_ON(thread_);
Tommie83500e2022-06-03 14:28:59 +0200293 bool ValidateNonce(absl::string_view nonce) const RTC_RUN_ON(thread_);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000294
Niels Möller76b51e22021-03-18 15:44:24 +0100295 TurnServerAllocation* FindAllocation(TurnServerConnection* conn)
296 RTC_RUN_ON(thread_);
Jonas Olssona4d87372019-07-05 19:08:33 +0200297 TurnServerAllocation* CreateAllocation(TurnServerConnection* conn,
298 int proto,
Niels Möller76b51e22021-03-18 15:44:24 +0100299 const std::string& key)
300 RTC_RUN_ON(thread_);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000301
Jonas Olssona4d87372019-07-05 19:08:33 +0200302 void SendErrorResponse(TurnServerConnection* conn,
303 const StunMessage* req,
304 int code,
305 const std::string& reason);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000306
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000307 void SendErrorResponseWithRealmAndNonce(TurnServerConnection* conn,
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000308 const StunMessage* req,
309 int code,
Niels Möller76b51e22021-03-18 15:44:24 +0100310 const std::string& reason)
311 RTC_RUN_ON(thread_);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000312
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000313 void SendErrorResponseWithAlternateServer(TurnServerConnection* conn,
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000314 const StunMessage* req,
Niels Möller76b51e22021-03-18 15:44:24 +0100315 const rtc::SocketAddress& addr)
316 RTC_RUN_ON(thread_);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000317
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000318 void SendStun(TurnServerConnection* conn, StunMessage* msg);
jbauchf1f87202016-03-30 06:43:37 -0700319 void Send(TurnServerConnection* conn, const rtc::ByteBufferWriter& buf);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000320
Niels Möller76b51e22021-03-18 15:44:24 +0100321 void OnAllocationDestroyed(TurnServerAllocation* allocation)
322 RTC_RUN_ON(thread_);
323 void DestroyInternalSocket(rtc::AsyncPacketSocket* socket)
324 RTC_RUN_ON(thread_);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000325
Jonas Olssona4d87372019-07-05 19:08:33 +0200326 typedef std::map<rtc::AsyncPacketSocket*, ProtocolType> InternalSocketMap;
Niels Möllerac9a2882021-10-20 15:25:09 +0200327 struct ServerSocketInfo {
328 ProtocolType proto;
329 // If non-null, used to wrap accepted sockets.
330 std::unique_ptr<rtc::SSLAdapterFactory> ssl_adapter_factory;
331 };
332 typedef std::map<rtc::Socket*, ServerSocketInfo> ServerSocketMap;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000333
Niels Möller76b51e22021-03-18 15:44:24 +0100334 rtc::Thread* const thread_;
335 const std::string nonce_key_;
336 std::string realm_ RTC_GUARDED_BY(thread_);
337 std::string software_ RTC_GUARDED_BY(thread_);
338 TurnAuthInterface* auth_hook_ RTC_GUARDED_BY(thread_);
339 TurnRedirectInterface* redirect_hook_ RTC_GUARDED_BY(thread_);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000340 // otu - one-time-use. Server will respond with 438 if it's
341 // sees the same nonce in next transaction.
Niels Möller76b51e22021-03-18 15:44:24 +0100342 bool enable_otu_nonce_ RTC_GUARDED_BY(thread_);
deadbeef376e1232015-11-25 09:00:08 -0800343 bool reject_private_addresses_ = false;
Taylor Brandstetteref184702016-06-23 17:35:47 -0700344 // Check for permission when receiving an external packet.
345 bool enable_permission_checks_ = true;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000346
Niels Möller76b51e22021-03-18 15:44:24 +0100347 InternalSocketMap server_sockets_ RTC_GUARDED_BY(thread_);
348 ServerSocketMap server_listen_sockets_ RTC_GUARDED_BY(thread_);
Niels Möller76b51e22021-03-18 15:44:24 +0100349 std::unique_ptr<rtc::PacketSocketFactory> external_socket_factory_
350 RTC_GUARDED_BY(thread_);
351 rtc::SocketAddress external_addr_ RTC_GUARDED_BY(thread_);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000352
Niels Möller76b51e22021-03-18 15:44:24 +0100353 AllocationMap allocations_ RTC_GUARDED_BY(thread_);
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000354
honghaizc463e202016-02-01 15:19:08 -0800355 // For testing only. If this is non-zero, the next NONCE will be generated
356 // from this value, and it will be reset to 0 after generating the NONCE.
Niels Möller76b51e22021-03-18 15:44:24 +0100357 int64_t ts_for_next_nonce_ RTC_GUARDED_BY(thread_) = 0;
honghaizc463e202016-02-01 15:19:08 -0800358
Jonas Orelandbdcee282017-10-10 14:01:40 +0200359 // For testing only. Used to observe STUN messages received.
Niels Möller76b51e22021-03-18 15:44:24 +0100360 std::unique_ptr<StunMessageObserver> stun_message_observer_
361 RTC_GUARDED_BY(thread_);
Jonas Orelandbdcee282017-10-10 14:01:40 +0200362
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000363 friend class TurnServerAllocation;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000364};
365
366} // namespace cricket
367
Steve Anton10542f22019-01-11 09:11:00 -0800368#endif // P2P_BASE_TURN_SERVER_H_