config.c 298 KB
Newer Older
1

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

Nick Mathewson's avatar
Nick Mathewson committed
8
/**
9
 * \file config.c
10
11
12
13
14
15
16
17
18
19
20
21
 * \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.
 *
22
 * <h3>How to add new options</h3>
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
59
 *
 * 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
60
61
 **/

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

114
115
#include "procmon.h"

116
#include "dirauth/dirvote.h"
117
#include "dirauth/mode.h"
118

119
120
121
122
123
124
#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
125
#endif /* defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__) */
126
#include <systemd/sd-daemon.h>
127
#endif /* defined(HAVE_SYSTEMD) */
128

129
/* Prefix used to indicate a Unix socket in a FooPort configuration. */
130
static const char unix_socket_prefix[] = "unix:";
131
132
133
/* Prefix used to indicate a Unix socket with spaces in it, in a FooPort
 * configuration. */
static const char unix_q_socket_prefix[] = "unix:\"";
134

135
136
137
138
139
/** macro to help with the bulk rename of *DownloadSchedule to
 * *DowloadInitialDelay . */
#define DOWNLOAD_SCHEDULE(name) \
  { #name "DownloadSchedule", #name "DownloadInitialDelay", 0, 1 }

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

189
190
191
192
193
194
195
196
197
198
  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),

199
200
  { NULL, NULL, 0, 0},
};
201

202
203
204
205
/** 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
206
207
208
209
/** 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>"
 */
210
#define VAR(name,conftype,member,initvalue)                             \
Neel Chauhan's avatar
Neel Chauhan committed
211
  { name, CONFIG_TYPE_ ## conftype, offsetof(or_options_t, member),     \
212
      initvalue CONF_TEST_MEMBERS(or_options_t, conftype, member) }
213
214
215
/** 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
216
/** An entry for config_vars: "The option <b>name</b> is obsolete." */
217
218
219
#ifdef TOR_UNIT_TESTS
#define OBSOLETE(name) { name, CONFIG_TYPE_OBSOLETE, 0, NULL, {.INT=NULL} }
#else
220
#define OBSOLETE(name) { name, CONFIG_TYPE_OBSOLETE, 0, NULL }
221
#endif
222

223
224
225
226
227
228
229
230
231
232
233
/**
 * 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)
234

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

383
  V(UseDefaultFallbackDirs,      BOOL,     "1"),
384

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

489
  OBSOLETE("PathBiasDisableRate"),
490
491
  V(PathBiasCircThreshold,       INT,      "-1"),
  V(PathBiasNoticeRate,          DOUBLE,   "-1"),
492
  V(PathBiasWarnRate,            DOUBLE,   "-1"),
493
  V(PathBiasExtremeRate,         DOUBLE,   "-1"),
494
  V(PathBiasScaleThreshold,      INT,      "-1"),
495
496
  OBSOLETE("PathBiasScaleFactor"),
  OBSOLETE("PathBiasMultFactor"),
497
  V(PathBiasDropGuards,          AUTOBOOL, "0"),
498
499
500
501
502
503
  OBSOLETE("PathBiasUseCloseCounts"),

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

505
  V(PathsNeededToBuildCircuits,  DOUBLE,   "-1"),
506
507
  V(PerConnBWBurst,              MEMUNIT,  "0"),
  V(PerConnBWRate,               MEMUNIT,  "0"),
508
  V(PidFile,                     STRING,   NULL),
509
  V(TestingTorNetwork,           BOOL,     "0"),
510
  V(TestingMinExitFlagThreshold, MEMUNIT,  "0"),
511
  V(TestingMinFastFlagThreshold, MEMUNIT,  "0"),
512

513
  V(TestingLinkCertLifetime,          INTERVAL, "2 days"),
514
515
516
517
518
  V(TestingAuthKeyLifetime,          INTERVAL, "2 days"),
  V(TestingLinkKeySlop,              INTERVAL, "3 hours"),
  V(TestingAuthKeySlop,              INTERVAL, "3 hours"),
  V(TestingSigningKeySlop,           INTERVAL, "1 day"),

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

677
  END_OF_CONFIG_VARS
678
};
679

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

718
  END_OF_CONFIG_VARS
719
};
720

721
#undef VAR
722
#undef V
723
724
#undef OBSOLETE

725
static const config_deprecation_t option_deprecation_notes_[] = {
726
  /* Deprecated since 0.3.2.0-alpha. */
727
728
729
730
  { "HTTPProxy", "It only applies to direct unencrypted HTTP connections "
    "to your directory server, which your Tor probably wasn't using." },
  { "HTTPProxyAuthenticator", "HTTPProxy is deprecated in favor of HTTPSProxy "
    "which should be used with HTTPSProxyAuthenticator." },
731
732
733
  /* End of options deprecated since 0.3.2.1-alpha */

  /* Options deprecated since 0.3.2.2-alpha */
734
735
736
737
  { "ReachableDirAddresses", "It has no effect on relays, and has had no "
    "effect on clients since 0.2.8." },
  { "ClientPreferIPv6DirPort", "It has no effect on relays, and has had no "
    "effect on clients since 0.2.8." },
Nick Mathewson's avatar