config.c 296 KB
Newer Older
1
/* Copyright (c) 2001 Matej Pfajfar.
Roger Dingledine's avatar
Roger Dingledine committed
2
 * Copyright (c) 2001-2004, Roger Dingledine.
3
 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4
 * Copyright (c) 2007-2017, The Tor Project, Inc. */
5
/* See LICENSE for licensing information */
6

Nick Mathewson's avatar
Nick Mathewson committed
7
/**
8
 * \file config.c
9
10
11
12
13
14
15
16
17
18
19
20
 * \brief Code to interpret the user's configuration of Tor.
 *
 * This module handles torrc configuration file, including parsing it,
 * combining it with torrc.defaults and the command line, allowing
 * user changes to it (via editing and SIGHUP or via the control port),
 * writing it back to disk (because of SAVECONF from the control port),
 * and -- most importantly, acting on it.
 *
 * The module additionally has some tools for manipulating and
 * inspecting values that are calculated as a result of the
 * configured options.
 *
21
 * <h3>How to add new options</h3>
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 *
 * To add new items to the torrc, there are a minimum of three places to edit:
 * <ul>
 *   <li>The or_options_t structure in or.h, where the options are stored.
 *   <li>The option_vars_ array below in this module, which configures
 *       the names of the torrc options, their types, their multiplicities,
 *       and their mappings to fields in or_options_t.
 *   <li>The manual in doc/tor.1.txt, to document what the new option
 *       is, and how it works.
 * </ul>
 *
 * Additionally, you might need to edit these places too:
 * <ul>
 *   <li>options_validate() below, in case you want to reject some possible
 *       values of the new configuration option.
 *   <li>options_transition_allowed() below, in case you need to
 *       forbid some or all changes in the option while Tor is
 *       running.
 *   <li>options_transition_affects_workers(), in case changes in the option
 *       might require Tor to relaunch or reconfigure its worker threads.
 *   <li>options_transition_affects_descriptor(), in case changes in the
 *       option might require a Tor relay to build and publish a new server
 *       descriptor.
 *   <li>options_act() and/or options_act_reversible(), in case there's some
 *       action that needs to be taken immediately based on the option's
 *       value.
 * </ul>
 *
 * <h3>Changing the value of an option</h3>
 *
 * Because of the SAVECONF command from the control port, it's a bad
 * idea to change the value of any user-configured option in the
 * or_options_t.  If you want to sometimes do this anyway, we recommend
 * that you create a secondary field in or_options_t; that you have the
 * user option linked only to the secondary field; that you use the
 * secondary field to initialize the one that Tor actually looks at; and that
 * you use the one Tor looks as the one that you modify.
Nick Mathewson's avatar
Nick Mathewson committed
59
60
 **/

61
#define CONFIG_PRIVATE
Roger Dingledine's avatar
Roger Dingledine committed
62
#include "or.h"
63
#include "bridges.h"
64
#include "compat.h"
65
#include "addressmap.h"
66
#include "channel.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
67
#include "circuitbuild.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
68
#include "circuitlist.h"
69
70
#include "circuitmux.h"
#include "circuitmux_ewma.h"
71
#include "circuitstats.h"
72
#include "compress.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
73
#include "config.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
74
#include "connection.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
75
#include "connection_edge.h"
76
#include "connection_or.h"
77
#include "consdiffmgr.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
78
#include "control.h"
79
#include "confparse.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
80
#include "cpuworker.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
81
#include "dirserv.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
82
#include "dirvote.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
83
#include "dns.h"
84
#include "dos.h"
85
#include "entrynodes.h"
86
#include "git_revision.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
87
#include "geoip.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
88
#include "hibernate.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
89
#include "main.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
90
#include "networkstatus.h"
91
#include "nodelist.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
92
#include "policies.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
93
#include "relay.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
94
#include "rendclient.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
95
#include "rendservice.h"
96
#include "hs_config.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
97
#include "rephist.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
98
#include "router.h"
99
#include "sandbox.h"
100
#include "util.h"
Sebastian Hahn's avatar
Sebastian Hahn committed
101
#include "routerlist.h"
102
#include "routerset.h"
103
#include "scheduler.h"
104
#include "statefile.h"
105
#include "transports.h"
106
#include "ext_orport.h"
107
#ifdef _WIN32
108
109
#include <shlobj.h>
#endif
Roger Dingledine's avatar
Roger Dingledine committed
110

111
112
#include "procmon.h"

113
114
115
116
117
118
#ifdef HAVE_SYSTEMD
#   if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__)
/* Systemd's use of gcc's __INCLUDE_LEVEL__ extension macro appears to confuse
 * Coverity. Here's a kludge to unconfuse it.
 */
#   define __INCLUDE_LEVEL__ 2
119
#endif /* defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__) */
120
#include <systemd/sd-daemon.h>
121
#endif /* defined(HAVE_SYSTEMD) */
122

123
/* Prefix used to indicate a Unix socket in a FooPort configuration. */
124
static const char unix_socket_prefix[] = "unix:";
125
126
127
/* Prefix used to indicate a Unix socket with spaces in it, in a FooPort
 * configuration. */
static const char unix_q_socket_prefix[] = "unix:\"";
128

129
130
131
132
133
/** macro to help with the bulk rename of *DownloadSchedule to
 * *DowloadInitialDelay . */
#define DOWNLOAD_SCHEDULE(name) \
  { #name "DownloadSchedule", #name "DownloadInitialDelay", 0, 1 }

134
135
/** A list of abbreviations and aliases to map command-line options, obsolete
 * option names, or alternative option names, to their current values. */
136
static config_abbrev_t option_abbrevs_[] = {
137
138
139
140
  PLURAL(AuthDirBadDirCC),
  PLURAL(AuthDirBadExitCC),
  PLURAL(AuthDirInvalidCC),
  PLURAL(AuthDirRejectCC),
141
  PLURAL(EntryNode),
142
  PLURAL(ExcludeNode),
143
  PLURAL(Tor2webRendezvousPoint),
144
  PLURAL(FirewallPort),
145
  PLURAL(LongLivedPort),
146
147
  PLURAL(HiddenServiceNode),
  PLURAL(HiddenServiceExcludeNode),
148
  PLURAL(NumCPU),
149
  PLURAL(RendNode),
150
  PLURAL(RecommendedPackage),
151
  PLURAL(RendExcludeNode),
152
153
  PLURAL(StrictEntryNode),
  PLURAL(StrictExitNode),
154
  PLURAL(StrictNode),
155
  { "l", "Log", 1, 0},
156
  { "AllowUnverifiedNodes", "AllowInvalidNodes", 0, 0},
157
158
  { "AutomapHostSuffixes", "AutomapHostsSuffixes", 0, 0},
  { "AutomapHostOnResolve", "AutomapHostsOnResolve", 0, 0},
159
160
161
  { "BandwidthRateBytes", "BandwidthRate", 0, 0},
  { "BandwidthBurstBytes", "BandwidthBurst", 0, 0},
  { "DirFetchPostPeriod", "StatusFetchPeriod", 0, 0},
162
  { "DirServer", "DirAuthority", 0, 0}, /* XXXX later, make this warn? */
163
  { "MaxConn", "ConnLimit", 0, 1},
164
  { "MaxMemInCellQueues", "MaxMemInQueues", 0, 0},
165
166
167
  { "ORBindAddress", "ORListenAddress", 0, 0},
  { "DirBindAddress", "DirListenAddress", 0, 0},
  { "SocksBindAddress", "SocksListenAddress", 0, 0},
168
169
170
171
  { "UseHelperNodes", "UseEntryGuards", 0, 0},
  { "NumHelperNodes", "NumEntryGuards", 0, 0},
  { "UseEntryNodes", "UseEntryGuards", 0, 0},
  { "NumEntryNodes", "NumEntryGuards", 0, 0},
172
173
  { "ResolvConf", "ServerDNSResolvConfFile", 0, 1},
  { "SearchDomains", "ServerDNSSearchDomains", 0, 1},
174
  { "ServerDNSAllowBrokenResolvConf", "ServerDNSAllowBrokenConfig", 0, 0},
175
  { "PreferTunnelledDirConns", "PreferTunneledDirConns", 0, 0},
176
  { "BridgeAuthoritativeDirectory", "BridgeAuthoritativeDir", 0, 0},
177
  { "HashedControlPassword", "__HashedControlSessionPassword", 1, 0},
178
  { "VirtualAddrNetwork", "VirtualAddrNetworkIPv4", 0, 0},
179
  { "SocksSocketsGroupWritable", "UnixSocksGroupWritable", 0, 1},
180
181
182
  { "_HSLayer2Nodes", "HSLayer2Nodes", 0, 1 },
  { "_HSLayer3Nodes", "HSLayer3Nodes", 0, 1 },

183
184
185
186
187
188
189
190
191
192
  DOWNLOAD_SCHEDULE(ClientBootstrapConsensusAuthority),
  DOWNLOAD_SCHEDULE(ClientBootstrapConsensusAuthorityOnly),
  DOWNLOAD_SCHEDULE(ClientBootstrapConsensusFallback),
  DOWNLOAD_SCHEDULE(TestingBridge),
  DOWNLOAD_SCHEDULE(TestingBridgeBootstrap),
  DOWNLOAD_SCHEDULE(TestingClient),
  DOWNLOAD_SCHEDULE(TestingClientConsensus),
  DOWNLOAD_SCHEDULE(TestingServer),
  DOWNLOAD_SCHEDULE(TestingServerConsensus),

193
194
  { NULL, NULL, 0, 0},
};
195

196
197
198
199
/** dummy instance of or_options_t, used for type-checking its
 * members with CONF_CHECK_VAR_TYPE. */
DUMMY_TYPECHECK_INSTANCE(or_options_t);

Nick Mathewson's avatar
Nick Mathewson committed
200
201
202
203
/** An entry for config_vars: "The option <b>name</b> has type
 * CONFIG_TYPE_<b>conftype</b>, and corresponds to
 * or_options_t.<b>member</b>"
 */
204
#define VAR(name,conftype,member,initvalue)                             \
Neel Chauhan's avatar
Neel Chauhan committed
205
  { name, CONFIG_TYPE_ ## conftype, offsetof(or_options_t, member),     \
206
      initvalue CONF_TEST_MEMBERS(or_options_t, conftype, member) }
207
208
209
/** As VAR, but the option name and member name are the same. */
#define V(member,conftype,initvalue)                                    \
  VAR(#member, conftype, member, initvalue)
Nick Mathewson's avatar
Nick Mathewson committed
210
/** An entry for config_vars: "The option <b>name</b> is obsolete." */
211
212
213
#ifdef TOR_UNIT_TESTS
#define OBSOLETE(name) { name, CONFIG_TYPE_OBSOLETE, 0, NULL, {.INT=NULL} }
#else
214
#define OBSOLETE(name) { name, CONFIG_TYPE_OBSOLETE, 0, NULL }
215
#endif
216

217
218
219
220
221
222
223
224
225
226
227
/**
 * Macro to declare *Port options.  Each one comes in three entries.
 * For example, most users should use "SocksPort" to configure the
 * socks port, but TorBrowser wants to use __SocksPort so that it
 * isn't stored by SAVECONF.  The SocksPortLines virtual option is
 * used to query both options from the controller.
 */
#define VPORT(member)                                           \
  VAR(#member "Lines", LINELIST_V, member ## _lines, NULL),     \
  VAR(#member, LINELIST_S, member ## _lines, NULL),             \
  VAR("__" #member, LINELIST_S, member ## _lines, NULL)
228

Nick Mathewson's avatar
Nick Mathewson committed
229
230
231
232
/** Array of configuration options.  Until we disallow nonstandard
 * abbreviations, order is significant, since the first matching option will
 * be chosen first.
 */
233
static config_var_t option_vars_[] = {
234
  V(AccountingMax,               MEMUNIT,  "0 bytes"),
235
  VAR("AccountingRule",          STRING,   AccountingRule_option,  "max"),
236
237
  V(AccountingStart,             STRING,   NULL),
  V(Address,                     STRING,   NULL),
Nick Mathewson's avatar
Nick Mathewson committed
238
  OBSOLETE("AllowDotExit"),
239
  OBSOLETE("AllowInvalidNodes"),
240
  V(AllowNonRFC953Hostnames,     BOOL,     "0"),
241
  OBSOLETE("AllowSingleHopCircuits"),
242
  OBSOLETE("AllowSingleHopExits"),
243
244
  V(AlternateBridgeAuthority,    LINELIST, NULL),
  V(AlternateDirAuthority,       LINELIST, NULL),
245
  OBSOLETE("AlternateHSAuthority"),
246
  V(AssumeReachable,             BOOL,     "0"),
247
248
  OBSOLETE("AuthDirBadDir"),
  OBSOLETE("AuthDirBadDirCCs"),
249
  V(AuthDirBadExit,              LINELIST, NULL),
250
  V(AuthDirBadExitCCs,           CSV,      ""),
251
  V(AuthDirInvalid,              LINELIST, NULL),
252
  V(AuthDirInvalidCCs,           CSV,      ""),
253
  V(AuthDirFastGuarantee,        MEMUNIT,  "100 KB"),
254
  V(AuthDirGuardBWGuarantee,     MEMUNIT,  "2 MB"),
255
  V(AuthDirPinKeys,              BOOL,     "1"),
256
  V(AuthDirReject,               LINELIST, NULL),
257
  V(AuthDirRejectCCs,            CSV,      ""),
258
  OBSOLETE("AuthDirRejectUnlisted"),
259
  OBSOLETE("AuthDirListBadDirs"),
260
  V(AuthDirListBadExits,         BOOL,     "0"),
261
  V(AuthDirMaxServersPerAddr,    UINT,     "2"),
262
  OBSOLETE("AuthDirMaxServersPerAuthAddr"),
263
  V(AuthDirHasIPv6Connectivity,  BOOL,     "0"),
264
265
266
267
  VAR("AuthoritativeDirectory",  BOOL, AuthoritativeDir,    "0"),
  V(AutomapHostsOnResolve,       BOOL,     "0"),
  V(AutomapHostsSuffixes,        CSV,      ".onion,.exit"),
  V(AvoidDiskWrites,             BOOL,     "0"),
268
269
  V(BandwidthBurst,              MEMUNIT,  "1 GB"),
  V(BandwidthRate,               MEMUNIT,  "1 GB"),
270
271
  V(BridgeAuthoritativeDir,      BOOL,     "0"),
  VAR("Bridge",                  LINELIST, Bridges,    NULL),
272
  V(BridgePassword,              STRING,   NULL),
273
  V(BridgeRecordUsageByCountry,  BOOL,     "1"),
274
  V(BridgeRelay,                 BOOL,     "0"),
275
  V(BridgeDistribution,          STRING,   NULL),
276
277
  VAR("CacheDirectory",          FILENAME, CacheDirectory_option, NULL),
  V(CacheDirectoryGroupReadable, BOOL,     "0"),
278
  V(CellStatistics,              BOOL,     "0"),
279
  V(PaddingStatistics,           BOOL,     "1"),
280
  V(LearnCircuitBuildTimeout,    BOOL,     "1"),
281
  V(CircuitBuildTimeout,         INTERVAL, "0"),
282
283
  OBSOLETE("CircuitIdleTimeout"),
  V(CircuitsAvailableTimeout,    INTERVAL, "0"),
284
  V(CircuitStreamTimeout,        INTERVAL, "0"),
285
  V(CircuitPriorityHalflife,     DOUBLE,  "-1.0"), /*negative:'Use default'*/
286
  V(ClientDNSRejectInternalAddresses, BOOL,"1"),
287
  V(ClientOnly,                  BOOL,     "0"),
288
289
  V(ClientPreferIPv6ORPort,      AUTOBOOL, "auto"),
  V(ClientPreferIPv6DirPort,     AUTOBOOL, "auto"),
290
  V(ClientRejectInternalAddresses, BOOL,   "1"),
291
  V(ClientTransportPlugin,       LINELIST, NULL),
292
  V(ClientUseIPv6,               BOOL,     "0"),
293
  V(ClientUseIPv4,               BOOL,     "1"),
294
  V(ConsensusParams,             STRING,   NULL),
295
  V(ConnLimit,                   UINT,     "1000"),
296
  V(ConnDirectionStatistics,     BOOL,     "0"),
297
298
299
  V(ConstrainedSockets,          BOOL,     "0"),
  V(ConstrainedSockSize,         MEMUNIT,  "8192"),
  V(ContactInfo,                 STRING,   NULL),
300
  OBSOLETE("ControlListenAddress"),
301
  VPORT(ControlPort),
302
  V(ControlPortFileGroupReadable,BOOL,     "0"),
303
  V(ControlPortWriteToFile,      FILENAME, NULL),
304
  V(ControlSocket,               LINELIST, NULL),
305
  V(ControlSocketsGroupWritable, BOOL,     "0"),
306
  V(UnixSocksGroupWritable,    BOOL,     "0"),
307
308
309
  V(CookieAuthentication,        BOOL,     "0"),
  V(CookieAuthFileGroupReadable, BOOL,     "0"),
  V(CookieAuthFile,              STRING,   NULL),
310
  V(CountPrivateBandwidth,       BOOL,     "0"),
311
  VAR("DataDirectory",           FILENAME, DataDirectory_option, NULL),
312
  V(DataDirectoryGroupReadable,  BOOL,     "0"),
313
  V(DisableOOSCheck,             BOOL,     "1"),
314
  V(DisableNetwork,              BOOL,     "0"),
315
  V(DirAllowPrivateAddresses,    BOOL,     "0"),
316
  V(TestingAuthDirTimeToLearnReachability, INTERVAL, "30 minutes"),
317
  OBSOLETE("DirListenAddress"),
318
  V(DirPolicy,                   LINELIST, NULL),
319
  VPORT(DirPort),
320
  V(DirPortFrontPage,            FILENAME, NULL),
321
  VAR("DirReqStatistics",        BOOL,     DirReqStatistics_option, "1"),
322
  VAR("DirAuthority",            LINELIST, DirAuthorities, NULL),
323
  V(DirCache,                    BOOL,     "1"),
324
325
326
327
328
  /* A DirAuthorityFallbackRate of 0.1 means that 0.5% of clients try an
   * authority when all fallbacks are up, and 2% try an authority when 25% of
   * fallbacks are down. (We rebuild the list when 25% of fallbacks are down).
   *
   * We want to reduce load on authorities, but keep these two figures within
Nick Mathewson's avatar
Nick Mathewson committed
329
330
   * an order of magnitude, so there isn't too much load shifting to
   * authorities when fallbacks go down. */
331
  V(DirAuthorityFallbackRate,    DOUBLE,   "0.1"),
332
  V(DisableAllSwap,              BOOL,     "0"),
333
  V(DisableDebuggerAttachment,   BOOL,     "1"),
334
  OBSOLETE("DisableIOCP"),
335
  OBSOLETE("DisableV2DirectoryInfo_"),
336
  OBSOLETE("DynamicDHGroups"),
337
  VPORT(DNSPort),
338
  OBSOLETE("DNSListenAddress"),
339
340
341
  /* DoS circuit creation options. */
  V(DoSCircuitCreationEnabled,   AUTOBOOL, "auto"),
  V(DoSCircuitCreationMinConnections,      UINT, "0"),
342
  V(DoSCircuitCreationRate,      UINT,     "0"),
343
344
345
346
347
348
349
350
351
  V(DoSCircuitCreationBurst,     UINT,     "0"),
  V(DoSCircuitCreationDefenseType,         INT,  "0"),
  V(DoSCircuitCreationDefenseTimePeriod,   INTERVAL, "0"),
  /* DoS connection options. */
  V(DoSConnectionEnabled,        AUTOBOOL, "auto"),
  V(DoSConnectionMaxConcurrentCount,       UINT, "0"),
  V(DoSConnectionDefenseType,    INT,      "0"),
  /* DoS single hop client options. */
  V(DoSRefuseSingleHopClientRendezvous,    AUTOBOOL, "auto"),
352
  V(DownloadExtraInfo,           BOOL,     "0"),
353
  V(TestingEnableConnBwEvent,    BOOL,     "0"),
354
  V(TestingEnableCellStatsEvent, BOOL,     "0"),
355
  OBSOLETE("TestingEnableTbEmptyEvent"),
356
  V(EnforceDistinctSubnets,      BOOL,     "1"),
357
  V(EntryNodes,                  ROUTERSET,   NULL),
358
  V(EntryStatistics,             BOOL,     "0"),
359
  V(TestingEstimatedDescriptorPropagationTime, INTERVAL, "10 minutes"),
360
361
  V(ExcludeNodes,                ROUTERSET, NULL),
  V(ExcludeExitNodes,            ROUTERSET, NULL),
362
  OBSOLETE("ExcludeSingleHopRelays"),
363
  V(ExitNodes,                   ROUTERSET, NULL),
364
365
  V(ExitPolicy,                  LINELIST, NULL),
  V(ExitPolicyRejectPrivate,     BOOL,     "1"),
366
  V(ExitPolicyRejectLocalInterfaces, BOOL, "0"),
367
  V(ExitPortStatistics,          BOOL,     "0"),
368
  V(ExtendAllowPrivateAddresses, BOOL,     "0"),
369
  V(ExitRelay,                   AUTOBOOL, "auto"),
370
  VPORT(ExtORPort),
371
  V(ExtORPortCookieAuthFile,     STRING,   NULL),
372
  V(ExtORPortCookieAuthFileGroupReadable, BOOL, "0"),
373
  V(ExtraInfoStatistics,         BOOL,     "1"),
374
  V(ExtendByEd25519ID,           AUTOBOOL, "auto"),
375
  V(FallbackDir,                 LINELIST, NULL),
376

377
  V(UseDefaultFallbackDirs,      BOOL,     "1"),
378

379
  OBSOLETE("FallbackNetworkstatusFile"),
380
381
  V(FascistFirewall,             BOOL,     "0"),
  V(FirewallPorts,               CSV,      ""),
382
  OBSOLETE("FastFirstHopPK"),
383
  V(FetchDirInfoEarly,           BOOL,     "0"),
384
  V(FetchDirInfoExtraEarly,      BOOL,     "0"),
385
386
387
  V(FetchServerDescriptors,      BOOL,     "1"),
  V(FetchHidServDescriptors,     BOOL,     "1"),
  V(FetchUselessDescriptors,     BOOL,     "0"),
388
  OBSOLETE("FetchV2Networkstatus"),
389
  V(GeoIPExcludeUnknown,         AUTOBOOL, "auto"),
390
#ifdef _WIN32
391
  V(GeoIPFile,                   FILENAME, "<default>"),
nils's avatar
nils committed
392
  V(GeoIPv6File,                 FILENAME, "<default>"),
393
#else
394
395
  V(GeoIPFile,                   FILENAME,
    SHARE_DATADIR PATH_SEPARATOR "tor" PATH_SEPARATOR "geoip"),
nils's avatar
nils committed
396
397
  V(GeoIPv6File,                 FILENAME,
    SHARE_DATADIR PATH_SEPARATOR "tor" PATH_SEPARATOR "geoip6"),
398
#endif /* defined(_WIN32) */
399
  OBSOLETE("Group"),
400
  V(GuardLifetime,               INTERVAL, "0 minutes"),
401
  V(HardwareAccel,               BOOL,     "0"),
402
  V(HeartbeatPeriod,             INTERVAL, "6 hours"),
Alexander Færøy's avatar
Alexander Færøy committed
403
  V(MainloopStats,               BOOL,     "0"),
404
405
  V(AccelName,                   STRING,   NULL),
  V(AccelDir,                    FILENAME, NULL),
406
  V(HashedControlPassword,       LINELIST, NULL),
407
  OBSOLETE("HidServDirectoryV2"),
Nick Mathewson's avatar
Nick Mathewson committed
408
  VAR("HiddenServiceDir",    LINELIST_S, RendConfigLines,    NULL),
409
  VAR("HiddenServiceDirGroupReadable",  LINELIST_S, RendConfigLines, NULL),
Nick Mathewson's avatar
Nick Mathewson committed
410
411
  VAR("HiddenServiceOptions",LINELIST_V, RendConfigLines,    NULL),
  VAR("HiddenServicePort",   LINELIST_S, RendConfigLines,    NULL),
412
  VAR("HiddenServiceVersion",LINELIST_S, RendConfigLines,    NULL),
413
  VAR("HiddenServiceAuthorizeClient",LINELIST_S,RendConfigLines, NULL),
414
  VAR("HiddenServiceAllowUnknownPorts",LINELIST_S, RendConfigLines, NULL),
415
416
  VAR("HiddenServiceMaxStreams",LINELIST_S, RendConfigLines, NULL),
  VAR("HiddenServiceMaxStreamsCloseCircuit",LINELIST_S, RendConfigLines, NULL),
417
  VAR("HiddenServiceNumIntroductionPoints", LINELIST_S, RendConfigLines, NULL),
Nick Mathewson's avatar
Nick Mathewson committed
418
  VAR("HiddenServiceStatistics", BOOL, HiddenServiceStatistics_option, "1"),
419
  V(HidServAuth,                 LINELIST, NULL),
420
  OBSOLETE("CloseHSClientCircuitsImmediatelyOnTimeout"),
421
  OBSOLETE("CloseHSServiceRendCircuitsImmediatelyOnTimeout"),
422
423
  V(HiddenServiceSingleHopMode,  BOOL,     "0"),
  V(HiddenServiceNonAnonymousMode,BOOL,    "0"),
424
425
426
427
  V(HTTPProxy,                   STRING,   NULL),
  V(HTTPProxyAuthenticator,      STRING,   NULL),
  V(HTTPSProxy,                  STRING,   NULL),
  V(HTTPSProxyAuthenticator,     STRING,   NULL),
428
  VPORT(HTTPTunnelPort),
429
  V(IPv6Exit,                    BOOL,     "0"),
430
  VAR("ServerTransportPlugin",   LINELIST, ServerTransportPlugin,  NULL),
431
  V(ServerTransportListenAddr,   LINELIST, NULL),
432
  V(ServerTransportOptions,      LINELIST, NULL),
433
  V(SigningKeyLifetime,          INTERVAL, "30 days"),
434
435
436
437
  V(Socks4Proxy,                 STRING,   NULL),
  V(Socks5Proxy,                 STRING,   NULL),
  V(Socks5ProxyUsername,         STRING,   NULL),
  V(Socks5ProxyPassword,         STRING,   NULL),
438
439
  VAR("KeyDirectory",            FILENAME, KeyDirectory_option, NULL),
  V(KeyDirectoryGroupReadable,   BOOL,     "0"),
440
441
  VAR("HSLayer2Nodes",           ROUTERSET,  HSLayer2Nodes,  NULL),
  VAR("HSLayer3Nodes",           ROUTERSET,  HSLayer3Nodes,  NULL),
442
  V(KeepalivePeriod,             INTERVAL, "5 minutes"),
443
  V(KeepBindCapabilities,            AUTOBOOL, "auto"),
444
  VAR("Log",                     LINELIST, Logs,             NULL),
445
  V(LogMessageDomains,           BOOL,     "0"),
446
  V(LogTimeGranularity,          MSEC_INTERVAL, "1 second"),
Arlo Breault's avatar
Arlo Breault committed
447
  V(TruncateLogFile,             BOOL,     "0"),
Peter Palfrader's avatar
Peter Palfrader committed
448
  V(SyslogIdentityTag,           STRING,   NULL),
449
  V(AndroidIdentityTag,          STRING,   NULL),
450
  V(LongLivedPorts,              CSV,
Nick Mathewson's avatar
Nick Mathewson committed
451
        "21,22,706,1863,5050,5190,5222,5223,6523,6667,6697,8300"),
452
453
454
  VAR("MapAddress",              LINELIST, AddressMap,           NULL),
  V(MaxAdvertisedBandwidth,      MEMUNIT,  "1 GB"),
  V(MaxCircuitDirtiness,         INTERVAL, "10 minutes"),
455
  V(MaxClientCircuitsPending,    UINT,     "32"),
456
  V(MaxConsensusAgeForDiffs,     INTERVAL, "0 seconds"),
457
  VAR("MaxMemInQueues",          MEMUNIT,   MaxMemInQueues_raw, "0"),
458
459
  OBSOLETE("MaxOnionsPending"),
  V(MaxOnionQueueDelay,          MSEC_INTERVAL, "1750 msec"),
460
  V(MaxUnparseableDescSizeToLog, MEMUNIT, "10 MB"),
461
  V(MinMeasuredBWsForAuthToIgnoreAdvertised, INT, "500"),
462
  VAR("MyFamily",                LINELIST, MyFamily_lines,       NULL),
463
  V(NewCircuitPeriod,            INTERVAL, "30 seconds"),
464
  OBSOLETE("NamingAuthoritativeDirectory"),
465
  OBSOLETE("NATDListenAddress"),
466
  VPORT(NATDPort),
467
  V(Nickname,                    STRING,   NULL),
468
  OBSOLETE("PredictedPortsRelevanceTime"),
469
  OBSOLETE("WarnUnsafeSocks"),
470
  VAR("NodeFamily",              LINELIST, NodeFamilies,         NULL),
471
  V(NoExec,                      BOOL,     "0"),
472
  V(NumCPUs,                     UINT,     "0"),
473
  V(NumDirectoryGuards,          UINT,     "0"),
474
  V(NumEntryGuards,              UINT,     "0"),
Nick Mathewson's avatar
Nick Mathewson committed
475
  V(OfflineMasterKey,            BOOL,     "0"),
476
  OBSOLETE("ORListenAddress"),
477
  VPORT(ORPort),
478
  V(OutboundBindAddress,         LINELIST,   NULL),
479
480
  V(OutboundBindAddressOR,       LINELIST,   NULL),
  V(OutboundBindAddressExit,     LINELIST,   NULL),
481

482
  OBSOLETE("PathBiasDisableRate"),
483
484
  V(PathBiasCircThreshold,       INT,      "-1"),
  V(PathBiasNoticeRate,          DOUBLE,   "-1"),
485
  V(PathBiasWarnRate,            DOUBLE,   "-1"),
486
  V(PathBiasExtremeRate,         DOUBLE,   "-1"),
487
  V(PathBiasScaleThreshold,      INT,      "-1"),
488
489
  OBSOLETE("PathBiasScaleFactor"),
  OBSOLETE("PathBiasMultFactor"),
490
  V(PathBiasDropGuards,          AUTOBOOL, "0"),
491
492
493
494
495
496
  OBSOLETE("PathBiasUseCloseCounts"),

  V(PathBiasUseThreshold,       INT,      "-1"),
  V(PathBiasNoticeUseRate,          DOUBLE,   "-1"),
  V(PathBiasExtremeUseRate,         DOUBLE,   "-1"),
  V(PathBiasScaleUseThreshold,      INT,      "-1"),
497

498
  V(PathsNeededToBuildCircuits,  DOUBLE,   "-1"),
499
500
  V(PerConnBWBurst,              MEMUNIT,  "0"),
  V(PerConnBWRate,               MEMUNIT,  "0"),
501
  V(PidFile,                     STRING,   NULL),
502
  V(TestingTorNetwork,           BOOL,     "0"),
503
  V(TestingMinExitFlagThreshold, MEMUNIT,  "0"),
504
  V(TestingMinFastFlagThreshold, MEMUNIT,  "0"),
505

506
  V(TestingLinkCertLifetime,          INTERVAL, "2 days"),
507
508
509
510
511
  V(TestingAuthKeyLifetime,          INTERVAL, "2 days"),
  V(TestingLinkKeySlop,              INTERVAL, "3 hours"),
  V(TestingAuthKeySlop,              INTERVAL, "3 hours"),
  V(TestingSigningKeySlop,           INTERVAL, "1 day"),

512
  V(OptimisticData,              AUTOBOOL, "auto"),
513
514
  OBSOLETE("PortForwarding"),
  OBSOLETE("PortForwardingHelper"),
515
  OBSOLETE("PreferTunneledDirConns"),
516
  V(ProtocolWarnings,            BOOL,     "0"),
517
  V(PublishServerDescriptor,     CSV,      "1"),
518
519
520
521
522
523
524
  V(PublishHidServDescriptors,   BOOL,     "1"),
  V(ReachableAddresses,          LINELIST, NULL),
  V(ReachableDirAddresses,       LINELIST, NULL),
  V(ReachableORAddresses,        LINELIST, NULL),
  V(RecommendedVersions,         LINELIST, NULL),
  V(RecommendedClientVersions,   LINELIST, NULL),
  V(RecommendedServerVersions,   LINELIST, NULL),
525
  V(RecommendedPackages,         LINELIST, NULL),
526
527
  V(ReducedConnectionPadding,    BOOL,     "0"),
  V(ConnectionPadding,           AUTOBOOL, "auto"),
528
  V(RefuseUnknownExits,          AUTOBOOL, "auto"),
529
  V(RejectPlaintextPorts,        CSV,      ""),
530
531
532
533
534
  V(RelayBandwidthBurst,         MEMUNIT,  "0"),
  V(RelayBandwidthRate,          MEMUNIT,  "0"),
  V(RendPostPeriod,              INTERVAL, "1 hour"),
  V(RephistTrackTime,            INTERVAL, "24 hours"),
  V(RunAsDaemon,                 BOOL,     "0"),
535
  V(ReducedExitPolicy,           BOOL,     "0"),
536
  OBSOLETE("RunTesting"), // currently unused
537
  V(Sandbox,                     BOOL,     "0"),
538
  V(SafeLogging,                 STRING,   "1"),
539
  V(SafeSocks,                   BOOL,     "0"),
540
  V(ServerDNSAllowBrokenConfig,  BOOL,     "1"),
541
542
  V(ServerDNSAllowNonRFC953Hostnames, BOOL,"0"),
  V(ServerDNSDetectHijacking,    BOOL,     "1"),
543
  V(ServerDNSRandomizeCase,      BOOL,     "1"),
544
545
546
  V(ServerDNSResolvConfFile,     STRING,   NULL),
  V(ServerDNSSearchDomains,      BOOL,     "0"),
  V(ServerDNSTestAddresses,      CSV,
547
      "www.google.com,www.mit.edu,www.yahoo.com,www.slashdot.org"),
548
549
550
551
552
  OBSOLETE("SchedulerLowWaterMark__"),
  OBSOLETE("SchedulerHighWaterMark__"),
  OBSOLETE("SchedulerMaxFlushCells__"),
  V(KISTSchedRunInterval,        MSEC_INTERVAL, "0 msec"),
  V(KISTSockBufSizeFactor,       DOUBLE,   "1.0"),
553
  V(Schedulers,                  CSV,      "KIST,KISTLite,Vanilla"),
554
  V(ShutdownWaitLength,          INTERVAL, "30 seconds"),
555
  OBSOLETE("SocksListenAddress"),
556
  V(SocksPolicy,                 LINELIST, NULL),
557
  VPORT(SocksPort),
558
  V(SocksTimeout,                INTERVAL, "2 minutes"),
559
  V(SSLKeyLifetime,              INTERVAL, "0"),
560
561
  OBSOLETE("StrictEntryNodes"),
  OBSOLETE("StrictExitNodes"),
562
  V(StrictNodes,                 BOOL,     "0"),
563
  OBSOLETE("Support022HiddenServices"),
564
  V(TestSocks,                   BOOL,     "0"),
565
  V(TokenBucketRefillInterval,   MSEC_INTERVAL, "100 msec"),
566
  V(Tor2webMode,                 BOOL,     "0"),
567
  V(Tor2webRendezvousPoints,      ROUTERSET, NULL),
568
  OBSOLETE("TLSECGroup"),
569
570
  V(TrackHostExits,              CSV,      NULL),
  V(TrackHostExitsExpire,        INTERVAL, "30 minutes"),
571
  OBSOLETE("TransListenAddress"),
572
  VPORT(TransPort),
573
  V(TransProxyType,              STRING,   "default"),
574
  OBSOLETE("TunnelDirConns"),
575
  V(UpdateBridgesFromAuthority,  BOOL,     "0"),
576
  V(UseBridges,                  BOOL,     "0"),
577
  VAR("UseEntryGuards",          BOOL,     UseEntryGuards_option, "1"),
Nick Mathewson's avatar
Nick Mathewson committed
578
  OBSOLETE("UseEntryGuardsAsDirGuards"),
579
  V(UseGuardFraction,            AUTOBOOL, "auto"),
580
  V(UseMicrodescriptors,         AUTOBOOL, "auto"),
581
  OBSOLETE("UseNTorHandshake"),
582
  V(User,                        STRING,   NULL),
583
  OBSOLETE("UserspaceIOCPBuffers"),
584
  V(AuthDirSharedRandomness,     BOOL,     "1"),
585
  V(AuthDirTestEd25519LinkKeys,  BOOL,     "1"),
586
  OBSOLETE("V1AuthoritativeDirectory"),
587
  OBSOLETE("V2AuthoritativeDirectory"),
588
  VAR("V3AuthoritativeDirectory",BOOL, V3AuthoritativeDir,   "0"),
589
590
591
  V(TestingV3AuthInitialVotingInterval, INTERVAL, "30 minutes"),
  V(TestingV3AuthInitialVoteDelay, INTERVAL, "5 minutes"),
  V(TestingV3AuthInitialDistDelay, INTERVAL, "5 minutes"),
592
  V(TestingV3AuthVotingStartOffset, INTERVAL, "0"),
593
594
595
596
  V(V3AuthVotingInterval,        INTERVAL, "1 hour"),
  V(V3AuthVoteDelay,             INTERVAL, "5 minutes"),
  V(V3AuthDistDelay,             INTERVAL, "5 minutes"),
  V(V3AuthNIntervalsValid,       UINT,     "3"),
597
  V(V3AuthUseLegacyKey,          BOOL,     "0"),
598
  V(V3BandwidthsFile,            FILENAME, NULL),
599
  V(GuardfractionFile,           FILENAME, NULL),
600
  VAR("VersioningAuthoritativeDirectory",BOOL,VersioningAuthoritativeDir, "0"),
601
  OBSOLETE("VoteOnHidServDirectoriesV2"),
602
603
  V(VirtualAddrNetworkIPv4,      STRING,   "127.192.0.0/10"),
  V(VirtualAddrNetworkIPv6,      STRING,   "[FE80::]/10"),
604
  V(WarnPlaintextPorts,          CSV,      "23,109,110,143"),
605
606
  OBSOLETE("UseFilteringSSLBufferevents"),
  OBSOLETE("__UseFilteringSSLBufferevents"),
607
  VAR("__ReloadTorrcOnSIGHUP",   BOOL,  ReloadTorrcOnSIGHUP,      "1"),
608
609
  VAR("__AllDirActionsPrivate",  BOOL,  AllDirActionsPrivate,     "0"),
  VAR("__DisablePredictedCircuits",BOOL,DisablePredictedCircuits, "0"),
610
  VAR("__DisableSignalHandlers", BOOL,  DisableSignalHandlers,    "0"),
611
  VAR("__LeaveStreamsUnattached",BOOL,  LeaveStreamsUnattached,   "0"),
612
613
  VAR("__HashedControlSessionPassword", LINELIST, HashedControlSessionPassword,
      NULL),
614
  VAR("__OwningControllerProcess",STRING,OwningControllerProcess, NULL),
615
  VAR("__OwningControllerFD",INT,OwningControllerFD, "-1"),
616
  V(MinUptimeHidServDirectoryV2, INTERVAL, "96 hours"),
617
  V(TestingServerDownloadInitialDelay, CSV_INTERVAL, "0, 0, 0, 60, 60, 120, "
618
                                 "300, 900, 2147483647"),
619
  V(TestingClientDownloadInitialDelay, CSV_INTERVAL, "0, 0, 60, 300, 600, "
620
                                 "2147483647"),
621
  V(TestingServerConsensusDownloadInitialDelay, CSV_INTERVAL, "0, 0, 60, "
622
623
                                 "300, 600, 1800, 1800, 1800, 1800, "
                                 "1800, 3600, 7200"),
624
  V(TestingClientConsensusDownloadInitialDelay, CSV_INTERVAL, "0, 0, 60, "
625
626
                                 "300, 600, 1800, 3600, 3600, 3600, "
                                 "10800, 21600, 43200"),
627
  /* With the ClientBootstrapConsensus*Download* below:
628
   * Clients with only authorities will try:
629
630
   *  - at least 3 authorities over 10 seconds, then exponentially backoff,
   *    with the next attempt 3-21 seconds later,
631
   * Clients with authorities and fallbacks will try:
632
633
   *  - at least 2 authorities and 4 fallbacks over 21 seconds, then
   *    exponentially backoff, with the next attempts 4-33 seconds later,
634
   * Clients will also retry when an application request arrives.
635
   * After a number of failed requests, clients retry every 3 days + 1 hour.
636
637
638
639
640
641
   *
   * Clients used to try 2 authorities over 10 seconds, then wait for
   * 60 minutes or an application request.
   *
   * When clients have authorities and fallbacks available, they use these
   * schedules: (we stagger the times to avoid thundering herds) */
642
  V(ClientBootstrapConsensusAuthorityDownloadInitialDelay, CSV_INTERVAL,
643
    "6, 11, 3600, 10800, 25200, 54000, 111600, 262800" /* 3 days + 1 hour */),
644
  V(ClientBootstrapConsensusFallbackDownloadInitialDelay, CSV_INTERVAL,
645
646
    "0, 1, 4, 11, 3600, 10800, 25200, 54000, 111600, 262800"),
  /* When clients only have authorities available, they use this schedule: */
647
  V(ClientBootstrapConsensusAuthorityOnlyDownloadInitialDelay, CSV_INTERVAL,
648
649
650
651
652
    "0, 3, 7, 3600, 10800, 25200, 54000, 111600, 262800"),
  /* We don't want to overwhelm slow networks (or mirrors whose replies are
   * blocked), but we also don't want to fail if only some mirrors are
   * blackholed. Clients will try 3 directories simultaneously.
   * (Relays never use simultaneous connections.) */
653
  V(ClientBootstrapConsensusMaxInProgressTries, UINT, "3"),
654
655
  /* When a client has any running bridges, check each bridge occasionally,
    * whether or not that bridge is actually up. */
656
  V(TestingBridgeDownloadInitialDelay, CSV_INTERVAL,
657
658
659
660
661
    "10800, 25200, 54000, 111600, 262800"),
  /* When a client is just starting, or has no running bridges, check each
   * bridge a few times quickly, and then try again later. These schedules
   * are much longer than the other schedules, because we try each and every
   * configured bridge with this schedule. */
662
  V(TestingBridgeBootstrapDownloadInitialDelay, CSV_INTERVAL,
663
    "0, 30, 90, 600, 3600, 10800, 25200, 54000, 111600, 262800"),
664
665
  V(TestingClientMaxIntervalWithoutRequest, INTERVAL, "10 minutes"),
  V(TestingDirConnectionMaxStall, INTERVAL, "5 minutes"),
666
667
668
669
670
671
  OBSOLETE("TestingConsensusMaxDownloadTries"),
  OBSOLETE("ClientBootstrapConsensusMaxDownloadTries"),
  OBSOLETE("ClientBootstrapConsensusAuthorityOnlyMaxDownloadTries"),
  OBSOLETE("TestingDescriptorMaxDownloadTries"),
  OBSOLETE("TestingMicrodescMaxDownloadTries"),
  OBSOLETE("TestingCertMaxDownloadTries"),
672
  V(TestingDirAuthVoteExit, ROUTERSET, NULL),
673
  V(TestingDirAuthVoteExitIsStrict,  BOOL,     "0"),
674
  V(TestingDirAuthVoteGuard, ROUTERSET, NULL),
675
  V(TestingDirAuthVoteGuardIsStrict,  BOOL,     "0"),
676
  V(TestingDirAuthVoteHSDir, ROUTERSET, NULL),
677
  V(TestingDirAuthVoteHSDirIsStrict,  BOOL,     "0"),
678
  VAR("___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_, "0"),
679

680
  END_OF_CONFIG_VARS
681
};
682

683
684
/** Override default values with these if the user sets the TestingTorNetwork
 * option. */
685
static const config_var_t testing_tor_network_defaults[] = {
686
687
688
689
  V(DirAllowPrivateAddresses,    BOOL,     "1"),
  V(EnforceDistinctSubnets,      BOOL,     "0"),
  V(AssumeReachable,             BOOL,     "1"),
  V(AuthDirMaxServersPerAddr,    UINT,     "0"),
690
  V(ClientBootstrapConsensusAuthorityDownloadInitialDelay, CSV_INTERVAL,
691
    "0, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 16, 32, 60"),
692
  V(ClientBootstrapConsensusFallbackDownloadInitialDelay, CSV_INTERVAL,
693
    "0, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 16, 32, 60"),
694
  V(ClientBootstrapConsensusAuthorityOnlyDownloadInitialDelay, CSV_INTERVAL,
695
    "0, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 16, 32, 60"),
696
  V(ClientDNSRejectInternalAddresses, BOOL,"0"),
697
  V(ClientRejectInternalAddresses, BOOL,   "0"),
698
  V(CountPrivateBandwidth,       BOOL,     "1"),
699
  V(ExitPolicyRejectPrivate,     BOOL,     "0"),
700
  V(ExtendAllowPrivateAddresses, BOOL,     "1"),
701
702
703
  V(V3AuthVotingInterval,        INTERVAL, "5 minutes"),
  V(V3AuthVoteDelay,             INTERVAL, "20 seconds"),
  V(V3AuthDistDelay,             INTERVAL, "20 seconds"),
704
  V(TestingV3AuthInitialVotingInterval, INTERVAL, "150 seconds"),
705
706
707
708
  V(TestingV3AuthInitialVoteDelay, INTERVAL, "20 seconds"),
  V(TestingV3AuthInitialDistDelay, INTERVAL, "20 seconds"),
  V(TestingAuthDirTimeToLearnReachability, INTERVAL, "0 minutes"),
  V(TestingEstimatedDescriptorPropagationTime, INTERVAL, "0 minutes"),
709
  V(MinUptimeHidServDirectoryV2, INTERVAL, "0 minutes"),
710
  V(TestingServerDownloadInitialDelay, CSV_INTERVAL, "0, 0, 0, 5, 10, 15, "
711
                                 "20, 30, 60"),
712
  V(TestingClientDownloadInitialDelay, CSV_INTERVAL, "0, 0, 5, 10, 15, 20, "
713
                                 "30, 60"),
714
  V(TestingServerConsensusDownloadInitialDelay, CSV_INTERVAL, "0, 0, 5, 10, "
715
                                 "15, 20, 30, 60"),
716
  V(TestingClientConsensusDownloadInitialDelay, CSV_INTERVAL, "0, 0, 5, 10, "
717
                                 "15, 20, 30, 60"),
718
719
  V(TestingBridgeDownloadInitialDelay, CSV_INTERVAL, "10, 30, 60"),
  V(TestingBridgeBootstrapDownloadInitialDelay, CSV_INTERVAL, "0, 0, 5, 10, "
720
                                 "15, 20, 30, 60"),
721
722
  V(TestingClientMaxIntervalWithoutRequest, INTERVAL, "5 seconds"),
  V(TestingDirConnectionMaxStall, INTERVAL, "30 seconds"),
723
  V(TestingEnableConnBwEvent,    BOOL,     "1"),
724
  V(TestingEnableCellStatsEvent, BOOL,     "1"),
725
  VAR("___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_, "1"),