blob: 93de0e141f3960ee17d8c5305cf7907d7897e4e8 [file] [log] [blame]
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +00001/*
2 * Copyright 2004 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
11#ifndef WEBRTC_P2P_BASE_PORTALLOCATOR_H_
12#define WEBRTC_P2P_BASE_PORTALLOCATOR_H_
13
Taylor Brandstettera1c30352016-05-13 08:15:11 -070014#include <deque>
15#include <memory>
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000016#include <string>
17#include <vector>
18
deadbeef653b8e02015-11-11 12:55:10 -080019#include "webrtc/p2p/base/port.h"
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000020#include "webrtc/p2p/base/portinterface.h"
21#include "webrtc/base/helpers.h"
22#include "webrtc/base/proxyinfo.h"
23#include "webrtc/base/sigslot.h"
Taylor Brandstettera1c30352016-05-13 08:15:11 -070024#include "webrtc/base/thread.h"
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000025
Honghai Zhangd93f50c2016-10-05 11:47:22 -070026namespace webrtc {
27class MetricsObserverInterface;
28}
29
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000030namespace cricket {
31
32// PortAllocator is responsible for allocating Port types for a given
33// P2PSocket. It also handles port freeing.
34//
35// Clients can override this class to control port allocation, including
36// what kinds of ports are allocated.
37
38enum {
Guo-wei Shieh13d35f62015-08-26 15:32:56 -070039 // Disable local UDP ports. This doesn't impact how we connect to relay
40 // servers.
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000041 PORTALLOCATOR_DISABLE_UDP = 0x01,
42 PORTALLOCATOR_DISABLE_STUN = 0x02,
43 PORTALLOCATOR_DISABLE_RELAY = 0x04,
Guo-wei Shieh13d35f62015-08-26 15:32:56 -070044 // Disable local TCP ports. This doesn't impact how we connect to relay
45 // servers.
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000046 PORTALLOCATOR_DISABLE_TCP = 0x08,
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000047 PORTALLOCATOR_ENABLE_IPV6 = 0x40,
Peter Thatcher7cbd1882015-09-17 18:54:52 -070048 // TODO(pthatcher): Remove this once it's no longer used in:
49 // remoting/client/plugin/pepper_port_allocator.cc
50 // remoting/protocol/chromium_port_allocator.cc
51 // remoting/test/fake_port_allocator.cc
52 // It's a no-op and is no longer needed.
pthatcherfa301802015-08-11 04:12:56 -070053 PORTALLOCATOR_ENABLE_SHARED_UFRAG = 0x80,
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000054 PORTALLOCATOR_ENABLE_SHARED_SOCKET = 0x100,
55 PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE = 0x200,
Guo-wei Shieh9af97f82015-11-10 14:47:39 -080056 // When specified, we'll only allocate the STUN candidate for the public
57 // interface as seen by regular http traffic and the HOST candidate associated
58 // with the default local interface.
guoweis@webrtc.orgf358aea2015-02-18 18:44:01 +000059 PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION = 0x400,
Guo-wei Shieh9af97f82015-11-10 14:47:39 -080060 // When specified along with PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION, the
61 // default local candidate mentioned above will not be allocated. Only the
62 // STUN candidate will be.
63 PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE = 0x800,
Guo-wei Shieh13d35f62015-08-26 15:32:56 -070064 // Disallow use of UDP when connecting to a relay server. Since proxy servers
65 // usually don't handle UDP, using UDP will leak the IP address.
66 PORTALLOCATOR_DISABLE_UDP_RELAY = 0x1000,
honghaiz60347052016-05-31 18:29:12 -070067
68 // When multiple networks exist, do not gather candidates on the ones with
69 // high cost. So if both Wi-Fi and cellular networks exist, gather only on the
70 // Wi-Fi network. If a network type is "unknown", it has a cost lower than
71 // cellular but higher than Wi-Fi/Ethernet. So if an unknown network exists,
72 // cellular networks will not be used to gather candidates and if a Wi-Fi
73 // network is present, "unknown" networks will not be usd to gather
74 // candidates. Doing so ensures that even if a cellular network type was not
75 // detected initially, it would not be used if a Wi-Fi network is present.
76 PORTALLOCATOR_DISABLE_COSTLY_NETWORKS = 0x2000,
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000077};
78
Honghai Zhangd93f50c2016-10-05 11:47:22 -070079// Defines various reasons that have caused ICE regathering.
80enum class IceRegatheringReason { NETWORK_CHANGE, NETWORK_FAILURE, MAX_VALUE };
81
Peter Boström0c4e06b2015-10-07 12:23:21 +020082const uint32_t kDefaultPortAllocatorFlags = 0;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000083
Peter Boström0c4e06b2015-10-07 12:23:21 +020084const uint32_t kDefaultStepDelay = 1000; // 1 sec step delay.
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000085// As per RFC 5245 Appendix B.1, STUN transactions need to be paced at certain
86// internal. Less than 20ms is not acceptable. We choose 50ms as our default.
Peter Boström0c4e06b2015-10-07 12:23:21 +020087const uint32_t kMinimumStepDelay = 50;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000088
89// CF = CANDIDATE FILTER
90enum {
91 CF_NONE = 0x0,
92 CF_HOST = 0x1,
93 CF_REFLEXIVE = 0x2,
94 CF_RELAY = 0x4,
95 CF_ALL = 0x7,
96};
97
deadbeef653b8e02015-11-11 12:55:10 -080098// TODO(deadbeef): Rename to TurnCredentials (and username to ufrag).
99struct RelayCredentials {
100 RelayCredentials() {}
101 RelayCredentials(const std::string& username, const std::string& password)
102 : username(username), password(password) {}
103
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700104 bool operator==(const RelayCredentials& o) const {
105 return username == o.username && password == o.password;
106 }
107 bool operator!=(const RelayCredentials& o) const { return !(*this == o); }
108
deadbeef653b8e02015-11-11 12:55:10 -0800109 std::string username;
110 std::string password;
111};
112
113typedef std::vector<ProtocolAddress> PortList;
114// TODO(deadbeef): Rename to TurnServerConfig.
115struct RelayServerConfig {
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700116 RelayServerConfig(RelayType type) : type(type) {}
deadbeef653b8e02015-11-11 12:55:10 -0800117
Taylor Brandstetter0c7e9f52015-12-29 14:14:52 -0800118 RelayServerConfig(const std::string& address,
119 int port,
120 const std::string& username,
121 const std::string& password,
hnsl277b2502016-12-13 05:17:23 -0800122 ProtocolType proto)
123 : type(RELAY_TURN), credentials(username, password) {
124 ports.push_back(ProtocolAddress(rtc::SocketAddress(address, port), proto));
125 }
126
127 // Legacy constructor where "secure" and PROTO_TCP implies PROTO_TLS.
128 RelayServerConfig(const std::string& address,
129 int port,
130 const std::string& username,
131 const std::string& password,
Taylor Brandstetter0c7e9f52015-12-29 14:14:52 -0800132 ProtocolType proto,
133 bool secure)
hnsl277b2502016-12-13 05:17:23 -0800134 : RelayServerConfig(address,
135 port,
136 username,
137 password,
138 (proto == PROTO_TCP && secure ? PROTO_TLS : proto)) {}
Taylor Brandstetter0c7e9f52015-12-29 14:14:52 -0800139
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700140 bool operator==(const RelayServerConfig& o) const {
141 return type == o.type && ports == o.ports && credentials == o.credentials &&
142 priority == o.priority;
143 }
144 bool operator!=(const RelayServerConfig& o) const { return !(*this == o); }
145
deadbeef653b8e02015-11-11 12:55:10 -0800146 RelayType type;
147 PortList ports;
148 RelayCredentials credentials;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700149 int priority = 0;
deadbeef653b8e02015-11-11 12:55:10 -0800150};
151
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000152class PortAllocatorSession : public sigslot::has_slots<> {
153 public:
154 // Content name passed in mostly for logging and debugging.
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000155 PortAllocatorSession(const std::string& content_name,
156 int component,
deadbeefcbecd352015-09-23 11:50:27 -0700157 const std::string& ice_ufrag,
158 const std::string& ice_pwd,
Peter Boström0c4e06b2015-10-07 12:23:21 +0200159 uint32_t flags);
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000160
161 // Subclasses should clean up any ports created.
162 virtual ~PortAllocatorSession() {}
163
Peter Boström0c4e06b2015-10-07 12:23:21 +0200164 uint32_t flags() const { return flags_; }
165 void set_flags(uint32_t flags) { flags_ = flags; }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000166 std::string content_name() const { return content_name_; }
167 int component() const { return component_; }
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700168 const std::string& ice_ufrag() const { return ice_ufrag_; }
169 const std::string& ice_pwd() const { return ice_pwd_; }
170 bool pooled() const { return ice_ufrag_.empty(); }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000171
Taylor Brandstetter417eebe2016-05-23 16:02:19 -0700172 // Setting this filter should affect not only candidates gathered in the
173 // future, but candidates already gathered and ports already "ready",
174 // which would be returned by ReadyCandidates() and ReadyPorts().
175 //
176 // Default filter should be CF_ALL.
177 virtual void SetCandidateFilter(uint32_t filter) = 0;
178
deadbeefb60a8192016-08-24 15:15:00 -0700179 // Starts gathering ports and ICE candidates.
Honghai Zhangd8f6fc42016-07-01 17:31:12 -0700180 virtual void StartGettingPorts() = 0;
deadbeefb60a8192016-08-24 15:15:00 -0700181 // Completely stops gathering. Will not gather again unless StartGettingPorts
182 // is called again.
Honghai Zhangd8f6fc42016-07-01 17:31:12 -0700183 virtual void StopGettingPorts() = 0;
Honghai Zhang5622c5e2016-07-01 13:59:29 -0700184 // Whether the session is actively getting ports.
Honghai Zhangd8f6fc42016-07-01 17:31:12 -0700185 virtual bool IsGettingPorts() = 0;
deadbeefb60a8192016-08-24 15:15:00 -0700186
187 //
188 // NOTE: The group of methods below is only used for continual gathering.
189 //
190
191 // ClearGettingPorts should have the same immediate effect as
192 // StopGettingPorts, but if the implementation supports continual gathering,
193 // ClearGettingPorts allows additional ports/candidates to be gathered if the
194 // network conditions change.
Honghai Zhangd8f6fc42016-07-01 17:31:12 -0700195 virtual void ClearGettingPorts() = 0;
Honghai Zhang5622c5e2016-07-01 13:59:29 -0700196 // Whether it is in the state where the existing gathering process is stopped,
197 // but new ones may be started (basically after calling ClearGettingPorts).
Honghai Zhangd8f6fc42016-07-01 17:31:12 -0700198 virtual bool IsCleared() const { return false; }
Honghai Zhang5622c5e2016-07-01 13:59:29 -0700199 // Whether the session has completely stopped.
Honghai Zhangd8f6fc42016-07-01 17:31:12 -0700200 virtual bool IsStopped() const { return false; }
Honghai Zhang5622c5e2016-07-01 13:59:29 -0700201 // Re-gathers candidates on networks that do not have any connections. More
202 // precisely, a network interface may have more than one IP addresses (e.g.,
203 // IPv4 and IPv6 addresses). Each address subnet will be used to create a
204 // network. Only if all networks of an interface have no connection, the
205 // implementation should start re-gathering on all networks of that interface.
206 virtual void RegatherOnFailedNetworks() {}
207 // Re-gathers candidates on all networks.
208 // TODO(honghaiz): Implement this in BasicPortAllocator.
209 virtual void RegatherOnAllNetworks() {}
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000210
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700211 // Another way of getting the information provided by the signals below.
212 //
213 // Ports and candidates are not guaranteed to be in the same order as the
214 // signals were emitted in.
215 virtual std::vector<PortInterface*> ReadyPorts() const = 0;
216 virtual std::vector<Candidate> ReadyCandidates() const = 0;
217 virtual bool CandidatesAllocationDone() const = 0;
Honghai Zhanga74363c2016-07-28 18:06:15 -0700218 // Marks all ports in the current session as "pruned" so that they may be
219 // destroyed if no connection is using them.
220 virtual void PruneAllPorts() {}
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700221
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000222 sigslot::signal2<PortAllocatorSession*, PortInterface*> SignalPortReady;
Honghai Zhang8eeecab2016-07-28 13:20:15 -0700223 // Fires this signal when the network of the ports failed (either because the
224 // interface is down, or because there is no connection on the interface),
225 // or when TURN ports are pruned because a higher-priority TURN port becomes
226 // ready(pairable).
Honghai Zhang5622c5e2016-07-01 13:59:29 -0700227 sigslot::signal2<PortAllocatorSession*, const std::vector<PortInterface*>&>
Honghai Zhang8eeecab2016-07-28 13:20:15 -0700228 SignalPortsPruned;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000229 sigslot::signal2<PortAllocatorSession*,
230 const std::vector<Candidate>&> SignalCandidatesReady;
Honghai Zhang5622c5e2016-07-01 13:59:29 -0700231 // Candidates should be signaled to be removed when the port that generated
232 // the candidates is removed.
233 sigslot::signal2<PortAllocatorSession*, const std::vector<Candidate>&>
234 SignalCandidatesRemoved;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000235 sigslot::signal1<PortAllocatorSession*> SignalCandidatesAllocationDone;
236
Honghai Zhangd93f50c2016-10-05 11:47:22 -0700237 sigslot::signal2<PortAllocatorSession*, IceRegatheringReason>
238 SignalIceRegathering;
239
Peter Boström0c4e06b2015-10-07 12:23:21 +0200240 virtual uint32_t generation() { return generation_; }
241 virtual void set_generation(uint32_t generation) { generation_ = generation; }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000242 sigslot::signal1<PortAllocatorSession*> SignalDestroyed;
243
deadbeefc55fb302016-05-12 12:51:38 -0700244 protected:
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700245 // This method is called when a pooled session (which doesn't have these
246 // properties initially) is returned by PortAllocator::TakePooledSession,
247 // and the content name, component, and ICE ufrag/pwd are updated.
248 //
249 // A subclass may need to override this method to perform additional actions,
250 // such as applying the updated information to ports and candidates.
251 virtual void UpdateIceParametersInternal() {}
252
deadbeefcbecd352015-09-23 11:50:27 -0700253 // TODO(deadbeef): Get rid of these when everyone switches to ice_ufrag and
254 // ice_pwd.
255 const std::string& username() const { return ice_ufrag_; }
256 const std::string& password() const { return ice_pwd_; }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000257
deadbeefc55fb302016-05-12 12:51:38 -0700258 private:
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700259 void SetIceParameters(const std::string& content_name,
260 int component,
261 const std::string& ice_ufrag,
262 const std::string& ice_pwd) {
263 content_name_ = content_name;
264 component_ = component;
265 ice_ufrag_ = ice_ufrag;
266 ice_pwd_ = ice_pwd;
267 UpdateIceParametersInternal();
268 }
269
deadbeefc55fb302016-05-12 12:51:38 -0700270 uint32_t flags_;
271 uint32_t generation_;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700272 std::string content_name_;
273 int component_;
deadbeefcbecd352015-09-23 11:50:27 -0700274 std::string ice_ufrag_;
275 std::string ice_pwd_;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700276
277 // SetIceParameters is an implementation detail which only PortAllocator
278 // should be able to call.
279 friend class PortAllocator;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000280};
281
Taylor Brandstetterf8e65772016-06-27 17:20:15 -0700282// Every method of PortAllocator (including the destructor) must be called on
283// the same thread, except for the constructor which may be called on any
284// thread.
285//
286// This allows constructing a PortAllocator subclass on one thread and
287// passing it into an object that uses it on a different thread.
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000288class PortAllocator : public sigslot::has_slots<> {
289 public:
290 PortAllocator() :
291 flags_(kDefaultPortAllocatorFlags),
292 min_port_(0),
293 max_port_(0),
294 step_delay_(kDefaultStepDelay),
295 allow_tcp_listen_(true),
296 candidate_filter_(CF_ALL) {
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000297 }
Peter Thatcher73ba7a62015-04-14 09:26:03 -0700298 virtual ~PortAllocator() {}
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000299
Taylor Brandstetterf8e65772016-06-27 17:20:15 -0700300 // This should be called on the PortAllocator's thread before the
301 // PortAllocator is used. Subclasses may override this if necessary.
302 virtual void Initialize() {}
303
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700304 // Set STUN and TURN servers to be used in future sessions, and set
305 // candidate pool size, as described in JSEP.
306 //
307 // If the servers are changing and the candidate pool size is nonzero,
308 // existing pooled sessions will be destroyed and new ones created.
309 //
310 // If the servers are not changing but the candidate pool size is,
311 // pooled sessions will be either created or destroyed as necessary.
deadbeef6de92f92016-12-12 18:49:32 -0800312 //
313 // Returns true if the configuration could successfully be changed.
314 bool SetConfiguration(const ServerAddresses& stun_servers,
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700315 const std::vector<RelayServerConfig>& turn_servers,
Honghai Zhangb9e7b4a2016-06-30 20:52:02 -0700316 int candidate_pool_size,
317 bool prune_turn_ports);
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700318
319 const ServerAddresses& stun_servers() const { return stun_servers_; }
320
321 const std::vector<RelayServerConfig>& turn_servers() const {
322 return turn_servers_;
323 }
324
deadbeef6de92f92016-12-12 18:49:32 -0800325 int candidate_pool_size() const { return candidate_pool_size_; }
deadbeef653b8e02015-11-11 12:55:10 -0800326
Taylor Brandstetter0c7e9f52015-12-29 14:14:52 -0800327 // Sets the network types to ignore.
328 // Values are defined by the AdapterType enum.
329 // For instance, calling this with
330 // ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK will ignore Ethernet and
331 // loopback interfaces.
332 virtual void SetNetworkIgnoreMask(int network_ignore_mask) = 0;
333
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700334 std::unique_ptr<PortAllocatorSession> CreateSession(
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000335 const std::string& content_name,
336 int component,
337 const std::string& ice_ufrag,
338 const std::string& ice_pwd);
339
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700340 // Get an available pooled session and set the transport information on it.
341 //
342 // Caller takes ownership of the returned session.
343 //
344 // If no pooled sessions are available, returns null.
345 std::unique_ptr<PortAllocatorSession> TakePooledSession(
346 const std::string& content_name,
347 int component,
348 const std::string& ice_ufrag,
349 const std::string& ice_pwd);
350
351 // Returns the next session that would be returned by TakePooledSession.
352 const PortAllocatorSession* GetPooledSession() const;
353
Peter Boström0c4e06b2015-10-07 12:23:21 +0200354 uint32_t flags() const { return flags_; }
355 void set_flags(uint32_t flags) { flags_ = flags; }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000356
357 const std::string& user_agent() const { return agent_; }
358 const rtc::ProxyInfo& proxy() const { return proxy_; }
359 void set_proxy(const std::string& agent, const rtc::ProxyInfo& proxy) {
360 agent_ = agent;
361 proxy_ = proxy;
362 }
363
364 // Gets/Sets the port range to use when choosing client ports.
365 int min_port() const { return min_port_; }
366 int max_port() const { return max_port_; }
367 bool SetPortRange(int min_port, int max_port) {
368 if (min_port > max_port) {
369 return false;
370 }
371
372 min_port_ = min_port;
373 max_port_ = max_port;
374 return true;
375 }
376
Peter Boström0c4e06b2015-10-07 12:23:21 +0200377 uint32_t step_delay() const { return step_delay_; }
378 void set_step_delay(uint32_t delay) { step_delay_ = delay; }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000379
380 bool allow_tcp_listen() const { return allow_tcp_listen_; }
381 void set_allow_tcp_listen(bool allow_tcp_listen) {
382 allow_tcp_listen_ = allow_tcp_listen;
383 }
384
Peter Boström0c4e06b2015-10-07 12:23:21 +0200385 uint32_t candidate_filter() { return candidate_filter_; }
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700386 void set_candidate_filter(uint32_t filter) {
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000387 candidate_filter_ = filter;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000388 }
389
Honghai Zhangb9e7b4a2016-06-30 20:52:02 -0700390 bool prune_turn_ports() const { return prune_turn_ports_; }
391
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000392 // Gets/Sets the Origin value used for WebRTC STUN requests.
393 const std::string& origin() const { return origin_; }
394 void set_origin(const std::string& origin) { origin_ = origin; }
395
Honghai Zhangd93f50c2016-10-05 11:47:22 -0700396 void SetMetricsObserver(webrtc::MetricsObserverInterface* observer) {
397 metrics_observer_ = observer;
398 }
399
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000400 protected:
401 virtual PortAllocatorSession* CreateSessionInternal(
402 const std::string& content_name,
403 int component,
404 const std::string& ice_ufrag,
405 const std::string& ice_pwd) = 0;
406
Honghai Zhangd93f50c2016-10-05 11:47:22 -0700407 webrtc::MetricsObserverInterface* metrics_observer() {
408 return metrics_observer_;
409 }
410
411 const std::deque<std::unique_ptr<PortAllocatorSession>>& pooled_sessions() {
412 return pooled_sessions_;
413 }
414
Peter Boström0c4e06b2015-10-07 12:23:21 +0200415 uint32_t flags_;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000416 std::string agent_;
417 rtc::ProxyInfo proxy_;
418 int min_port_;
419 int max_port_;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200420 uint32_t step_delay_;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000421 bool allow_tcp_listen_;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200422 uint32_t candidate_filter_;
pthatcher@webrtc.org0ba15332015-01-10 00:47:02 +0000423 std::string origin_;
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700424
425 private:
426 ServerAddresses stun_servers_;
427 std::vector<RelayServerConfig> turn_servers_;
deadbeef6de92f92016-12-12 18:49:32 -0800428 int candidate_pool_size_ = 0; // Last value passed into SetConfiguration.
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700429 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_;
Honghai Zhangb9e7b4a2016-06-30 20:52:02 -0700430 bool prune_turn_ports_ = false;
Honghai Zhangd93f50c2016-10-05 11:47:22 -0700431
432 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +0000433};
434
435} // namespace cricket
436
437#endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_