80#include "trunnel/conflux.h"
81#include "core/or/dos.h"
133#ifdef HAVE_SYS_STAT_H
136#ifdef HAVE_SYS_PARAM_H
137#include <sys/param.h>
165# if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__)
169# define __INCLUDE_LEVEL__ 2
171#include <systemd/sd-daemon.h>
175static const char unix_socket_prefix[] =
"unix:";
178static const char unix_q_socket_prefix[] =
"unix:\"";
181#define MIN_CONSTRAINED_TCP_BUFFER 2048
182#define MAX_CONSTRAINED_TCP_BUFFER 262144
187#define DOWNLOAD_SCHEDULE(name) \
188 { (#name "DownloadSchedule"), (#name "DownloadInitialDelay"), 0, 1 }
187#define DOWNLOAD_SCHEDULE(name) \ …
190#define DOWNLOAD_SCHEDULE(name) { NULL, NULL, 0, 1 }
199 PLURAL(AuthDirMiddleOnlyCC),
205 PLURAL(HiddenServiceNode),
206 PLURAL(HiddenServiceExcludeNode),
209 PLURAL(RecommendedPackage),
215 {
"AllowUnverifiedNodes",
"AllowInvalidNodes", 0, 0},
216 {
"AutomapHostSuffixes",
"AutomapHostsSuffixes", 0, 0},
217 {
"AutomapHostOnResolve",
"AutomapHostsOnResolve", 0, 0},
218 {
"BandwidthRateBytes",
"BandwidthRate", 0, 0},
219 {
"BandwidthBurstBytes",
"BandwidthBurst", 0, 0},
220 {
"DirFetchPostPeriod",
"StatusFetchPeriod", 0, 0},
221 {
"DirServer",
"DirAuthority", 0, 0},
222 {
"MaxConn",
"ConnLimit", 0, 1},
223 {
"MaxMemInCellQueues",
"MaxMemInQueues", 0, 0},
224 {
"ORBindAddress",
"ORListenAddress", 0, 0},
225 {
"DirBindAddress",
"DirListenAddress", 0, 0},
226 {
"SocksBindAddress",
"SocksListenAddress", 0, 0},
227 {
"UseHelperNodes",
"UseEntryGuards", 0, 0},
228 {
"NumHelperNodes",
"NumEntryGuards", 0, 0},
229 {
"UseEntryNodes",
"UseEntryGuards", 0, 0},
230 {
"NumEntryNodes",
"NumEntryGuards", 0, 0},
231 {
"ResolvConf",
"ServerDNSResolvConfFile", 0, 1},
232 {
"SearchDomains",
"ServerDNSSearchDomains", 0, 1},
233 {
"ServerDNSAllowBrokenResolvConf",
"ServerDNSAllowBrokenConfig", 0, 0},
234 {
"PreferTunnelledDirConns",
"PreferTunneledDirConns", 0, 0},
235 {
"BridgeAuthoritativeDirectory",
"BridgeAuthoritativeDir", 0, 0},
236 {
"HashedControlPassword",
"__HashedControlSessionPassword", 1, 0},
237 {
"VirtualAddrNetwork",
"VirtualAddrNetworkIPv4", 0, 0},
238 {
"SocksSocketsGroupWritable",
"UnixSocksGroupWritable", 0, 1},
239 {
"_HSLayer2Nodes",
"HSLayer2Nodes", 0, 1 },
240 {
"_HSLayer3Nodes",
"HSLayer3Nodes", 0, 1 },
263#define VAR(varname,conftype,member,initvalue) \
264 CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, 0, initvalue)
263#define VAR(varname,conftype,member,initvalue) \ …
267#define VAR_D(varname,conftype,member,initvalue) \
268 CONFIG_VAR_DEFN(or_options_t, varname, conftype, member, 0, initvalue)
270#define VAR_NODUMP(varname,conftype,member,initvalue) \
271 CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, \
272 CFLG_NODUMP, initvalue)
273#define VAR_NODUMP_IMMUTABLE(varname,conftype,member,initvalue) \
274 CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, \
275 CFLG_NODUMP | CFLG_IMMUTABLE, initvalue)
276#define VAR_INVIS(varname,conftype,member,initvalue) \
277 CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, \
278 CFLG_NODUMP | CFLG_NOSET | CFLG_NOLIST, initvalue)
280#define V(member,conftype,initvalue) \
281 VAR(#member, conftype, member, initvalue)
283#define VAR_IMMUTABLE(varname, conftype, member, initvalue) \
284 CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, \
285 CFLG_IMMUTABLE, initvalue)
287#define V_IMMUTABLE(member,conftype,initvalue) \
288 VAR_IMMUTABLE(#member, conftype, member, initvalue)
291#define V_D(member,type,initvalue) \
292 VAR_D(#member, type, member, initvalue)
291#define V_D(member,type,initvalue) \ …
295#define OBSOLETE(varname) CONFIG_VAR_OBSOLETE(varname)
304#define VPORT(member) \
305 VAR(#member "Lines", LINELIST_V, member ## _lines, NULL), \
306 VAR(#member, LINELIST_S, member ## _lines, NULL), \
307 VAR_NODUMP("__" #member, LINELIST_S, member ## _lines, NULL)
304#define VPORT(member) \ …
310#define UINT64_MAX_STRING "18446744073709551615"
317 V(AccountingMax, MEMUNIT,
"0 bytes"),
318 VAR(
"AccountingRule", STRING, AccountingRule_option,
"max"),
319 V(AccountingStart, STRING, NULL),
320 V(Address, LINELIST, NULL),
321 V(AddressDisableIPv6, BOOL,
"0"),
324 V(AllowNonRFC953Hostnames, BOOL,
"0"),
327 V(AlternateBridgeAuthority, LINELIST, NULL),
328 V(AlternateDirAuthority, LINELIST, NULL),
330 V(AssumeReachable, BOOL,
"0"),
331 V(AssumeReachableIPv6, AUTOBOOL,
"auto"),
334 V(AuthDirBadExit, LINELIST, NULL),
335 V(AuthDirBadExitCCs, CSV,
""),
336 V(AuthDirInvalid, LINELIST, NULL),
337 V(AuthDirInvalidCCs, CSV,
""),
338 V(AuthDirMiddleOnly, LINELIST, NULL),
339 V(AuthDirMiddleOnlyCCs, CSV,
""),
340 V(AuthDirReject, LINELIST, NULL),
341 V(AuthDirRejectCCs, CSV,
""),
344 OBSOLETE(
"AuthDirMaxServersPerAuthAddr"),
345 VAR(
"AuthoritativeDirectory", BOOL, AuthoritativeDir,
"0"),
346 V(AutomapHostsOnResolve, BOOL,
"0"),
347 V(AutomapHostsSuffixes, CSV,
".onion,.exit"),
348 V(AvoidDiskWrites, BOOL,
"0"),
349 V(BandwidthBurst, MEMUNIT,
"1 GB"),
350 V(BandwidthRate, MEMUNIT,
"1 GB"),
351 V(BridgeAuthoritativeDir, BOOL,
"0"),
352 VAR(
"Bridge", LINELIST, Bridges, NULL),
353 V(BridgePassword, STRING, NULL),
354 V(BridgeRecordUsageByCountry, BOOL,
"1"),
355 V(BridgeRelay, BOOL,
"0"),
356 V(BridgeDistribution, STRING, NULL),
357 VAR_IMMUTABLE(
"CacheDirectory",FILENAME, CacheDirectory_option, NULL),
358 V(CacheDirectoryGroupReadable, AUTOBOOL,
"auto"),
359 V(CellStatistics, BOOL,
"0"),
360 V(PaddingStatistics, BOOL,
"1"),
361 V(OverloadStatistics, BOOL,
"1"),
362 V(LearnCircuitBuildTimeout, BOOL,
"1"),
363 V(CircuitBuildTimeout, INTERVAL,
"0"),
365 V(CircuitsAvailableTimeout, INTERVAL,
"0"),
366 V(CircuitStreamTimeout, INTERVAL,
"0"),
367 V(CircuitPriorityHalflife, DOUBLE,
"-1.0"),
368 V(ClientDNSRejectInternalAddresses, BOOL,
"1"),
369#if defined(HAVE_MODULE_RELAY) || defined(TOR_UNIT_TESTS)
371 V(ClientOnly, BOOL,
"0"),
374 V(ClientOnly, BOOL,
"1"),
376 V(ClientPreferIPv6ORPort, AUTOBOOL,
"auto"),
377 V(ClientPreferIPv6DirPort, AUTOBOOL,
"auto"),
379 V(ClientRejectInternalAddresses, BOOL,
"1"),
380 V(ClientTransportPlugin, LINELIST, NULL),
381 V(ClientUseIPv6, BOOL,
"1"),
382 V(ClientUseIPv4, BOOL,
"1"),
383 V(CompiledProofOfWorkHash, AUTOBOOL,
"auto"),
384 V(ConfluxEnabled, AUTOBOOL,
"auto"),
385 VAR(
"ConfluxClientUX", STRING, ConfluxClientUX_option,
387 V(ConnLimit, POSINT,
"1000"),
388 V(ConnDirectionStatistics, BOOL,
"0"),
389 V(ConstrainedSockets, BOOL,
"0"),
390 V(ConstrainedSockSize, MEMUNIT,
"8192"),
391 V(ContactInfo, STRING, NULL),
394 V(ControlPortFileGroupReadable,BOOL,
"0"),
395 V(ControlPortWriteToFile, FILENAME, NULL),
396 V(ControlSocket, LINELIST, NULL),
397 V(ControlSocketsGroupWritable, BOOL,
"0"),
398 V(UnixSocksGroupWritable, BOOL,
"0"),
399 V(CookieAuthentication, BOOL,
"0"),
400 V(CookieAuthFileGroupReadable, BOOL,
"0"),
401 V(CookieAuthFile, FILENAME, NULL),
402 V(CountPrivateBandwidth, BOOL,
"0"),
403 VAR_IMMUTABLE(
"DataDirectory", FILENAME, DataDirectory_option, NULL),
404 V(DataDirectoryGroupReadable, BOOL,
"0"),
405 V(DisableOOSCheck, BOOL,
"1"),
406 V(DisableNetwork, BOOL,
"0"),
407 V(DirAllowPrivateAddresses, BOOL,
"0"),
409 V(DirPolicy, LINELIST, NULL),
411 V(DirPortFrontPage, FILENAME, NULL),
412 VAR(
"DirReqStatistics", BOOL, DirReqStatistics_option,
"1"),
413 VAR(
"DirAuthority", LINELIST, DirAuthorities, NULL),
414#if defined(HAVE_MODULE_RELAY) || defined(TOR_UNIT_TESTS)
416 V(DirCache, BOOL,
"1"),
419 V(DirCache, BOOL,
"0"),
428 V(DirAuthorityFallbackRate, DOUBLE,
"0.1"),
429 V_IMMUTABLE(DisableAllSwap, BOOL,
"0"),
430 V_IMMUTABLE(DisableDebuggerAttachment, BOOL,
"1"),
432 OBSOLETE(
"DisableV2DirectoryInfo_"),
436 V(DormantClientTimeout, INTERVAL,
"24 hours"),
437 V(DormantTimeoutEnabled, BOOL,
"1"),
438 V(DormantTimeoutDisabledByIdleStreams, BOOL,
"1"),
439 V(DormantOnFirstStartup, BOOL,
"0"),
440 V(DormantCanceledByStartup, BOOL,
"0"),
441 V(DownloadExtraInfo, BOOL,
"0"),
442 V(TestingEnableConnBwEvent, BOOL,
"0"),
443 V(TestingEnableCellStatsEvent, BOOL,
"0"),
444 OBSOLETE(
"TestingEnableTbEmptyEvent"),
445 V(EnforceDistinctSubnets, BOOL,
"1"),
446 V_D(EntryNodes, ROUTERSET, NULL),
447 V(EntryStatistics, BOOL,
"0"),
448 OBSOLETE(
"TestingEstimatedDescriptorPropagationTime"),
449 V_D(ExcludeNodes, ROUTERSET, NULL),
450 V_D(ExcludeExitNodes, ROUTERSET, NULL),
452 V_D(ExitNodes, ROUTERSET, NULL),
456 V_D(MiddleNodes, ROUTERSET, NULL),
457 V(ExitPolicy, LINELIST, NULL),
458 V(ExitPolicyRejectPrivate, BOOL,
"1"),
459 V(ExitPolicyRejectLocalInterfaces, BOOL,
"0"),
460 V(ExitPortStatistics, BOOL,
"0"),
461 V(ExtendAllowPrivateAddresses, BOOL,
"0"),
462 V(ExitRelay, AUTOBOOL,
"auto"),
464 V(ExtORPortCookieAuthFile, FILENAME, NULL),
465 V(ExtORPortCookieAuthFileGroupReadable, BOOL,
"0"),
466 V(ExtraInfoStatistics, BOOL,
"1"),
467 V(ExtendByEd25519ID, AUTOBOOL,
"auto"),
468 V(FallbackDir, LINELIST, NULL),
470 V(UseDefaultFallbackDirs, BOOL,
"1"),
472 OBSOLETE(
"FallbackNetworkstatusFile"),
473 VAR(
"FamilyId", LINELIST, FamilyId_lines, NULL),
474 VAR_IMMUTABLE(
"FamilyKeyDirectory",
475 FILENAME, FamilyKeyDirectory_option, NULL),
476 V(FascistFirewall, BOOL,
"0"),
477 V(FirewallPorts, CSV,
""),
479 V(FetchDirInfoEarly, BOOL,
"0"),
480 V(FetchDirInfoExtraEarly, BOOL,
"0"),
481 V(FetchServerDescriptors, BOOL,
"1"),
482 V(FetchHidServDescriptors, BOOL,
"1"),
483 V(FetchUselessDescriptors, BOOL,
"0"),
485 V(GeoIPExcludeUnknown, AUTOBOOL,
"auto"),
487 V(GeoIPFile, FILENAME,
"<default>"),
488 V(GeoIPv6File, FILENAME,
"<default>"),
489#elif defined(__ANDROID__)
494 V(GeoIPFile, FILENAME,
"/data/local/tmp/geoip"),
495 V(GeoIPv6File, FILENAME,
"/data/local/tmp/geoip6"),
497 V(GeoIPFile, FILENAME,
498 SHARE_DATADIR PATH_SEPARATOR
"tor" PATH_SEPARATOR
"geoip"),
499 V(GeoIPv6File, FILENAME,
500 SHARE_DATADIR PATH_SEPARATOR
"tor" PATH_SEPARATOR
"geoip6"),
503 V(GuardLifetime, INTERVAL,
"0 minutes"),
504 V(HeartbeatPeriod, INTERVAL,
"6 hours"),
505 V(MainloopStats, BOOL,
"0"),
506 V(HashedControlPassword, LINELIST, NULL),
508 OBSOLETE(
"HiddenServiceAuthorizeClient"),
510 VAR(
"HiddenServiceDir", LINELIST_S, RendConfigLines, NULL),
511 VAR(
"HiddenServiceDirGroupReadable", LINELIST_S, RendConfigLines, NULL),
512 VAR(
"HiddenServiceOptions",LINELIST_V, RendConfigLines, NULL),
513 VAR(
"HiddenServicePort", LINELIST_S, RendConfigLines, NULL),
514 VAR(
"HiddenServiceVersion",LINELIST_S, RendConfigLines, NULL),
515 VAR(
"HiddenServiceAllowUnknownPorts",LINELIST_S, RendConfigLines, NULL),
516 VAR(
"HiddenServiceMaxStreams",LINELIST_S, RendConfigLines, NULL),
517 VAR(
"HiddenServiceMaxStreamsCloseCircuit",LINELIST_S, RendConfigLines, NULL),
518 VAR(
"HiddenServiceNumIntroductionPoints", LINELIST_S, RendConfigLines, NULL),
519 VAR(
"HiddenServiceExportCircuitID", LINELIST_S, RendConfigLines, NULL),
520 VAR(
"HiddenServiceEnableIntroDoSDefense", LINELIST_S, RendConfigLines, NULL),
521 VAR(
"HiddenServiceEnableIntroDoSRatePerSec",
522 LINELIST_S, RendConfigLines, NULL),
523 VAR(
"HiddenServiceEnableIntroDoSBurstPerSec",
524 LINELIST_S, RendConfigLines, NULL),
525 VAR(
"HiddenServiceOnionBalanceInstance",
526 LINELIST_S, RendConfigLines, NULL),
527 VAR(
"HiddenServicePoWDefensesEnabled", LINELIST_S, RendConfigLines, NULL),
528 VAR(
"HiddenServicePoWQueueRate", LINELIST_S, RendConfigLines, NULL),
529 VAR(
"HiddenServicePoWQueueBurst", LINELIST_S, RendConfigLines, NULL),
530 VAR(
"HiddenServiceStatistics", BOOL, HiddenServiceStatistics_option,
"1"),
531 V(ClientOnionAuthDir, FILENAME, NULL),
532 OBSOLETE(
"CloseHSClientCircuitsImmediatelyOnTimeout"),
533 OBSOLETE(
"CloseHSServiceRendCircuitsImmediatelyOnTimeout"),
534 V_IMMUTABLE(HiddenServiceSingleHopMode, BOOL,
"0"),
535 V_IMMUTABLE(HiddenServiceNonAnonymousMode,BOOL,
"0"),
536 V(HTTPProxy, STRING, NULL),
537 V(HTTPProxyAuthenticator, STRING, NULL),
538 V(HTTPSProxy, STRING, NULL),
539 V(HTTPSProxyAuthenticator, STRING, NULL),
540 VPORT(HTTPTunnelPort),
541 V(IPv6Exit, BOOL,
"0"),
542 VAR(
"ServerTransportPlugin", LINELIST, ServerTransportPlugin, NULL),
543 V(ServerTransportListenAddr, LINELIST, NULL),
544 V(ServerTransportOptions, LINELIST, NULL),
545 V(SigningKeyLifetime, INTERVAL,
"30 days"),
546 V(Socks4Proxy, STRING, NULL),
547 V(Socks5Proxy, STRING, NULL),
548 V(Socks5ProxyUsername, STRING, NULL),
549 V(Socks5ProxyPassword, STRING, NULL),
550 V(TCPProxy, STRING, NULL),
551 VAR_IMMUTABLE(
"KeyDirectory", FILENAME, KeyDirectory_option, NULL),
552 V(KeyDirectoryGroupReadable, AUTOBOOL,
"auto"),
553 VAR_D(
"HSLayer2Nodes", ROUTERSET, HSLayer2Nodes, NULL),
554 VAR_D(
"HSLayer3Nodes", ROUTERSET, HSLayer3Nodes, NULL),
555 V(KeepalivePeriod, INTERVAL,
"5 minutes"),
556 V_IMMUTABLE(KeepBindCapabilities, AUTOBOOL,
"auto"),
557 VAR(
"Log", LINELIST, Logs, NULL),
558 V(LogMessageDomains, BOOL,
"0"),
559 V(LogTimeGranularity, MSEC_INTERVAL,
"1 second"),
560 V(TruncateLogFile, BOOL,
"0"),
561 V_IMMUTABLE(SyslogIdentityTag, STRING, NULL),
563 V(LongLivedPorts, CSV,
564 "21,22,706,1863,5050,5190,5222,5223,6523,6667,6697,8300"),
565 VAR(
"MapAddress", LINELIST, AddressMap, NULL),
566 V(MaxAdvertisedBandwidth, MEMUNIT,
"1 GB"),
567 V(MaxCircuitDirtiness, INTERVAL,
"10 minutes"),
568 V(MaxClientCircuitsPending, POSINT,
"32"),
569 V(MaxConsensusAgeForDiffs, INTERVAL,
"0 seconds"),
570 VAR(
"MaxMemInQueues", MEMUNIT, MaxMemInQueues_raw,
"0"),
571 VAR(
"MaxHSDirCacheBytes", MEMUNIT, MaxHSDirCacheBytes,
"0"),
573 V(MaxOnionQueueDelay, MSEC_INTERVAL,
"0"),
574 V(MaxUnparseableDescSizeToLog, MEMUNIT,
"10 MB"),
576 V(MetricsPortPolicy, LINELIST, NULL),
577 V(TestingMinTimeToReportBandwidth, INTERVAL,
"1 day"),
578 VAR(
"MyFamily", LINELIST, MyFamily_lines, NULL),
579 V(NewCircuitPeriod, INTERVAL,
"30 seconds"),
580 OBSOLETE(
"NamingAuthoritativeDirectory"),
583 V(Nickname, STRING, NULL),
584 OBSOLETE(
"PredictedPortsRelevanceTime"),
586 VAR(
"NodeFamily", LINELIST, NodeFamilies, NULL),
587 V_IMMUTABLE(NoExec, BOOL,
"0"),
588 V(NumCPUs, POSINT,
"0"),
589 V(NumDirectoryGuards, POSINT,
"0"),
590 V(NumEntryGuards, POSINT,
"0"),
591 V(NumPrimaryGuards, POSINT,
"0"),
592 V(OfflineMasterKey, BOOL,
"0"),
595 V(OutboundBindAddress, LINELIST, NULL),
596 V(OutboundBindAddressOR, LINELIST, NULL),
597 V(OutboundBindAddressExit, LINELIST, NULL),
598 V(OutboundBindAddressPT, LINELIST, NULL),
601 V(PathBiasCircThreshold, INT,
"-1"),
602 V(PathBiasNoticeRate, DOUBLE,
"-1"),
603 V(PathBiasWarnRate, DOUBLE,
"-1"),
604 V(PathBiasExtremeRate, DOUBLE,
"-1"),
605 V(PathBiasScaleThreshold, INT,
"-1"),
608 V(PathBiasDropGuards, AUTOBOOL,
"0"),
611 V(PathBiasUseThreshold, INT,
"-1"),
612 V(PathBiasNoticeUseRate, DOUBLE,
"-1"),
613 V(PathBiasExtremeUseRate, DOUBLE,
"-1"),
614 V(PathBiasScaleUseThreshold, INT,
"-1"),
616 V(PathsNeededToBuildCircuits, DOUBLE,
"-1"),
617 V(PerConnBWBurst, MEMUNIT,
"0"),
618 V(PerConnBWRate, MEMUNIT,
"0"),
619 V_IMMUTABLE(PidFile, FILENAME, NULL),
620 V_IMMUTABLE(TestingTorNetwork, BOOL,
"0"),
622 V(TestingLinkCertLifetime, INTERVAL,
"2 days"),
623 V(TestingAuthKeyLifetime, INTERVAL,
"2 days"),
624 V(TestingLinkKeySlop, INTERVAL,
"3 hours"),
625 V(TestingAuthKeySlop, INTERVAL,
"3 hours"),
626 V(TestingSigningKeySlop, INTERVAL,
"1 day"),
632 V(ProtocolWarnings, BOOL,
"0"),
633 V(PublishServerDescriptor, CSV,
"1"),
634 V(PublishHidServDescriptors, BOOL,
"1"),
635 V(ReachableAddresses, LINELIST, NULL),
636 V(ReachableDirAddresses, LINELIST, NULL),
637 V(ReachableORAddresses, LINELIST, NULL),
639 V(ReducedConnectionPadding, BOOL,
"0"),
640 V(ConnectionPadding, AUTOBOOL,
"auto"),
641 V(RefuseUnknownExits, AUTOBOOL,
"auto"),
642 V(CircuitPadding, BOOL,
"1"),
643 V(ReconfigDropsBridgeDescs, BOOL,
"0"),
644 V(ReducedCircuitPadding, BOOL,
"0"),
645 V(RejectPlaintextPorts, CSV,
""),
646 V(RelayBandwidthBurst, MEMUNIT,
"0"),
647 V(RelayBandwidthRate, MEMUNIT,
"0"),
648 V(RephistTrackTime, INTERVAL,
"24 hours"),
649 V_IMMUTABLE(RunAsDaemon, BOOL,
"0"),
650 V(ReducedExitPolicy, BOOL,
"0"),
651 V(ReevaluateExitPolicy, BOOL,
"0"),
653 V_IMMUTABLE(Sandbox, BOOL,
"0"),
654 V(SafeLogging, STRING,
"1"),
655 V(SafeSocks, BOOL,
"0"),
656 V(ServerDNSAllowBrokenConfig, BOOL,
"1"),
657 V(ServerDNSAllowNonRFC953Hostnames, BOOL,
"0"),
658 V(ServerDNSDetectHijacking, BOOL,
"1"),
659 V(ServerDNSRandomizeCase, BOOL,
"1"),
660 V(ServerDNSResolvConfFile, FILENAME, NULL),
661 V(ServerDNSSearchDomains, BOOL,
"0"),
662 V(ServerDNSTestAddresses, CSV,
663 "www.google.com,www.mit.edu,www.yahoo.com,www.slashdot.org"),
664 OBSOLETE(
"SchedulerLowWaterMark__"),
665 OBSOLETE(
"SchedulerHighWaterMark__"),
666 OBSOLETE(
"SchedulerMaxFlushCells__"),
667 V(KISTSchedRunInterval, MSEC_INTERVAL,
"0 msec"),
668 V(KISTSockBufSizeFactor, DOUBLE,
"1.0"),
669 V(Schedulers, CSV,
"KIST,KISTLite,Vanilla"),
670 V(ShutdownWaitLength, INTERVAL,
"30 seconds"),
672 V(SocksPolicy, LINELIST, NULL),
674 V(SocksTimeout, INTERVAL,
"2 minutes"),
675 V(SSLKeyLifetime, INTERVAL,
"0"),
678 V(StrictNodes, BOOL,
"0"),
679 OBSOLETE(
"Support022HiddenServices"),
680 V(TestSocks, BOOL,
"0"),
681 V_IMMUTABLE(TokenBucketRefillInterval, MSEC_INTERVAL,
"100 msec"),
683 OBSOLETE(
"Tor2webRendezvousPoints"),
685 V(TrackHostExits, CSV, NULL),
686 V(TrackHostExitsExpire, INTERVAL,
"30 minutes"),
689 V(TransProxyType, STRING,
"default"),
691 V(UpdateBridgesFromAuthority, BOOL,
"0"),
692 V(UseBridges, BOOL,
"0"),
693 VAR(
"UseEntryGuards", BOOL, UseEntryGuards_option,
"1"),
694 OBSOLETE(
"UseEntryGuardsAsDirGuards"),
695 V(UseGuardFraction, AUTOBOOL,
"auto"),
696 V(VanguardsLiteEnabled, AUTOBOOL,
"auto"),
697 V(UseMicrodescriptors, AUTOBOOL,
"auto"),
699 VAR(
"__AlwaysCongestionControl", BOOL, AlwaysCongestionControl,
"0"),
700 VAR(
"__SbwsExit", BOOL, SbwsExit,
"0"),
701 V_IMMUTABLE(User, STRING, NULL),
703 OBSOLETE(
"V1AuthoritativeDirectory"),
704 OBSOLETE(
"V2AuthoritativeDirectory"),
705 VAR(
"V3AuthoritativeDirectory",BOOL, V3AuthoritativeDir,
"0"),
706 V(TestingV3AuthInitialVotingInterval, INTERVAL,
"30 minutes"),
707 V(TestingV3AuthInitialVoteDelay, INTERVAL,
"5 minutes"),
708 V(TestingV3AuthInitialDistDelay, INTERVAL,
"5 minutes"),
709 V(TestingV3AuthVotingStartOffset, INTERVAL,
"0"),
710 V(V3AuthVotingInterval, INTERVAL,
"1 hour"),
711 V(V3AuthVoteDelay, INTERVAL,
"5 minutes"),
712 V(V3AuthDistDelay, INTERVAL,
"5 minutes"),
713 V(V3AuthNIntervalsValid, POSINT,
"3"),
714 V(V3AuthUseLegacyKey, BOOL,
"0"),
715 V(V3BandwidthsFile, FILENAME, NULL),
716 V(GuardfractionFile, FILENAME, NULL),
717 OBSOLETE(
"VoteOnHidServDirectoriesV2"),
718 V(VirtualAddrNetworkIPv4, STRING,
"127.192.0.0/10"),
719 V(VirtualAddrNetworkIPv6, STRING,
"[FE80::]/10"),
720 V(WarnPlaintextPorts, CSV,
"23,109,110,143"),
721 OBSOLETE(
"UseFilteringSSLBufferevents"),
722 OBSOLETE(
"__UseFilteringSSLBufferevents"),
723 VAR_NODUMP(
"__ReloadTorrcOnSIGHUP", BOOL, ReloadTorrcOnSIGHUP,
"1"),
724 VAR_NODUMP(
"__AllDirActionsPrivate", BOOL, AllDirActionsPrivate,
"0"),
725 VAR_NODUMP(
"__DisablePredictedCircuits",BOOL,DisablePredictedCircuits,
"0"),
726 VAR_NODUMP_IMMUTABLE(
"__DisableSignalHandlers", BOOL,
727 DisableSignalHandlers,
"0"),
728 VAR_NODUMP(
"__LeaveStreamsUnattached",BOOL, LeaveStreamsUnattached,
"0"),
729 VAR_NODUMP(
"__HashedControlSessionPassword", LINELIST,
730 HashedControlSessionPassword,
732 VAR_NODUMP(
"__OwningControllerProcess",STRING,
733 OwningControllerProcess, NULL),
734 VAR_NODUMP_IMMUTABLE(
"__OwningControllerFD", UINT64, OwningControllerFD,
736 V(TestingServerDownloadInitialDelay, CSV_INTERVAL,
"0"),
737 V(TestingClientDownloadInitialDelay, CSV_INTERVAL,
"0"),
738 V(TestingServerConsensusDownloadInitialDelay, CSV_INTERVAL,
"0"),
739 V(TestingClientConsensusDownloadInitialDelay, CSV_INTERVAL,
"0"),
755 V(ClientBootstrapConsensusAuthorityDownloadInitialDelay, CSV_INTERVAL,
"6"),
756 V(ClientBootstrapConsensusFallbackDownloadInitialDelay, CSV_INTERVAL,
"0"),
758 V(ClientBootstrapConsensusAuthorityOnlyDownloadInitialDelay, CSV_INTERVAL,
764 V(ClientBootstrapConsensusMaxInProgressTries, POSINT,
"3"),
767 V(TestingBridgeDownloadInitialDelay, CSV_INTERVAL,
"10800"),
772 V(TestingBridgeBootstrapDownloadInitialDelay, CSV_INTERVAL,
"0"),
773 V(TestingClientMaxIntervalWithoutRequest, INTERVAL,
"10 minutes"),
774 V(TestingDirConnectionMaxStall, INTERVAL,
"5 minutes"),
775 OBSOLETE(
"TestingConsensusMaxDownloadTries"),
776 OBSOLETE(
"ClientBootstrapConsensusMaxDownloadTries"),
777 OBSOLETE(
"ClientBootstrapConsensusAuthorityOnlyMaxDownloadTries"),
778 OBSOLETE(
"TestingDescriptorMaxDownloadTries"),
779 OBSOLETE(
"TestingMicrodescMaxDownloadTries"),
780 OBSOLETE(
"TestingCertMaxDownloadTries"),
781 VAR_INVIS(
"___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_,
790#include "auth_dirs.inc"
800#include "fallback_dirs.inc"
812#include "testnet.inc"
823 {
"HTTPProxy",
"It only applies to direct unencrypted HTTP connections "
824 "to your directory server, which your Tor probably wasn't using." },
825 {
"HTTPProxyAuthenticator",
"HTTPProxy is deprecated in favor of HTTPSProxy "
826 "which should be used with HTTPSProxyAuthenticator." },
830 {
"ReachableDirAddresses",
"It has no effect on relays, and has had no "
831 "effect on clients since 0.2.8." },
832 {
"ClientPreferIPv6DirPort",
"It has no effect on relays, and has had no "
833 "effect on clients since 0.2.8." },
837 {
"ClientAutoIPv6ORPort",
"This option is unreliable if a connection isn't "
838 "reliably dual-stack."},
845static char *get_windows_conf_root(
void);
856static int opt_streq(
const char *s1,
const char *s2);
874#define OR_OPTIONS_MAGIC 9090909
885 .deprecations = option_deprecation_notes_,
890 .has_config_suite =
true,
891 .config_suite_offset = offsetof(
or_options_t, subconfigs_),
924 if (PREDICT_UNLIKELY(options_mgr == NULL)) {
933#define CHECK_OPTIONS_MAGIC(opt) STMT_BEGIN \
934 config_check_toplevel_magic(get_options_mgr(), (opt)); \
972 next = &(*next)->next;
999 "Acting on config options left us in a broken state. Dying.");
1011 connection_reapply_exit_policy(changes);
1012 config_free_lines(changes);
1016 or_options_free(old_options);
1032 CHECK_OPTIONS_MAGIC(opts);
1038 rs, routerset_free(rs));
1055 tor_free(options->master_key_fname);
1056 config_free_lines(options->
MyFamily);
1098 config_mgr_free(options_mgr);
1115 if (options->SafeLogging_ == SAFELOG_SCRUB_ALL)
1116 return "[scrubbed]";
1136 if (options->SafeLogging_ != SAFELOG_SCRUB_NONE)
1137 return "[scrubbed]";
1148 if (
get_options()->SafeLogging_ == SAFELOG_SCRUB_ALL)
1149 return "[scrubbed]";
1160 if (
get_options()->SafeLogging_ != SAFELOG_SCRUB_NONE)
1161 return "[scrubbed]";
1226 log_err(
LD_BUG,
"Couldn't parse internal DirAuthority line %s",
1240 log_err(
LD_BUG,
"Couldn't parse internal FallbackDir line %s",
1259 "You cannot set both DirAuthority and Alternate*Authority.");
1273 "You have used DirAuthority or AlternateDirAuthority to "
1274 "specify alternate directory authorities in "
1275 "your configuration. This is potentially dangerous: it can "
1276 "make you look different from all other Tor users, and hurt "
1277 "your anonymity. Even if you've specified the same "
1278 "authorities as Tor uses by default, the defaults could "
1279 "change in the future. Be sure you know what you're doing.");
1293 for (cl = options->
FallbackDir; cl; cl = cl->next)
1307 int need_to_update =
1308 !smartlist_len(router_get_trusted_dir_servers()) ||
1309 !smartlist_len(router_get_fallback_dir_servers()) || !old_options ||
1318 if (!need_to_update)
1348 if (type != NO_DIRINFO)
1361 for (cl = options->
FallbackDir; cl; cl = cl->next)
1375 const char *directory,
1380 cpd_check_t cpd_opts = create ? CPD_CREATE : CPD_CHECK;
1382 cpd_opts |= CPD_GROUP_READ;
1387 "Couldn't %s private data directory \"%s\"",
1388 create ?
"create" :
"access",
1394 if (group_readable) {
1396 if (chmod(directory, 0750)) {
1397 log_warn(
LD_FS,
"Unable to make %s group-readable: %s",
1398 directory, strerror(errno));
1416 cpd_opts |= CPD_GROUP_READ;
1418 log_err(
LD_OR,
"Can't create/check datadirectory %s",
1431static int have_low_ports = -1;
1460 sd_notifyf(0,
"MAINPID=%ld\n", (
long int)getpid());
1468 control_initialize_event_queue();
1482 *msg_out = tor_strdup(
"DisableAllSwap failure. Do you have proper "
1501 if (options->
User) {
1503 unsigned switch_id_flags = 0;
1513 *msg_out = tor_strdup(
"Problem with User value. See logs for details.");
1533 if (subdir_gr != -1) {
1539 if (0 == strcmp(subdir, datadir)) {
1581 key_dir_group_readable,
1595 cache_dir_group_readable,
1638 if (! running_tor) {
1647 *msg_out = tor_strdup(
"Problem with ConnLimit value. "
1648 "See logs for details.");
1661 if (
parse_ports(options, 0, msg_out, &n_ports, NULL)) {
1663 *msg_out = tor_strdup(
"Unexpected problem parsing port config");
1678 *msg_out = tor_strdup(
"Failed to bind one of the listener ports.");
1684 log_notice(
LD_NET,
"DisableNetwork is set. Tor will not make or accept "
1685 "non-control network connections. Shutting down all existing "
1692#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
1694 if (options->TransPort_set &&
1696 if (get_pf_socket() < 0) {
1697 *msg_out = tor_strdup(
"Unable to open /dev/pf for transparent proxy.");
1731 int socks_in_reserve = options->
ConnLimit_ / 20;
1732 if (socks_in_reserve > 64) socks_in_reserve = 64;
1737 "Recomputed OOS thresholds: ConnLimit %d, ConnLimit_ %d, "
1738 "ConnLimit_high_thresh %d, ConnLimit_low_thresh %d",
1768 log_notice(LD_NET,
"Closing partially-constructed %s",
1769 connection_describe(conn));
1770 connection_close_immediate(conn);
1771 connection_mark_for_close(conn);
1817 old_options->SafeLogging_ != options->SafeLogging_;
1826 *msg_out = tor_strdup(
"Failed to init Log options. See logs for details.");
1864 const char *badness = NULL;
1865 int bad_safelog = 0, bad_severity = 0, new_badness = 0;
1866 if (options->SafeLogging_ != SAFELOG_SCRUB_ALL) {
1876 if (bad_safelog && bad_severity)
1877 badness =
"you disabled SafeLogging, and "
1878 "you're logging more than \"notice\"";
1879 else if (bad_safelog)
1880 badness =
"you disabled SafeLogging";
1882 badness =
"you're logging more than \"notice\"";
1884 log_warn(
LD_GENERAL,
"Your log may contain sensitive information - %s. "
1885 "Don't log unless it serves an important reason. "
1886 "Overwrite the log afterwards.", badness);
1948 if (listener_transaction == NULL)
1968 if (log_transaction == NULL)
1996 int bridge_usage = should_record_bridge_info(options);
1997 int routerset_usage =
2006 if (routerset_usage && reason_out) {
2007 *reason_out =
"We've been configured to use (or avoid) nodes in certain "
2008 "countries, and we need GEOIP information to figure out which ones they "
2010 }
else if (bridge_usage && reason_out) {
2011 *reason_out =
"We've been configured to see which countries can access "
2012 "us as a bridge, and we need GEOIP information to tell which countries "
2015 return bridge_usage || routerset_usage;
2019#define YES_IF_CHANGED_BOOL(opt) \
2020 if (!CFG_EQ_BOOL(old_options, new_options, opt)) return 1;
2021#define YES_IF_CHANGED_INT(opt) \
2022 if (!CFG_EQ_INT(old_options, new_options, opt)) return 1;
2023#define YES_IF_CHANGED_STRING(opt) \
2024 if (!CFG_EQ_STRING(old_options, new_options, opt)) return 1;
2025#define YES_IF_CHANGED_LINELIST(opt) \
2026 if (!CFG_EQ_LINELIST(old_options, new_options, opt)) return 1;
2027#define YES_IF_CHANGED_SMARTLIST(opt) \
2028 if (!CFG_EQ_SMARTLIST(old_options, new_options, opt)) return 1;
2029#define YES_IF_CHANGED_ROUTERSET(opt) \
2030 if (!CFG_EQ_ROUTERSET(old_options, new_options, opt)) return 1;
2045 YES_IF_CHANGED_BOOL(UseEntryGuards);
2046 YES_IF_CHANGED_BOOL(UseBridges);
2047 YES_IF_CHANGED_BOOL(ClientUseIPv4);
2048 YES_IF_CHANGED_BOOL(ClientUseIPv6);
2049 YES_IF_CHANGED_BOOL(FascistFirewall);
2050 YES_IF_CHANGED_ROUTERSET(ExcludeNodes);
2051 YES_IF_CHANGED_ROUTERSET(EntryNodes);
2052 YES_IF_CHANGED_SMARTLIST(FirewallPorts);
2053 YES_IF_CHANGED_LINELIST(Bridges);
2054 YES_IF_CHANGED_LINELIST(ReachableORAddresses);
2055 YES_IF_CHANGED_LINELIST(ReachableDirAddresses);
2077 const int transition_affects_guards =
2087 static int disabled_debugger_attach = 0;
2090 static int warned_debugger_attach = 0;
2096 if (warned_debugger_attach && ok == 1) {
2097 log_notice(
LD_CONFIG,
"Disabled attaching debuggers for unprivileged "
2101 disabled_debugger_attach = (ok == 1);
2103 !warned_debugger_attach) {
2104 log_notice(
LD_CONFIG,
"Not disabling debugger attaching for "
2105 "unprivileged users.");
2106 warned_debugger_attach = 1;
2129 if (hs_service_non_anonymous_mode_enabled(options)) {
2130 log_warn(
LD_GENERAL,
"This copy of Tor was compiled or configured to run "
2131 "in a non-anonymous mode. It will provide NO ANONYMITY.");
2137 log_warn(
LD_BUG,
"Failed parsing previously validated outbound "
2138 "bind addresses: %s", msg);
2146 for (cl = options->
Bridges; cl; cl = cl->next) {
2151 "Previously validated Bridge line could not be added!");
2163 "Previously validated hidden services line could not be added!");
2170 log_warn(
LD_BUG,
"Previously validated client authorization for "
2171 "hidden services could not be added!");
2176 if (running_tor && !old_options &&
2178 const unsigned ctrl_flags =
2179 CC_LOCAL_FD_IS_OWNER |
2180 CC_LOCAL_FD_IS_AUTHENTICATED;
2183 log_warn(
LD_CONFIG,
"Could not add local controller connection with "
2193 if (options_act_dirauth_mtbf(options) < 0)
2206 "Previously validated ClientTransportPlugin line "
2207 "could not be added!");
2215 if (options_act_server_transport(old_options) < 0)
2238 if (options_act_relay(old_options) < 0)
2245 log_err(
LD_CONFIG,
"Unable to write PIDFile %s",
2259 log_warn(
LD_BUG,
"Error parsing already-validated policy options.");
2264 log_warn(
LD_CONFIG,
"Error creating control cookie authentication file.");
2272 log_warn(
LD_GENERAL,
"Error loading rendezvous service keys");
2280 if (options_act_relay_accounting(old_options) < 0)
2290 char *http_authenticator;
2292 if (!http_authenticator) {
2294 log_warn(
LD_BUG,
"Unable to allocate HTTP authenticator. Not setting "
2300 http_authenticator, strlen(http_authenticator),
2321 int revise_trackexithosts = 0;
2322 int revise_automap_entries = 0;
2323 int abandon_circuits = 0;
2340 "Changed to using entry guards or bridges, or changed "
2341 "preferred or excluded node lists. "
2342 "Abandoning previous circuits.");
2343 abandon_circuits = 1;
2346 if (transition_affects_guards) {
2348 routerlist_drop_bridge_descriptors();
2350 abandon_circuits = 1;
2354 if (abandon_circuits) {
2357 revise_trackexithosts = 1;
2362 revise_trackexithosts = 1;
2364 if (revise_trackexithosts)
2369 revise_automap_entries = 1;
2373 revise_automap_entries = 1;
2378 revise_automap_entries = 1;
2381 if (revise_automap_entries)
2384 if (options_act_bridge_stats(old_options) < 0)
2390 if (options_act_relay_bandwidth(old_options) < 0)
2407 server_mode(options);
2412 if (!public_server_mode(options)) {
2419 bool print_notice = 0;
2420 if (options_act_relay_stats(old_options, &print_notice) < 0)
2425 options_act_relay_stats_msg();
2427 if (options_act_relay_desc(old_options) < 0)
2430 if (options_act_dirauth(old_options) < 0)
2448 if (options_act_relay_dos(old_options) < 0)
2450 if (options_act_relay_dir(old_options) < 0)
2470static const struct {
2482 { .name=
"--torrc-file",
2485 { .name=
"--allow-missing-torrc" },
2486 { .name=
"--defaults-torrc",
2488 { .name=
"--hash-password",
2492 { .name=
"--dump-config",
2496 { .name=
"--list-fingerprint",
2501 { .name=
"--keygen-family",
2504 { .name=
"--key-expiration",
2509 { .name=
"--newpass" },
2510 { .name=
"--no-passphrase" },
2511 { .name=
"--passphrase-fd",
2513 { .name=
"--verify-config",
2515 { .name=
"--ignore-missing-torrc" },
2520 { .name=
"--version",
2523 { .name=
"--list-modules",
2526 { .name=
"--library-versions",
2533 { .name=
"--list-torrc-options",
2536 { .name=
"--list-deprecated-options",
2538 { .name=
"--nt-service" },
2539 { .name=
"-nt-service" },
2540 { .name=
"--dbg-dump-subsystem-list",
2571 bool is_a_command =
false;
2580 is_a_command =
true;
2601 }
else if (*s ==
'/') {
2608 const int is_last = (i == argc-1);
2611 if (ignore_errors) {
2612 arg = tor_strdup(
"");
2614 log_warn(
LD_CONFIG,
"Command-line option '%s' with no value. Failing.",
2616 parsed_cmdline_free(result);
2621 (is_last || argv[i+1][0] ==
'-')) {
2622 arg = tor_strdup(
"");
2630 param->key = is_cmdline ? tor_strdup(argv[i]) :
2635 log_debug(
LD_CONFIG,
"command line: parsed keyword '%s', value '%s'",
2636 param->key, param->value);
2643 *new_cmdline = param;
2644 new_cmdline = &((*new_cmdline)->next);
2647 new = &((*new)->next);
2650 i += want_arg ? 2 : 1;
2706 list, flags, msg)) < 0) {
2707 or_options_free(trial_options);
2720"Copyright (c) 2001-2004, Roger Dingledine\n"
2721"Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson\n"
2722"Copyright (c) 2007-2021, The Tor Project, Inc.\n\n"
2723"tor -f <torrc> [args]\n"
2724"See man page for options, or https://www.torproject.org/ for "
2741 printf(
"%s\n", var->member.name);
2742 } SMARTLIST_FOREACH_END(var);
2743 smartlist_free(vars);
2754 printf(
"%s\n",
name));
2755 smartlist_free(deps);
2762 static const struct {
2766 {
"relay", have_module_relay() },
2767 {
"dirauth", have_module_dirauth() },
2768 {
"dircache", have_module_dircache() },
2769 {
"pow", have_module_pow() }
2772 for (
unsigned i = 0; i <
sizeof list /
sizeof list[0]; i++) {
2773 printf(
"%s: %s\n", list[i].
name, list[i].have ?
"yes" :
"no");
2782 printf(
"Library versions\tCompiled\t\tRuntime\n");
2783 printf(
"Libevent\t\t%-15s\t\t%s\n",
2786#ifdef ENABLE_OPENSSL
2787 printf(
"OpenSSL \t\t%-15s\t\t%s\n",
2788 crypto_openssl_get_header_version_str(),
2789 crypto_openssl_get_version_str());
2792 printf(
"NSS \t\t%-15s\t\t%s\n",
2793 crypto_nss_get_header_version_str(),
2794 crypto_nss_get_version_str());
2797 printf(
"Zlib \t\t%-15s\t\t%s\n",
2802 printf(
"Liblzma \t\t%-15s\t\t%s\n",
2807 printf(
"Libzstd \t\t%-15s\t\t%s\n",
2812 printf(
"%-7s \t\t%-15s\t\t%s\n",
2828 log_err(
LD_CONFIG,
"--no-passphrase specified without --keygen!");
2839 const char *formats[] = {
"iso8601",
"timestamp" };
2842 if (!strcmp(value, formats[i])) {
2856 log_err(
LD_CONFIG,
"--format specified without --key-expiration!");
2869 log_err(
LD_CONFIG,
"--newpass specified without --keygen!");
2878 if (
get_options()->keygen_force_passphrase == FORCE_PASSPHRASE_OFF) {
2879 log_err(
LD_CONFIG,
"--no-passphrase specified with --passphrase-fd!");
2882 log_err(
LD_CONFIG,
"--passphrase-fd specified without --keygen!");
2887 if (fd < 0 || ok == 0) {
2903 log_err(
LD_CONFIG,
"--master-key without --keygen!");
2914using_default_dir_authorities(
const or_options_t *options)
2938 log_err(
LD_BUG,
"Unable to set default options: %s", msg);
2940 tor_assert_unreached();
2942 config_free_lines(dflts);
2955 switch (how_to_dump) {
2956 case OPTIONS_DUMP_MINIMAL:
2960 case OPTIONS_DUMP_ALL:
2961 use_defaults = NULL;
2965 log_warn(
LD_BUG,
"Bogus value for how_to_dump==%d", how_to_dump);
2987 if (i < 1 || i > 65535) {
3002 if (*value > ROUTER_MAX_DECLARED_BANDWIDTH) {
3007 if (*value > ROUTER_MAX_DECLARED_BANDWIDTH) {
3010 ROUTER_MAX_DECLARED_BANDWIDTH);
3019#define MAX_CIRCS_AVAILABLE_TIME (24*60*60)
3023#define MIN_MAX_CIRCUIT_DIRTINESS 10
3027#define MAX_MAX_CIRCUIT_DIRTINESS (30*24*60*60)
3031#define MIN_CIRCUIT_STREAM_TIMEOUT 10
3038#define RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT (10)
3059 if (vs == VSTAT_TRANSITION_ERR) {
3060 rv = SETOPT_ERR_TRANSITION;
3062 }
else if (vs < 0) {
3063 rv = SETOPT_ERR_PARSE;
3069 rv = SETOPT_ERR_SETTING;
3077 tor_assert(new_options == NULL || rv != SETOPT_OK);
3078 or_options_free(new_options);
3082#ifdef TOR_UNIT_TESTS
3098 return vs < 0 ? -1 : 0;
3102#define REJECT(arg) \
3103 STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END
3104#if defined(__GNUC__) && __GNUC__ <= 3
3105#define COMPLAIN(args...) \
3106 STMT_BEGIN log_warn(LD_CONFIG, args); STMT_END
3108#define COMPLAIN(args, ...) \
3109 STMT_BEGIN log_warn(LD_CONFIG, args, ##__VA_ARGS__); STMT_END
3122 const char *filepath)
3126 COMPLAIN(
"Path for %s (%s) is relative and will resolve to %s."
3127 " Is this what you wanted?", option, filepath, abs_path);
3151 const char *
name = cv->member.name;
3155 config_free_lines(line);
3156 } SMARTLIST_FOREACH_END(cv);
3157 smartlist_free(vars);
3160 hs_line = hs_line->next) {
3161 if (!strcasecmp(hs_line->key,
"HiddenServiceDir"))
3174options_validate_scheduler(
or_options_t *options,
char **msg)
3180 REJECT(
"Empty Schedulers list. Either remove the option so the defaults "
3181 "can be used or set at least one value.");
3191 if (!strcasecmp(
"KISTLite", type)) {
3192 sched_type = tor_malloc_zero(
sizeof(
int));
3193 *sched_type = SCHEDULER_KIST_LITE;
3195 }
else if (!strcasecmp(
"KIST", type)) {
3196 sched_type = tor_malloc_zero(
sizeof(
int));
3197 *sched_type = SCHEDULER_KIST;
3199 }
else if (!strcasecmp(
"Vanilla", type)) {
3200 sched_type = tor_malloc_zero(
sizeof(
int));
3201 *sched_type = SCHEDULER_VANILLA;
3204 tor_asprintf(msg,
"Unknown type %s in option Schedulers. "
3205 "Possible values are KIST, KISTLite and Vanilla.",
3209 } SMARTLIST_FOREACH_END(type);
3212 REJECT(
"KISTSockBufSizeFactor must be at least 0");
3218 tor_asprintf(msg,
"KISTSchedRunInterval must not be more than %d (ms)",
3219 KIST_SCHED_RUN_INTERVAL_MAX);
3231options_validate_single_onion(
or_options_t *options,
char **msg)
3235 !options->HiddenServiceNonAnonymousMode) {
3236 REJECT(
"HiddenServiceSingleHopMode does not provide any server anonymity. "
3237 "It must be used with HiddenServiceNonAnonymousMode set to 1.");
3239 if (options->HiddenServiceNonAnonymousMode &&
3241 REJECT(
"HiddenServiceNonAnonymousMode does not provide any server "
3242 "anonymity. It must be used with HiddenServiceSingleHopMode set to "
3251 const int client_port_set = (options->SocksPort_set ||
3252 options->TransPort_set ||
3253 options->NATDPort_set ||
3254 options->DNSPort_set ||
3255 options->HTTPTunnelPort_set);
3256 if (hs_service_non_anonymous_mode_enabled(options) && client_port_set) {
3257 REJECT(
"HiddenServiceNonAnonymousMode is incompatible with using Tor as "
3258 "an anonymous client. Please set Socks/Trans/NATD/DNSPort to 0, or "
3259 "revert HiddenServiceNonAnonymousMode to 0.");
3262 if (hs_service_allow_non_anonymous_connection(options)
3272 "HiddenServiceSingleHopMode is enabled; disabling "
3288 CHECK_OPTIONS_MAGIC(old_options_);
3289 CHECK_OPTIONS_MAGIC(options_);
3295 int world_writable_control_socket=0;
3301 &world_writable_control_socket) < 0)
3304#ifndef HAVE_SYS_UN_H
3306 *msg = tor_strdup(
"Unix domain sockets (ControlSocket) not supported "
3307 "on this OS/with this build.");
3312 *msg = tor_strdup(
"Setting ControlSocketsGroupWritable without setting "
3313 "a ControlSocket makes no sense.");
3324 if (options_validate_relay_os(old_options, options, msg) < 0)
3332 REJECT(
"Invalid DataDirectory");
3337 REJECT(
"You have specified at least one relative path (see above) "
3338 "with the RunAsDaemon option. RunAsDaemon is not compatible "
3339 "with relative paths.");
3342 if (options_validate_relay_info(old_options, options, msg) < 0)
3350 REJECT(
"Failed to validate Log options. See logs for details.");
3356 "SocksPort, TransPort, NATDPort, DNSPort, and ORPort are all "
3357 "undefined, and there aren't any hidden services configured. "
3358 "Tor will still run, but probably won't do anything.");
3361#ifdef USE_TRANSPARENT
3366#if !defined(OpenBSD) && !defined(DARWIN)
3368 REJECT(
"pf-divert is a OpenBSD-specific "
3369 "and OS X/Darwin-specific feature.");
3374#if !defined(__linux__)
3375 REJECT(
"TPROXY is a Linux-specific feature.");
3380#ifndef KERNEL_MAY_SUPPORT_IPFW
3382 REJECT(
"ipfw is a FreeBSD-specific "
3383 "and OS X/Darwin-specific feature.");
3388 REJECT(
"Unrecognized value for TransProxyType");
3392 !options->TransPort_set) {
3393 REJECT(
"Cannot use TransProxyType without any valid TransPort.");
3397 if (options->TransPort_set)
3398 REJECT(
"TransPort is disabled in this build.");
3403 REJECT(
"TokenBucketRefillInterval must be between 1 and 1000 inclusive.");
3407 REJECT(
"Cannot set AssumeReachable 1 and AssumeReachableIPv6 0.");
3429 COMPLAIN(
"You have asked to exclude certain relays from all positions "
3430 "in your circuits. Expect hidden services and other Tor "
3431 "features to be broken in unpredictable ways.");
3438 REJECT(
"FetchDirInfoExtraEarly requires that you also set "
3439 "FetchDirInfoEarly");
3443 "ConnLimit must be greater than 0, but was set to %d",
3450 log_warn(
LD_CONFIG,
"PathsNeededToBuildCircuits is too low. Increasing "
3454 log_warn(
LD_CONFIG,
"PathsNeededToBuildCircuits is too high. Decreasing "
3463 "MaxClientCircuitsPending must be between 1 and %d, but "
3464 "was set to %d", MAX_MAX_CLIENT_CIRCUITS_PENDING,
3476 "RejectPlaintextPorts", msg) < 0)
3480 "WarnPlaintextPorts", msg) < 0)
3490 new_line->key = tor_strdup(
"ReachableAddresses");
3495 int p = atoi(portno);
3497 smartlist_add_asprintf(instead,
"*:%d", p);
3502 "Converting FascistFirewall and FirewallPorts "
3503 "config options to new format: \"ReachableAddresses %s\"",
3507 smartlist_free(instead);
3513 new_line->key = tor_strdup(
"ReachableDirAddresses");
3514 new_line->value = tor_strdup(
"*:80");
3516 log_notice(
LD_CONFIG,
"Converting FascistFirewall config option "
3517 "to new format: \"ReachableDirAddresses *:80\"");
3521 new_line->key = tor_strdup(
"ReachableORAddresses");
3522 new_line->value = tor_strdup(
"*:443");
3524 log_notice(
LD_CONFIG,
"Converting FascistFirewall config option "
3525 "to new format: \"ReachableORAddresses *:443\"");
3534 server_mode(options))
3535 REJECT(
"Servers must be able to freely connect to the rest "
3536 "of the Internet, so they must not set Reachable*Addresses "
3537 "or FascistFirewall or FirewallPorts or ClientUseIPv4 0.");
3540 server_mode(options))
3541 REJECT(
"Servers must be able to freely connect to the rest "
3542 "of the Internet, so they must not set UseBridges.");
3548 REJECT(
"You cannot set both UseBridges and EntryNodes.");
3553 REJECT(
"Setting UseBridges requires also setting UseEntryGuards.");
3556 compute_real_max_mem_in_queues(options->MaxMemInQueues_raw,
3557 server_mode(options));
3562 options->SafeLogging_ = SAFELOG_SCRUB_NONE;
3563 }
else if (!strcasecmp(options->
SafeLogging,
"relay")) {
3564 options->SafeLogging_ = SAFELOG_SCRUB_RELAY;
3565 }
else if (!strcasecmp(options->
SafeLogging,
"1")) {
3566 options->SafeLogging_ = SAFELOG_SCRUB_ALL;
3569 "Unrecognized value '%s' in SafeLogging",
3574 options->ConfluxClientUX = CONFLUX_UX_HIGH_THROUGHPUT;
3577 options->ConfluxClientUX = CONFLUX_UX_MIN_LATENCY;
3579 options->ConfluxClientUX = CONFLUX_UX_HIGH_THROUGHPUT;
3581 options->ConfluxClientUX = CONFLUX_UX_LOW_MEM_LATENCY;
3583 options->ConfluxClientUX = CONFLUX_UX_LOW_MEM_THROUGHPUT;
3585 REJECT(
"ConfluxClientUX must be 'latency', 'throughput, "
3586 "'latency_lowmem', or 'throughput_lowmem'");
3589 if (options_validate_publish_server(old_options, options, msg) < 0)
3592 if (options_validate_relay_padding(old_options, options, msg) < 0)
3596 if (options_validate_single_onion(options, msg) < 0)
3603 REJECT(
"CircuitsAvailableTimeout is too large. Max is 24 hours.");
3607 REJECT(
"If EntryNodes is set, UseEntryGuards must be enabled.");
3612 !hs_service_allow_non_anonymous_connection(options)) {
3614 "UseEntryGuards is disabled, but you have configured one or more "
3615 "hidden services on this Tor instance. Your hidden services "
3616 "will be very easy to locate using a well-known attack -- see "
3617 "https://freehaven.net/anonbib/#hs-attack06 for details.");
3622 REJECT(
"NumEntryGuards must not be greater than NumPrimaryGuards.");
3630 "You have one single EntryNodes and at least one hidden service "
3631 "configured. This is bad because it's very easy to locate your "
3632 "entry guard which can then lead to the deanonymization of your "
3633 "hidden service -- for more details, see "
3634 "https://bugs.torproject.org/tpo/core/tor/14917. "
3635 "For this reason, the use of one EntryNodes with an hidden "
3636 "service is prohibited until a better solution is found.");
3646 "EntryNodes is set with multiple entries and at least one "
3647 "hidden service is configured. Pinning entry nodes can possibly "
3648 "be harmful to the service anonymity. Because of this, we "
3649 "recommend you either don't do that or make sure you know what "
3650 "you are doing. For more details, please look at "
3651 "https://bugs.torproject.org/tpo/core/tor/21155.");
3655 if (hs_service_non_anonymous_mode_enabled(options)) {
3657 "HiddenServiceNonAnonymousMode is set. Every hidden service on "
3658 "this tor instance is NON-ANONYMOUS. If "
3659 "the HiddenServiceNonAnonymousMode option is changed, Tor will "
3660 "refuse to launch hidden services from the same directories, to "
3661 "protect your anonymity against config errors. This setting is "
3662 "for experimental use only.");
3668 "CircuitBuildTimeout is shorter (%d seconds) than the recommended "
3669 "minimum (%d seconds), and LearnCircuitBuildTimeout is disabled. "
3670 "If tor isn't working, raise this value or enable "
3671 "LearnCircuitBuildTimeout.",
3682 log_fn(severity,
LD_CONFIG,
"You disabled LearnCircuitBuildTimeout, but "
3683 "didn't specify a CircuitBuildTimeout. I'll pick a plausible "
3688 REJECT(
"DormantClientTimeout is too low. It must be at least 10 minutes.");
3691 if (options->PathBiasNoticeRate > 1.0) {
3693 "PathBiasNoticeRate is too high. "
3694 "It must be between 0 and 1.0");
3697 if (options->PathBiasWarnRate > 1.0) {
3699 "PathBiasWarnRate is too high. "
3700 "It must be between 0 and 1.0");
3703 if (options->PathBiasExtremeRate > 1.0) {
3705 "PathBiasExtremeRate is too high. "
3706 "It must be between 0 and 1.0");
3709 if (options->PathBiasNoticeUseRate > 1.0) {
3711 "PathBiasNoticeUseRate is too high. "
3712 "It must be between 0 and 1.0");
3715 if (options->PathBiasExtremeUseRate > 1.0) {
3717 "PathBiasExtremeUseRate is too high. "
3718 "It must be between 0 and 1.0");
3723 log_warn(
LD_CONFIG,
"MaxCircuitDirtiness option is too short; "
3729 log_warn(
LD_CONFIG,
"MaxCircuitDirtiness option is too high; "
3736 log_warn(
LD_CONFIG,
"CircuitStreamTimeout option is too short; "
3744 log_warn(
LD_CONFIG,
"HeartbeatPeriod option is too short; "
3750 REJECT(
"KeepalivePeriod option must be positive.");
3753 "BandwidthRate", msg) < 0)
3756 "BandwidthBurst", msg) < 0)
3759 if (options_validate_relay_bandwidth(old_options, options, msg) < 0)
3763 REJECT(
"BandwidthBurst must be at least equal to BandwidthRate.");
3765 if (options_validate_relay_accounting(old_options, options, msg) < 0)
3774 REJECT(
"HTTPProxy failed to parse or resolve. Please fix.");
3782 REJECT(
"HTTPProxyAuthenticator is too long (>= 512 chars).");
3788 REJECT(
"HTTPSProxy failed to parse or resolve. Please fix.");
3796 REJECT(
"HTTPSProxyAuthenticator is too long (>= 512 chars).");
3803 REJECT(
"Socks4Proxy failed to parse or resolve. Please fix.");
3813 REJECT(
"Socks5Proxy failed to parse or resolve. Please fix.");
3829 REJECT(
"You have configured more than one proxy type. "
3830 "(Socks4Proxy|Socks5Proxy|HTTPSProxy|TCPProxy)");
3837 log_warn(
LD_CONFIG,
"HTTPProxy configured, but no SOCKS proxy, "
3838 "HTTPS proxy, or any other TCP proxy configured. Watch out: "
3839 "this configuration will proxy unencrypted directory "
3840 "connections only.");
3848 REJECT(
"Socks5ProxyUsername must be between 1 and 255 characters.");
3851 REJECT(
"Socks5ProxyPassword must be included with Socks5ProxyUsername.");
3855 REJECT(
"Socks5ProxyPassword must be between 1 and 255 characters.");
3857 REJECT(
"Socks5ProxyPassword must be included with Socks5ProxyUsername.");
3862 REJECT(
"Bad HashedControlPassword: wrong length or bad encoding");
3873 REJECT(
"Bad HashedControlSessionPassword: wrong length or bad encoding");
3881 const char *validate_pspec_msg = NULL;
3883 &validate_pspec_msg)) {
3885 validate_pspec_msg);
3890 if ((options->ControlPort_set || world_writable_control_socket) &&
3894 log_warn(
LD_CONFIG,
"Control%s is %s, but no authentication method "
3895 "has been configured. This means that any program on your "
3896 "computer can reconfigure your Tor. That's bad! You should "
3897 "upgrade your Tor controller as soon as possible.",
3898 options->ControlPort_set ?
"Port" :
"Socket",
3899 options->ControlPort_set ?
"open" :
"world writable");
3903 log_warn(
LD_CONFIG,
"CookieAuthFileGroupReadable is set, but will have "
3904 "no effect: you must specify an explicit CookieAuthFile to "
3905 "have it group-readable.");
3922 log_info(
LD_CONFIG,
"You have set UseDefaultFallbackDirs 1 and "
3923 "FallbackDir(s). Ignoring UseDefaultFallbackDirs, and "
3924 "using the FallbackDir(s) you have set.");
3928 REJECT(
"Directory authority/fallback line did not parse. See logs "
3932 REJECT(
"If you set UseBridges, you must specify at least one bridge.");
3934 for (cl = options->
Bridges; cl; cl = cl->next) {
3937 REJECT(
"Bridge line did not parse. See logs for details.");
3938 bridge_line_free(bridge_line);
3943 REJECT(
"Invalid client transport line. See logs for details.");
3946 if (options_validate_server_transport(old_options, options, msg) < 0)
3956 "ConstrainedSockSize is invalid. Must be a value between %d and %d "
3957 "in 1024 byte increments.",
3958 MIN_CONSTRAINED_TCP_BUFFER, MAX_CONSTRAINED_TCP_BUFFER);
3963 if (options_validate_dirauth_schedule(old_options, options, msg) < 0)
3967 REJECT(
"Failed to configure rendezvous options. See logs for details.");
3971 REJECT(
"Failed to configure client authorization for hidden services. "
3972 "See logs for details.");
3978 AF_INET6, 1, msg)<0)
3985 REJECT(
"TestingTorNetwork may only be configured in combination with "
3986 "a non-default set of DirAuthority or both of "
3987 "AlternateDirAuthority and AlternateBridgeAuthority configured.");
3990#define CHECK_DEFAULT(arg) \
3992 if (!config_is_same(get_options_mgr(),options, \
3993 dflt_options,#arg)) { \
3994 or_options_free(dflt_options); \
3995 REJECT(#arg " may only be changed in testing Tor " \
4006 CHECK_DEFAULT(TestingV3AuthInitialVotingInterval);
4007 CHECK_DEFAULT(TestingV3AuthInitialVoteDelay);
4008 CHECK_DEFAULT(TestingV3AuthInitialDistDelay);
4009 CHECK_DEFAULT(TestingV3AuthVotingStartOffset);
4010 CHECK_DEFAULT(TestingAuthDirTimeToLearnReachability);
4011 CHECK_DEFAULT(TestingServerDownloadInitialDelay);
4012 CHECK_DEFAULT(TestingClientDownloadInitialDelay);
4013 CHECK_DEFAULT(TestingServerConsensusDownloadInitialDelay);
4014 CHECK_DEFAULT(TestingClientConsensusDownloadInitialDelay);
4015 CHECK_DEFAULT(TestingBridgeDownloadInitialDelay);
4016 CHECK_DEFAULT(TestingBridgeBootstrapDownloadInitialDelay);
4017 CHECK_DEFAULT(TestingClientMaxIntervalWithoutRequest);
4018 CHECK_DEFAULT(TestingDirConnectionMaxStall);
4019 CHECK_DEFAULT(TestingAuthKeyLifetime);
4020 CHECK_DEFAULT(TestingLinkCertLifetime);
4021 CHECK_DEFAULT(TestingSigningKeySlop);
4022 CHECK_DEFAULT(TestingAuthKeySlop);
4023 CHECK_DEFAULT(TestingLinkKeySlop);
4024 CHECK_DEFAULT(TestingMinTimeToReportBandwidth);
4025 or_options_free(dflt_options);
4032 REJECT(
"ClientDNSRejectInternalAddresses used for default network.");
4034 if (options_validate_relay_testing(old_options, options, msg) < 0)
4036 if (options_validate_dirauth_testing(old_options, options, msg) < 0)
4040 REJECT(
"TestingClientMaxIntervalWithoutRequest is way too low.");
4042 COMPLAIN(
"TestingClientMaxIntervalWithoutRequest is insanely high.");
4046 REJECT(
"TestingDirConnectionMaxStall is way too low.");
4048 COMPLAIN(
"TestingDirConnectionMaxStall is insanely high.");
4052 REJECT(
"ClientBootstrapConsensusMaxInProgressTries must be greater "
4056 COMPLAIN(
"ClientBootstrapConsensusMaxInProgressTries is insanely "
4062 REJECT(
"TestingEnableConnBwEvent may only be changed in testing "
4068 REJECT(
"TestingEnableCellStatsEvent may only be changed in testing "
4073 log_warn(
LD_CONFIG,
"TestingTorNetwork is set. This will make your node "
4074 "almost unusable in the public Tor network, and is "
4075 "therefore only advised if you are building a "
4076 "testing Tor network!");
4079 if (options_validate_scheduler(options, msg) < 0) {
4093compute_real_max_mem_in_queues(
const uint64_t val,
bool is_server)
4095#define MIN_SERVER_MB 64
4096#define MIN_UNWARNED_SERVER_MB 256
4097#define MIN_UNWARNED_CLIENT_MB 64
4101#define ONE_GIGABYTE (UINT64_C(1) << 30)
4102#define ONE_MEGABYTE (UINT64_C(1) << 20)
4105 static int notice_sent = 0;
4109#if SIZEOF_VOID_P >= 8
4111 result = 8 * ONE_GIGABYTE;
4114 result = ONE_GIGABYTE;
4120#if SIZEOF_SIZE_T > 4
4122#define RAM_IS_VERY_LARGE(x) ((x) >= (8 * ONE_GIGABYTE))
4125#define RAM_IS_VERY_LARGE(x) (0)
4128 if (RAM_IS_VERY_LARGE(ram)) {
4135 avail = (ram / 5) * 2;
4140 avail = (ram / 4) * 3;
4149 }
else if (avail < ONE_GIGABYTE / 4) {
4150 result = ONE_GIGABYTE / 4;
4155 if (is_server && ! notice_sent) {
4156 log_notice(
LD_CONFIG,
"%sMaxMemInQueues is set to %"PRIu64
" MB. "
4157 "You can override this by setting MaxMemInQueues by hand.",
4158 ram ?
"Based on detected system memory, " :
"",
4159 (result / ONE_MEGABYTE));
4163 }
else if (is_server && val < ONE_MEGABYTE * MIN_SERVER_MB) {
4165 log_warn(
LD_CONFIG,
"MaxMemInQueues must be at least %d MB on servers "
4166 "for now. Ideally, have it as large as you can afford.",
4168 return MIN_SERVER_MB * ONE_MEGABYTE;
4169 }
else if (is_server && val < ONE_MEGABYTE * MIN_UNWARNED_SERVER_MB) {
4172 log_warn(
LD_CONFIG,
"MaxMemInQueues is set to a low value; if your "
4173 "relay doesn't work, this may be the reason why.");
4175 }
else if (! is_server && val < ONE_MEGABYTE * MIN_UNWARNED_CLIENT_MB) {
4178 log_warn(
LD_CONFIG,
"MaxMemInQueues is set to a low value; if your "
4179 "client doesn't work, this may be the reason why.");
4198 const void *new_val_,
4201 CHECK_OPTIONS_MAGIC(old_);
4202 CHECK_OPTIONS_MAGIC(new_val_);
4210#define BAD_CHANGE_TO(opt, how) do { \
4211 *msg = tor_strdup("While Tor is running"how", changing " #opt \
4212 " is not allowed"); \
4217#define SB_NOCHANGE_STR(opt) \
4218 if (! CFG_EQ_STRING(old, new_val, opt)) \
4219 BAD_CHANGE_TO(opt," with Sandbox active")
4220#define SB_NOCHANGE_LINELIST(opt) \
4221 if (! CFG_EQ_LINELIST(old, new_val, opt)) \
4222 BAD_CHANGE_TO(opt," with Sandbox active")
4223#define SB_NOCHANGE_INT(opt) \
4224 if (! CFG_EQ_INT(old, new_val, opt)) \
4225 BAD_CHANGE_TO(opt," with Sandbox active")
4227 SB_NOCHANGE_LINELIST(Address);
4228 SB_NOCHANGE_STR(ServerDNSResolvConfFile);
4229 SB_NOCHANGE_STR(DirPortFrontPage);
4230 SB_NOCHANGE_STR(CookieAuthFile);
4231 SB_NOCHANGE_STR(ExtORPortCookieAuthFile);
4232 SB_NOCHANGE_LINELIST(Logs);
4233 SB_NOCHANGE_INT(ConnLimit);
4235 if (server_mode(old) != server_mode(new_val)) {
4236 *msg = tor_strdup(
"Can't start/stop being a server while "
4237 "Sandbox is active");
4242#undef SB_NOCHANGE_LINELIST
4243#undef SB_NOCHANGE_STR
4244#undef SB_NOCHANGE_INT
4246#undef NO_CHANGE_BOOL
4248#undef NO_CHANGE_STRING
4256get_windows_conf_root(
void)
4258 static int is_set = 0;
4259 static char path[MAX_PATH*2+1];
4260 TCHAR tpath[MAX_PATH] = {0};
4272#ifdef ENABLE_LOCAL_APPDATA
4273#define APPDATA_PATH CSIDL_LOCAL_APPDATA
4275#define APPDATA_PATH CSIDL_APPDATA
4277 if (!SUCCEEDED(SHGetSpecialFolderLocation(NULL, APPDATA_PATH, &idl))) {
4278 getcwd(path,MAX_PATH);
4281 "I couldn't find your application data folder: are you "
4282 "running an ancient version of Windows 95? Defaulting to \"%s\"",
4287 result = SHGetPathFromIDList(idl, tpath);
4289 wcstombs(path,tpath,
sizeof(path));
4290 path[
sizeof(path)-1] =
'\0';
4292 strlcpy(path,tpath,
sizeof(path));
4299 m->lpVtbl->Free(m, idl);
4300 m->lpVtbl->Release(m);
4302 if (!SUCCEEDED(result)) {
4305 strlcat(path,
"\\tor",MAX_PATH);
4316#ifdef DISABLE_SYSTEM_TORRC
4317 (void) defaults_file;
4319#elif defined(_WIN32)
4320 if (defaults_file) {
4321 static char defaults_path[MAX_PATH+1];
4322 tor_snprintf(defaults_path, MAX_PATH,
"%s\\torrc-defaults",
4323 get_windows_conf_root());
4324 return defaults_path;
4326 static char path[MAX_PATH+1];
4328 get_windows_conf_root());
4332 return defaults_file ? CONFDIR
"/torrc-defaults" : CONFDIR
"/torrc";
4350 int *using_default_fname,
int *ignore_missing_torrc)
4354 const char *fname_opt = defaults_file ?
"--defaults-torrc" :
"-f";
4355 const char *fname_long_opt = defaults_file ?
"--defaults-torrc" :
4357 const char *ignore_opt = defaults_file ? NULL :
"--ignore-missing-torrc";
4358 const char *keygen_opt =
"--keygen";
4361 *ignore_missing_torrc = 1;
4363 for (p_index = cmd_arg; p_index; p_index = p_index->next) {
4365 if (!strcmp(p_index->key, fname_opt) ||
4366 !strcmp(p_index->key, fname_long_opt)) {
4368 log_warn(
LD_CONFIG,
"Duplicate %s options on command line.",
4381 *using_default_fname = 0;
4382 }
else if ((ignore_opt && !strcmp(p_index->key, ignore_opt)) ||
4383 (keygen_opt && !strcmp(p_index->key, keygen_opt))) {
4384 *ignore_missing_torrc = 1;
4388 if (*using_default_fname) {
4392 if (dflt && (st == FN_FILE || st == FN_EMPTY)) {
4393 fname = tor_strdup(dflt);
4397 if (!defaults_file) {
4402 if (hmst == FN_FILE || hmst == FN_EMPTY || dflt == NULL) {
4406 fname = tor_strdup(dflt);
4409 fname = dflt ? tor_strdup(dflt) : NULL;
4412 fname = dflt ? tor_strdup(dflt) : NULL;
4427 return read_file_to_str_until_eof(STDIN_FILENO,SIZE_MAX,&sz_out);
4442 int using_default_torrc = 1;
4443 int ignore_missing_torrc = 0;
4446 if (*fname_var == NULL) {
4448 &using_default_torrc, &ignore_missing_torrc);
4454 log_debug(
LD_CONFIG,
"Opening config file \"%s\"", fname?fname:
"<NULL>");
4458 if (fname == NULL ||
4459 !(st == FN_FILE || st == FN_EMPTY) ||
4460 !(cf = read_file_to_str(fname,0,NULL))) {
4461 if (using_default_torrc == 1 || ignore_missing_torrc) {
4463 log_notice(
LD_CONFIG,
"Configuration file \"%s\" not present, "
4464 "using reasonable defaults.", fname);
4467 cf = tor_strdup(
"");
4470 "Unable to open configuration file \"%s\".", fname);
4474 log_notice(
LD_CONFIG,
"Read configuration file \"%s\".", fname);
4492 char *cf=NULL, *cf_defaults=NULL;
4531 printf(
"This build of Tor is covered by the GNU General Public License "
4532 "(https://www.gnu.org/licenses/gpl-3.0.en.html)\n");
4534 printf(
"Tor is running on %s with Libevent %s, "
4535 "%s %s, Zlib %s, Liblzma %s, Libzstd %s and %s %s as libc.\n",
4549 printf(
"Tor compiled with %s version %s\n",
4550 strcmp(COMPILER_VENDOR,
"gnu") == 0?
4551 COMPILER:COMPILER_VENDOR, COMPILER_VERSION);
4572 cf_defaults = tor_strdup(
"");
4573 cf = tor_strdup(
"");
4579 if (f_line && f_line_long) {
4580 log_err(
LD_CONFIG,
"-f and --torrc-file cannot be used together.");
4583 }
else if (f_line_long) {
4584 f_line = f_line_long;
4587 const int read_torrc_from_stdin =
4588 (f_line != NULL && strcmp(f_line->value,
"-") == 0);
4590 if (read_torrc_from_stdin) {
4598 cf = tor_strdup(
"");
4626 KEY_EXPIRATION_FORMAT_ISO8601;
4661 return retval < 0 ? -1 : 0;
4675 int command,
const char *command_arg,
4679 or_options_t *oldoptions, *newoptions, *newdefaultoptions=NULL;
4683 int cf_has_include = 0;
4692 newoptions->
command_arg = command_arg ? tor_strdup(command_arg) : NULL;
4695 for (
int i = 0; i < 2; ++i) {
4696 const char *body = i==0 ? cf_defaults : cf;
4701 retval = config_get_lines_include(body, &cl, 1,
4702 body == cf ? &cf_has_include : NULL,
4705 err = SETOPT_ERR_PARSE;
4710 config_free_lines(cl);
4712 err = SETOPT_ERR_PARSE;
4719 if (newdefaultoptions == NULL) {
4734 err = SETOPT_ERR_PARSE;
4740 opened_files = NULL;
4766 smartlist_free(opened_files);
4768 or_options_free(newdefaultoptions);
4769 or_options_free(newoptions);
4771 char *old_msg = *msg;
4772 tor_asprintf(msg,
"Failed to parse/validate config: %s", old_msg);
4802 const char *from, *to, *msg;
4806 for (opt = options->
AddressMap; opt; opt = opt->next) {
4808 SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 2);
4809 if (smartlist_len(elts) < 2) {
4810 log_warn(
LD_CONFIG,
"MapAddress '%s' has too few arguments. Ignoring.",
4815 from = smartlist_get(elts,0);
4816 to = smartlist_get(elts,1);
4818 if (to[0] ==
'.' || from[0] ==
'.') {
4819 log_warn(
LD_CONFIG,
"MapAddress '%s' is ambiguous - address starts with a"
4820 "'.'. Ignoring.",opt->value);
4825 log_warn(
LD_CONFIG,
"MapAddress '%s' failed: %s. Ignoring.", opt->value,
4830 if (smartlist_len(elts) > 2)
4831 log_warn(
LD_CONFIG,
"Ignoring extra arguments to MapAddress.");
4837 smartlist_free(elts);
4849 int from_wildcard = 0, to_wildcard = 0;
4851 *msg =
"whoops, forgot the error message";
4853 if (!strcmp(to,
"*") || !strcmp(from,
"*")) {
4854 *msg =
"can't remap from or to *";
4858 if (!strncmp(from,
"*.",2)) {
4862 if (!strncmp(to,
"*.",2)) {
4867 if (to_wildcard && !from_wildcard) {
4868 *msg =
"can only use wildcard (i.e. '*.') if 'from' address "
4869 "uses wildcard also";
4874 *msg =
"destination is invalid";
4879 from_wildcard, to_wildcard, 0);
4889 const char *filename,
int truncate_log)
4891 int open_flags = O_WRONLY|O_CREAT;
4892 open_flags |= truncate_log ? O_TRUNC : O_APPEND;
4894 int fd = tor_open_cloexec(filename, open_flags, 0640);
4911 log_warn(
LD_CONFIG,
"Log time granularity '%d' has to be positive.",
4917 if (granularity < 40) {
4919 while (1000 % granularity != 0);
4920 }
else if (granularity < 1000) {
4921 granularity = 1000 / granularity;
4922 while (1000 % granularity != 0)
4924 granularity = 1000 / granularity;
4926 granularity = 1000 * ((granularity / 1000) + 1);
4928 log_warn(
LD_CONFIG,
"Log time granularity '%d' has to be either a "
4929 "divisor or a multiple of 1 second. Changing to "
4965 if (options->
Logs == NULL && !run_as_daemon && !validate_only) {
4971 for (opt = options->
Logs; opt; opt = opt->next) {
4973 const char *cfg = opt->value;
4976 log_warn(
LD_CONFIG,
"Couldn't parse log levels in Log option 'Log %s'",
4978 ok = 0;
goto cleanup;
4982 SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 2);
4984 if (smartlist_len(elts) == 0)
4987 if (smartlist_len(elts) == 1 &&
4988 (!strcasecmp(smartlist_get(elts,0),
"stdout") ||
4989 !strcasecmp(smartlist_get(elts,0),
"stderr"))) {
4990 int err = smartlist_len(elts) &&
4991 !strcasecmp(smartlist_get(elts,0),
"stderr");
4992 if (!validate_only) {
4993 if (run_as_daemon) {
4995 "Can't log to %s with RunAsDaemon set; skipping stdout",
4996 err?
"stderr":
"stdout");
4999 fileno(err?stderr:stdout));
5004 if (smartlist_len(elts) == 1) {
5005 if (!strcasecmp(smartlist_get(elts,0),
"syslog")) {
5007 if (!validate_only) {
5011 log_warn(
LD_CONFIG,
"Syslog is not supported on this system. Sorry.");
5018 if (!strcasecmp(smartlist_get(elts, 0),
"android")) {
5020 log_warn(
LD_CONFIG,
"The android logging API is no longer supported;"
5021 " adding a syslog instead. The 'android' logging "
5022 " type will no longer work in the future.");
5023 if (!validate_only) {
5027 log_warn(
LD_CONFIG,
"The android logging API is no longer supported.");
5033 if (smartlist_len(elts) == 2 &&
5034 !strcasecmp(smartlist_get(elts,0),
"file")) {
5035 if (!validate_only) {
5039 int truncate_log = 0;
5044 for (opt2 = old_options->
Logs; opt2; opt2 = opt2->next)
5045 if (!strcmp(opt->value, opt2->value)) {
5052 log_warn(
LD_CONFIG,
"Couldn't open file for 'Log %s': %s",
5053 opt->value, strerror(errno));
5061 log_warn(
LD_CONFIG,
"Bad syntax on file Log option 'Log %s'",
5063 ok = 0;
goto cleanup;
5070 smartlist_free(elts);
5072 if (ok && !validate_only)
5084 char *socks_string = NULL;
5085 size_t socks_string_len;
5092 log_warn(
LD_CONFIG,
"'%s' is not a k=v item.", s);
5095 } SMARTLIST_FOREACH_END(s);
5101 socks_string_len = strlen(socks_string);
5105 log_warn(
LD_CONFIG,
"SOCKS arguments can't be more than %u bytes (%lu).",
5107 (
unsigned long) socks_string_len);
5121 if (bridge_line->socks_args) {
5123 smartlist_free(bridge_line->socks_args);
5125 tor_free(bridge_line->transport_name);
5145 char *addrport=NULL, *fingerprint=NULL;
5151 SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
5152 if (smartlist_len(items) < 1) {
5153 log_warn(
LD_CONFIG,
"Too few arguments to Bridge line.");
5158 field = smartlist_get(items, 0);
5163 bridge_line->transport_name = field;
5164 if (smartlist_len(items) < 1) {
5165 log_warn(
LD_CONFIG,
"Too few items to Bridge line.");
5168 addrport = smartlist_get(items, 0);
5175 &bridge_line->addr, &bridge_line->port, 443)<0) {
5176 log_warn(
LD_CONFIG,
"Error parsing Bridge address '%s'", addrport);
5183 if (smartlist_len(items)) {
5184 if (bridge_line->transport_name) {
5185 field = smartlist_get(items, 0);
5194 fingerprint = field;
5205 log_warn(
LD_CONFIG,
"Key digest for Bridge is wrong length.");
5210 log_warn(
LD_CONFIG,
"Unable to decode Bridge key digest.");
5217 if (bridge_line->transport_name && smartlist_len(items)) {
5218 if (!bridge_line->socks_args)
5225 tor_assert(smartlist_len(bridge_line->socks_args) > 0);
5228 if (bridge_line->socks_args) {
5236 bridge_line_free(bridge_line);
5241 smartlist_free(items);
5268 SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 2);
5271 if (smartlist_len(sl) < 2) {
5272 *msg = tor_strdup(
"TCPProxy has no address/port. Please fix.");
5276 char *protocol_string = smartlist_get(sl, 0);
5277 char *addrport_string = smartlist_get(sl, 1);
5280 if (strcasecmp(protocol_string,
"haproxy")) {
5281 *msg = tor_strdup(
"TCPProxy protocol is not supported. Currently "
5282 "the only supported protocol is 'haproxy'. "
5293 *msg = tor_strdup(
"TCPProxy address/port failed to parse or resolve. "
5322 const char *line,
int validate_only,
5328 const char *transports = NULL;
5331 char *addrport = NULL;
5334 int socks_ver = PROXY_NONE;
5338 char **proxy_argv = NULL;
5341 int is_useless_proxy = 1;
5348 SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
5349 line_length = smartlist_len(items);
5351 if (line_length < 3) {
5353 "Too few arguments on %sTransportPlugin line.",
5354 server ?
"Server" :
"Client");
5361 transports = smartlist_get(items, 0);
5364 SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
5368 log_warn(
LD_CONFIG,
"Transport name is not a C identifier (%s).",
5375 is_useless_proxy = 0;
5376 } SMARTLIST_FOREACH_END(transport_name);
5378 type = smartlist_get(items, 1);
5379 if (!strcmp(type,
"exec")) {
5381 }
else if (server && !strcmp(type,
"proxy")) {
5384 }
else if (!server && !strcmp(type,
"socks4")) {
5387 socks_ver = PROXY_SOCKS4;
5388 }
else if (!server && !strcmp(type,
"socks5")) {
5391 socks_ver = PROXY_SOCKS5;
5394 "Strange %sTransportPlugin type '%s'",
5395 server ?
"Server" :
"Client", type);
5399 if (is_managed && options->
Sandbox) {
5401 "Managed proxies are not compatible with Sandbox mode."
5402 "(%sTransportPlugin line was %s)",
5403 server ?
"Server" :
"Client",
escaped(line));
5407 if (is_managed && options->
NoExec) {
5409 "Managed proxies are not compatible with NoExec mode; ignoring."
5410 "(%sTransportPlugin line was %s)",
5411 server ?
"Server" :
"Client",
escaped(line));
5419 if (!server && !validate_only && is_useless_proxy) {
5421 "Pluggable transport proxy (%s) does not provide "
5422 "any needed transports and will not be launched.",
5432 if (!validate_only && (server || !is_useless_proxy)) {
5433 proxy_argc = line_length - 2;
5435 proxy_argv = tor_calloc((proxy_argc + 1),
sizeof(
char *));
5438 for (i = 0; i < proxy_argc; i++) {
5440 *tmp++ = smartlist_get(items, 2);
5458 log_warn(
LD_CONFIG,
"You have configured an external proxy with another "
5459 "proxy type. (Socks4Proxy|Socks5Proxy|HTTPSProxy|"
5466 "You can't have an external proxy with more than "
5471 addrport = smartlist_get(items, 2);
5475 "Error parsing transport address '%s'", addrport);
5481 "Transport address '%s' has no port.", addrport);
5485 if (!validate_only) {
5486 log_info(
LD_DIR,
"%s '%s' at %s.",
5487 server ?
"Server transport" :
"Transport",
5506 smartlist_free(items);
5548 const char *eq = strchr(flag,
'=');
5550 const char *target = eq + 1;
5554 log_warn(
LD_CONFIG,
"Unsupported URL scheme in authority flag %s", flag);
5557 const char *addr = target + strlen(
"http://");
5559 const char *eos = strchr(addr,
'/');
5561 if (eos && strcmp(eos,
"/")) {
5562 log_warn(
LD_CONFIG,
"Unsupported URL prefix in authority flag %s", flag);
5565 addr_len = eos - addr;
5567 addr_len = strlen(addr);
5571 char *addr_string = tor_strndup(addr, addr_len);
5573 memset(&dirport, 0,
sizeof(dirport));
5575 &dirport.addr, &dirport.port, -1);
5576 if (ds != NULL && rv == 0) {
5578 }
else if (rv == -1) {
5579 log_warn(
LD_CONFIG,
"Unable to parse address in authority flag %s",flag);
5599 char *addrport=NULL, *address=NULL, *nickname=NULL, *fingerprint=NULL;
5601 uint16_t dir_port = 0, or_port = 0;
5605 double weight = 1.0;
5608 memset(v3_digest, 0,
sizeof(v3_digest));
5612 SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
5613 if (smartlist_len(items) < 1) {
5614 log_warn(
LD_CONFIG,
"No arguments on DirAuthority line.");
5619 nickname = smartlist_get(items, 0);
5623 while (smartlist_len(items)) {
5624 char *flag = smartlist_get(items, 0);
5625 if (TOR_ISDIGIT(flag[0]))
5627 if (!strcasecmp(flag,
"hs") ||
5628 !strcasecmp(flag,
"no-hs")) {
5629 log_warn(
LD_CONFIG,
"The DirAuthority options 'hs' and 'no-hs' are "
5630 "obsolete; you don't need them any more.");
5631 }
else if (!strcasecmp(flag,
"bridge")) {
5633 }
else if (!strcasecmp(flag,
"no-v2")) {
5638 char *portstring = flag + strlen(
"orport=");
5639 or_port = (uint16_t)
tor_parse_long(portstring, 10, 1, 65535, &ok, NULL);
5641 log_warn(
LD_CONFIG,
"Invalid orport '%s' on DirAuthority line.",
5645 const char *wstring = flag + strlen(
"weight=");
5648 log_warn(
LD_CONFIG,
"Invalid weight '%s' on DirAuthority line.",flag);
5652 char *idstr = flag + strlen(
"v3ident=");
5656 log_warn(
LD_CONFIG,
"Bad v3 identity digest '%s' on DirAuthority line",
5662 if (ipv6_addrport_ptr) {
5663 log_warn(
LD_CONFIG,
"Redundant ipv6 addr/port on DirAuthority line");
5666 &ipv6_addrport.addr, &ipv6_addrport.port,
5669 log_warn(
LD_CONFIG,
"Bad ipv6 addr/port %s on DirAuthority line",
5673 ipv6_addrport_ptr = &ipv6_addrport;
5682 log_warn(
LD_CONFIG,
"Unrecognized flag '%s' on DirAuthority line",
5689 if (smartlist_len(items) < 2) {
5690 log_warn(
LD_CONFIG,
"Too few arguments to DirAuthority line.");
5693 addrport = smartlist_get(items, 0);
5697 log_warn(
LD_CONFIG,
"Error parsing DirAuthority address '%s'.", addrport);
5702 log_warn(
LD_CONFIG,
"Error parsing DirAuthority address '%s' "
5703 "(invalid IPv4 address)", address);
5708 log_warn(
LD_CONFIG,
"Missing port in DirAuthority address '%s'",addrport);
5714 log_warn(
LD_CONFIG,
"Key digest '%s' for DirAuthority is wrong length %d.",
5715 fingerprint, (
int)strlen(fingerprint));
5720 log_warn(
LD_CONFIG,
"Unable to decode DirAuthority key digest.");
5724 if (validate_only) {
5728 } SMARTLIST_FOREACH_END(cp);
5731 if (!validate_only && (!required_type || required_type & type)) {
5734 type &= required_type;
5736 log_debug(
LD_DIR,
"Trusted %d dirserver at %s:%d (%s)", (
int)type,
5737 address, (
int)dir_port, (
char*)smartlist_get(items,0));
5740 digest, v3_digest, type, weight)))
5746 } SMARTLIST_FOREACH_END(cp);
5758 smartlist_free(extra_dirports);
5760 smartlist_free(items);
5787 memset(
id, 0,
sizeof(
id));
5789 SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
5791 const char *eq = strchr(cp,
'=');
5799 1, 65535, &ok, NULL);
5804 if (ipv6_addrport_ptr) {
5805 log_warn(
LD_CONFIG,
"Redundant ipv6 addr/port on FallbackDir line");
5808 &ipv6_addrport.addr, &ipv6_addrport.port,
5811 log_warn(
LD_CONFIG,
"Bad ipv6 addr/port %s on FallbackDir line",
5815 ipv6_addrport_ptr = &ipv6_addrport;
5819 const char *wstring = cp + strlen(
"weight=");
5822 log_warn(
LD_CONFIG,
"Invalid weight '%s' on FallbackDir line.", cp);
5831 } SMARTLIST_FOREACH_END(cp);
5833 if (smartlist_len(positional) != 1) {
5839 log_warn(
LD_CONFIG,
"Missing identity on FallbackDir line");
5844 log_warn(
LD_CONFIG,
"Missing orport on FallbackDir line");
5849 &address, &dirport) < 0 ||
5851 log_warn(
LD_CONFIG,
"Couldn't parse address:port %s on FallbackDir line",
5852 (
const char*)smartlist_get(positional, 0));
5856 if (!validate_only) {
5871 smartlist_free(items);
5872 smartlist_free(positional);
5913 const char *portname,
5914 const int listener_type)
5917 if (port->type != listener_type)
5919 if (port->is_unix_addr) {
5921 }
else if (!tor_addr_is_internal(&port->addr, 1)) {
5922 log_warn(
LD_CONFIG,
"You specified a public address '%s' for %sPort. "
5923 "Other people on the Internet might find your computer and "
5924 "use it as an open proxy. Please don't allow this unless you "
5925 "have a good reason.",
5928 log_notice(
LD_CONFIG,
"You configured a non-loopback address '%s' "
5929 "for %sPort. This allows everybody on your local network to "
5930 "use your machine as a proxy. Make sure this is what you "
5934 } SMARTLIST_FOREACH_END(port);
5948 if (port->is_unix_addr)
5951 if (forbid_nonlocal) {
5954 "You have a ControlPort set to accept "
5955 "unauthenticated connections from a non-local address. "
5956 "This means that programs not running on your computer "
5957 "can reconfigure your Tor, without even having to guess a "
5958 "password. That's so bad that I'm closing your ControlPort "
5959 "for you. If you need to control your Tor remotely, try "
5960 "enabling authentication and using a tool like stunnel or "
5961 "ssh to encrypt remote access.");
5963 port_cfg_free(port);
5966 log_warn(
LD_CONFIG,
"You have a ControlPort set to accept "
5967 "connections from a non-local address. This means that "
5968 "programs not running on your computer can reconfigure your "
5969 "Tor. That's pretty bad, since the controller "
5970 "protocol isn't encrypted! Maybe you should just listen on "
5971 "127.0.0.1 and use a tool like stunnel or ssh to encrypt "
5972 "remote connections to your control port.");
5976 } SMARTLIST_FOREACH_END(port);
5991 char **addrport_out,
5993 const char **rest_out)
6006 *addrport_out = NULL;
6007 line += strlen(unix_socket_prefix);
6009 if (!*rest_out || (*addrport_out && sz != strlen(*addrport_out))) {
6018 line += strlen(unix_socket_prefix);
6026 end = strchr(line,
'\0');
6029 *addrport_out = tor_strndup(line, end - line);
6036warn_client_dns_cache(
const char *option,
int disabling)
6042 "Client-side DNS caching enables a wide variety of route-"
6043 "capture attacks. If a single bad exit node lies to you about "
6044 "an IP address, caching that address would make you visit "
6045 "an address of the attacker's choice every time you connected "
6046 "to your destination.");
6082 const char *portname,
6084 const char *defaultaddr,
6086 const unsigned flags)
6092 const unsigned allow_no_stream_options = flags & CL_PORT_NO_STREAM_OPTIONS;
6093 const unsigned use_server_options = flags & CL_PORT_SERVER_OPTIONS;
6094 const unsigned warn_nonlocal = flags & CL_PORT_WARN_NONLOCAL;
6095 const unsigned forbid_nonlocal = flags & CL_PORT_FORBID_NONLOCAL;
6096 const unsigned default_to_group_writable =
6097 flags & CL_PORT_DFLT_GROUP_WRITABLE;
6098 const unsigned takes_hostnames = flags & CL_PORT_TAKES_HOSTNAMES;
6099 const unsigned is_unix_socket = flags & CL_PORT_IS_UNIXSOCKET;
6100 int got_zero_port=0, got_nonzero_port=0;
6101 char *unix_socket_path = NULL;
6103 bool addr_is_explicit =
false;
6114 if (defaultport && defaultaddr && out) {
6115 cfg =
port_cfg_new(is_unix_socket ? strlen(defaultaddr) : 0);
6116 cfg->
type = listener_type;
6117 if (is_unix_socket) {
6119 memcpy(cfg->
unix_addr, defaultaddr, strlen(defaultaddr) + 1);
6122 cfg->
port = defaultport;
6133 char *addrport = NULL;
6135 for (; ports; ports = ports->next) {
6139 has_used_unix_socket_only_option = 0,
6140 is_unix_tagged_addr = 0;
6142 const char *rest_of_line = NULL;
6145 &addrport, &is_unix_tagged_addr, &rest_of_line)<0) {
6146 log_warn(
LD_CONFIG,
"Invalid %sPort line with unparsable address",
6150 if (strlen(addrport) == 0) {
6151 log_warn(
LD_CONFIG,
"Invalid %sPort line with no address", portname);
6157 SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
6160 if (is_unix_tagged_addr) {
6161#ifndef HAVE_SYS_UN_H
6162 log_warn(
LD_CONFIG,
"Unix sockets not supported on this system.");
6165 unix_socket_path = addrport;
6169 if (unix_socket_path &&
6171 log_warn(
LD_CONFIG,
"%sPort does not support unix sockets", portname);
6175 if (unix_socket_path) {
6177 }
else if (is_unix_socket) {
6180 unix_socket_path = tor_strdup(addrport);
6181 if (!strcmp(addrport,
"0"))
6185 }
else if (!strcasecmp(addrport,
"auto")) {
6189 char *addrtmp = tor_strndup(addrport, strlen(addrport)-5);
6192 log_warn(
LD_CONFIG,
"Invalid address '%s' for %sPort",
6204 addr_is_explicit =
false;
6207 log_warn(
LD_CONFIG,
"%sPort line has address but no port", portname);
6211 addr_is_explicit =
true;
6213 log_warn(
LD_CONFIG,
"Couldn't parse address %s for %sPort",
6220 cfg =
port_cfg_new(unix_socket_path ? strlen(unix_socket_path) : 0);
6222 cfg->explicit_addr = addr_is_explicit;
6223 if (unix_socket_path && default_to_group_writable)
6224 cfg->is_group_writable = 1;
6227 if (use_server_options) {
6230 if (!strcasecmp(elt,
"NoAdvertise")) {
6231 cfg->server_cfg.no_advertise = 1;
6232 }
else if (!strcasecmp(elt,
"NoListen")) {
6233 cfg->server_cfg.no_listen = 1;
6236 }
else if (!strcasecmp(elt,
"AllAddrs")) {
6240 }
else if (!strcasecmp(elt,
"IPv4Only")) {
6241 cfg->server_cfg.bind_ipv4_only = 1;
6242 }
else if (!strcasecmp(elt,
"IPv6Only")) {
6243 cfg->server_cfg.bind_ipv6_only = 1;
6245 log_warn(
LD_CONFIG,
"Unrecognized %sPort option '%s'",
6248 } SMARTLIST_FOREACH_END(elt);
6250 if (cfg->server_cfg.no_advertise && cfg->server_cfg.no_listen) {
6251 log_warn(
LD_CONFIG,
"Tried to set both NoListen and NoAdvertise "
6252 "on %sPort line '%s'",
6253 portname,
escaped(ports->value));
6256 if (cfg->server_cfg.bind_ipv4_only &&
6257 cfg->server_cfg.bind_ipv6_only) {
6258 log_warn(
LD_CONFIG,
"Tried to set both IPv4Only and IPv6Only "
6259 "on %sPort line '%s'",
6260 portname,
escaped(ports->value));
6263 if (cfg->server_cfg.bind_ipv4_only &&
6265 if (cfg->explicit_addr) {
6266 log_warn(
LD_CONFIG,
"Could not interpret %sPort address as IPv4",
6274 if (cfg->server_cfg.bind_ipv6_only &&
6276 if (cfg->explicit_addr) {
6277 log_warn(
LD_CONFIG,
"Could not interpret %sPort address as IPv6",
6288 int no = 0, isoflag = 0;
6289 const char *elt_orig = elt;
6293 10, 0, INT_MAX, &ok, NULL);
6294 if (!ok || allow_no_stream_options) {
6295 log_warn(
LD_CONFIG,
"Invalid %sPort option '%s'",
6300 log_warn(
LD_CONFIG,
"Multiple SessionGroup options on %sPort",
6313 if (!strcasecmp(elt,
"GroupWritable")) {
6314 cfg->is_group_writable = !no;
6315 has_used_unix_socket_only_option = 1;
6317 }
else if (!strcasecmp(elt,
"WorldWritable")) {
6318 cfg->is_world_writable = !no;
6319 has_used_unix_socket_only_option = 1;
6321 }
else if (!strcasecmp(elt,
"RelaxDirModeCheck")) {
6322 cfg->relax_dirmode_check = !no;
6323 has_used_unix_socket_only_option = 1;
6327 if (allow_no_stream_options) {
6328 log_warn(
LD_CONFIG,
"Unrecognized %sPort option '%s'",
6333 if (takes_hostnames) {
6334 if (!strcasecmp(elt,
"IPv4Traffic")) {
6337 }
else if (!strcasecmp(elt,
"IPv6Traffic")) {
6340 }
else if (!strcasecmp(elt,
"PreferIPv6")) {
6343 }
else if (!strcasecmp(elt,
"DNSRequest")) {
6346 }
else if (!strcasecmp(elt,
"OnionTraffic")) {
6349 }
else if (!strcasecmp(elt,
"OnionTrafficOnly")) {
6354 log_warn(
LD_CONFIG,
"Unsupported %sPort option 'No%s'. Use "
6355 "DNSRequest, IPv4Traffic, and/or IPv6Traffic instead.",
6365 if (!strcasecmp(elt,
"CacheIPv4DNS")) {
6366 warn_client_dns_cache(elt, no);
6369 }
else if (!strcasecmp(elt,
"CacheIPv6DNS")) {
6370 warn_client_dns_cache(elt, no);
6371 cfg->
entry_cfg.cache_ipv6_answers = ! no;
6373 }
else if (!strcasecmp(elt,
"CacheDNS")) {
6374 warn_client_dns_cache(elt, no);
6376 cfg->
entry_cfg.cache_ipv6_answers = ! no;
6378 }
else if (!strcasecmp(elt,
"UseIPv4Cache")) {
6379 warn_client_dns_cache(elt, no);
6382 }
else if (!strcasecmp(elt,
"UseIPv6Cache")) {
6383 warn_client_dns_cache(elt, no);
6384 cfg->
entry_cfg.use_cached_ipv6_answers = ! no;
6386 }
else if (!strcasecmp(elt,
"UseDNSCache")) {
6387 warn_client_dns_cache(elt, no);
6389 cfg->
entry_cfg.use_cached_ipv6_answers = ! no;
6391 }
else if (!strcasecmp(elt,
"PreferIPv6Automap")) {
6394 }
else if (!strcasecmp(elt,
"PreferSOCKSNoAuth")) {
6397 }
else if (!strcasecmp(elt,
"KeepAliveIsolateSOCKSAuth")) {
6400 }
else if (!strcasecmp(elt,
"ExtendedErrors")) {
6406 elt[strlen(elt)-1] =
'\0';
6408 if (!strcasecmp(elt,
"IsolateDestPort")) {
6410 }
else if (!strcasecmp(elt,
"IsolateDestAddr")) {
6412 }
else if (!strcasecmp(elt,
"IsolateSOCKSAuth")) {
6414 }
else if (!strcasecmp(elt,
"IsolateClientProtocol")) {
6416 }
else if (!strcasecmp(elt,
"IsolateClientAddr")) {
6419 log_warn(
LD_CONFIG,
"Unrecognized %sPort option '%s'",
6428 } SMARTLIST_FOREACH_END(elt);
6432 got_nonzero_port = 1;
6438 log_warn(
LD_CONFIG,
"You have a %sPort entry with DNS disabled; that "
6439 "won't work.", portname);
6446 log_warn(
LD_CONFIG,
"You have a %sPort entry with all of IPv4 and "
6447 "IPv6 and .onion disabled; that won't work.", portname);
6454 log_warn(
LD_CONFIG,
"You have a %sPort entry with DNSRequest enabled, "
6455 "but IPv4 and IPv6 disabled; DNS-based sites won't work.",
6459 if (has_used_unix_socket_only_option && !unix_socket_path) {
6460 log_warn(
LD_CONFIG,
"You have a %sPort entry with GroupWritable, "
6461 "WorldWritable, or RelaxDirModeCheck, but it is not a "
6462 "unix socket.", portname);
6467 log_warn(
LD_CONFIG,
"You have a %sPort entry with both "
6468 "NoIsolateSOCKSAuth and KeepAliveIsolateSOCKSAuth set.",
6472 if (unix_socket_path &&
6480 size_t namelen = unix_socket_path ? strlen(unix_socket_path) : 0;
6481 if (unix_socket_path) {
6483 memcpy(cfg->
unix_addr, unix_socket_path, namelen + 1);
6490 cfg->
type = listener_type;
6506 if (warn_nonlocal && out) {
6509 else if (is_ext_orport)
6510 port_warn_nonlocal_ext_orports(out, portname);
6515 if (got_zero_port && got_nonzero_port) {
6516 log_warn(
LD_CONFIG,
"You specified a nonzero %sPort along with '%sPort 0' "
6517 "in the same configuration. Did you mean to disable %sPort or "
6518 "not?", portname, portname, portname);
6536 smartlist_free(elts);
6552 if (port->server_cfg.no_listen)
6554 if (!count_sockets && port->is_unix_addr)
6556 if (port->type != listenertype)
6559 } SMARTLIST_FOREACH_END(port);
6573 char **msg,
int *n_ports_out,
6574 int *world_writable_control_socket)
6584 CL_PORT_DFLT_GROUP_WRITABLE : 0;
6589 ((validate_only ? 0 : CL_PORT_WARN_NONLOCAL)
6590 | CL_PORT_TAKES_HOSTNAMES | gw_flag)) < 0) {
6591 *msg = tor_strdup(
"Invalid SocksPort configuration");
6598 CL_PORT_WARN_NONLOCAL|CL_PORT_TAKES_HOSTNAMES) < 0) {
6599 *msg = tor_strdup(
"Invalid DNSPort configuration");
6606 CL_PORT_WARN_NONLOCAL) < 0) {
6607 *msg = tor_strdup(
"Invalid TransPort configuration");
6614 CL_PORT_WARN_NONLOCAL) < 0) {
6615 *msg = tor_strdup(
"Invalid NatdPort configuration");
6622 ((validate_only ? 0 : CL_PORT_WARN_NONLOCAL)
6623 | CL_PORT_TAKES_HOSTNAMES | gw_flag)) < 0) {
6624 *msg = tor_strdup(
"Invalid HTTPTunnelPort configuration");
6632 unsigned control_port_flags = CL_PORT_NO_STREAM_OPTIONS |
6633 CL_PORT_WARN_NONLOCAL;
6637 if (! any_passwords)
6638 control_port_flags |= CL_PORT_FORBID_NONLOCAL;
6640 control_port_flags |= CL_PORT_DFLT_GROUP_WRITABLE;
6646 control_port_flags) < 0) {
6647 *msg = tor_strdup(
"Invalid ControlPort configuration");
6654 control_port_flags | CL_PORT_IS_UNIXSOCKET) < 0) {
6655 *msg = tor_strdup(
"Invalid ControlSocket configuration");
6663 *n_ports_out = smartlist_len(ports);
6669 port_update_port_set_relay(options, ports);
6670 options->SocksPort_set =
6672 options->TransPort_set =
6674 options->NATDPort_set =
6676 options->HTTPTunnelPort_set =
6679 options->ControlPort_set =
6681 options->DNSPort_set =
6684 if (world_writable_control_socket) {
6688 p->is_world_writable) {
6689 *world_writable_control_socket = 1;
6694 if (!validate_only) {
6707 smartlist_free(ports);
6718 && !port->server_cfg.bind_ipv6_only);
6727 && !port->server_cfg.bind_ipv4_only);
6752 static const char *ipv4_localhost =
"127.0.0.1";
6753 static const char *ipv6_localhost =
"[::1]";
6754 const char *address;
6756 char *
string = NULL;
6762 if (cfg->server_cfg.no_listen)
6765 if (cfg->type == listener_type &&
6774 address =
tor_addr_is_v4(&cfg->addr) ? ipv4_localhost : ipv6_localhost;
6795 } SMARTLIST_FOREACH_END(cfg);
6806 const port_cfg_t *first_port_explicit_addr = NULL;
6808 if (address_family == AF_UNSPEC)
6813 if (cfg->type == listener_type && !cfg->server_cfg.no_advertise) {
6814 if ((address_family == AF_INET && port_binds_ipv4(cfg)) ||
6815 (address_family == AF_INET6 && port_binds_ipv6(cfg))) {
6816 if (cfg->explicit_addr && !first_port_explicit_addr) {
6817 first_port_explicit_addr = cfg;
6818 }
else if (!first_port) {
6823 } SMARTLIST_FOREACH_END(cfg);
6826 return (first_port_explicit_addr) ? first_port_explicit_addr : first_port;
6838 return cfg ? cfg->
port : 0;
6850 return cfg ? &cfg->
addr : NULL;
6861 int port,
int check_wildcard)
6866 if (cfg->type == listener_type) {
6867 if (cfg->port == port || (check_wildcard && port == -1)) {
6873 if (!check_wildcard) {
6877 const int cfg_v4 = port_binds_ipv4(cfg);
6882 if ((cfg_any_v4 && addr_v4) || (cfg_v4 && addr_any_v4)) {
6886 const int cfg_v6 = port_binds_ipv6(cfg);
6891 if ((cfg_any_v6 && addr_v6) || (cfg_v6 && addr_any_v6)) {
6896 } SMARTLIST_FOREACH_END(cfg);
6903port_exists_by_type_addr32h_port(
int listener_type, uint32_t addr_ipv4h,
6904 int port,
int check_wildcard)
6919 return tor_strdup(val);
6921 return tor_strdup(get_windows_conf_root());
6923#elif defined(__ANDROID__)
6928 return tor_strdup(val);
6930 return tor_strdup(
"/data/local/tmp");
6933 const char *d = val;
6940 log_warn(
LD_CONFIG,
"Failed to expand filename \"%s\".", d);
6943 if (!val && !strcmp(fn,
"/.tor")) {
6948 "Default DataDirectory is \"~/.tor\". This expands to "
6949 "\"%s\", which is probably not what you want. Using "
6950 "\"%s"PATH_SEPARATOR
"tor\" instead", fn, LOCALSTATEDIR);
6952 fn = tor_strdup(LOCALSTATEDIR PATH_SEPARATOR
"tor");
6956 return tor_strdup(d);
6970 log_warn(
LD_CONFIG,
"DataDirectory is too long.");
7012#define GENERATED_FILE_PREFIX "# This file was generated by Tor; " \
7013 "if you edit it, comments will not be preserved"
7012#define GENERATED_FILE_PREFIX "# This file was generated by Tor; " \ …
7016#define GENERATED_FILE_COMMENT "# The old torrc file was renamed " \
7017 "to torrc.orig.1, and Tor will ignore it"
7016#define GENERATED_FILE_COMMENT "# The old torrc file was renamed " \ …
7026 char *old_val=NULL, *new_val=NULL, *new_conf=NULL;
7027 int rename_old = 0, r;
7032 switch (file_status(fname)) {
7036 old_val = read_file_to_str(fname, 0, NULL);
7048 "Config file \"%s\" is not a file? Failing.", fname);
7052 if (!(new_conf =
options_dump(options, OPTIONS_DUMP_MINIMAL))) {
7053 log_warn(
LD_BUG,
"Couldn't get configuration string");
7061 char *fn_tmp = NULL;
7064 if (fn_tmp_status == FN_DIR || fn_tmp_status == FN_ERROR) {
7066 "Config backup file \"%s\" is not a file? Failing.", fn_tmp);
7071 log_notice(
LD_CONFIG,
"Renaming old configuration file to \"%s\"", fn_tmp);
7072 if (replace_file(fname, fn_tmp) < 0) {
7074 "Couldn't rename configuration file \"%s\" to \"%s\": %s",
7075 fname, fn_tmp, strerror(errno));
7082 if (write_str_to_file(fname, new_val, 0) < 0)
7117 return (n >= 1) ? n : 1;
7139 memset(&cfg, 0,
sizeof(cfg));
7160 directory_root_t roottype,
7161 const char *sub1,
const char *sub2,
7162 const char *suffix))
7166 const char *rootdir = NULL;
7168 case DIRROOT_DATADIR:
7171 case DIRROOT_CACHEDIR:
7174 case DIRROOT_KEYDIR:
7178 tor_assert_unreached();
7191 }
else if (sub2 == NULL) {
7192 tor_asprintf(&fname,
"%s"PATH_SEPARATOR
"%s%s", rootdir, sub1, suffix);
7194 tor_asprintf(&fname,
"%s"PATH_SEPARATOR
"%s"PATH_SEPARATOR
"%s%s",
7195 rootdir, sub1, sub2, suffix);
7162 const char *suffix)) {
…}
7207 char *statsdir = get_datadir_fname(subdir);
7211 log_warn(
LD_HIST,
"Unable to create %s/ directory!", subdir);
7225 const char* str,
const char* descr)
7227 char *filename = get_datadir_fname2(subdir, fname);
7230 if (write_str_to_file(filename, str, 0) < 0) {
7231 log_warn(
LD_HIST,
"Unable to write %s to disk!", descr ? descr : fname);
7244 const char *question,
char **answer,
7245 const char **errmsg)
7249 if (!strcmp(question,
"config/names")) {
7260 } SMARTLIST_FOREACH_END(var);
7264 smartlist_free(vars);
7265 }
else if (!strcmp(question,
"config/defaults")) {
7267 int dirauth_lines_seen = 0, fallback_lines_seen = 0;
7272 if (var->initvalue != NULL) {
7273 if (strcmp(var->member.name,
"DirAuthority") == 0) {
7278 ++dirauth_lines_seen;
7280 if (strcmp(var->member.name,
"FallbackDir") == 0) {
7285 ++fallback_lines_seen;
7291 } SMARTLIST_FOREACH_END(var);
7292 smartlist_free(vars);
7294 if (dirauth_lines_seen == 0) {
7312 if (fallback_lines_seen == 0 &&
7351 if (family==AF_INET6) {
7358 if (!validate_only) {
7377 if (verify_and_store_outbound_address(family, &addr, type,
7378 options, validate_only)) {
7380 tor_asprintf(msg,
"Multiple%s%s outbound bind addresses "
7382 family==AF_INET?
" IPv4":(family==AF_INET6?
" IPv6":
""),
7388 lines = lines->next;
7402 if (!validate_only) {
7409 validate_only, msg) < 0) {
7445 const char *msg =
"";
7450 char *free_fname = NULL;
7453 if (!strcmp(fname,
"<default>")) {
7454 const char *conf_root = get_windows_conf_root();
7465 if (r < 0 && severity ==
LOG_WARN) {
7488 if (options->GeoIPv6File &&
7489 ((!old_options || !
opt_streq(old_options->GeoIPv6File,
7490 options->GeoIPv6File))
7510 int cookie_len,
int group_readable,
7511 uint8_t **cookie_out,
int *cookie_is_set_out)
7513 char cookie_file_str_len = strlen(header) + cookie_len;
7514 char *cookie_file_str = tor_malloc(cookie_file_str_len);
7519 if (*cookie_is_set_out) {
7531 *cookie_out = tor_malloc(cookie_len);
7535 memcpy(cookie_file_str, header, strlen(header));
7536 memcpy(cookie_file_str+strlen(header), *cookie_out, cookie_len);
7537 if (write_bytes_to_file(fname, cookie_file_str, cookie_file_str_len, 1)) {
7538 log_warn(
LD_FS,
"Error writing auth cookie to %s.",
escaped(fname));
7543 if (group_readable) {
7544 if (chmod(fname, 0640)) {
7545 log_warn(
LD_FS,
"Unable to make %s group-readable.",
escaped(fname));
7549 (void) group_readable;
7554 *cookie_is_set_out = 1;
7558 memwipe(cookie_file_str, 0, cookie_file_str_len);
7570 return (options->SocksPort_set ||
7571 options->TransPort_set ||
7572 options->NATDPort_set ||
7573 options->DNSPort_set ||
7574 options->HTTPTunnelPort_set);
void tor_addr_copy(tor_addr_t *dest, const tor_addr_t *src)
void tor_addr_make_unspec(tor_addr_t *a)
int string_is_valid_ipv4_address(const char *string)
int tor_addr_parse(tor_addr_t *addr, const char *src)
int tor_addr_port_parse(int severity, const char *addrport, tor_addr_t *address_out, uint16_t *port_out, int default_port)
int tor_addr_is_loopback(const tor_addr_t *addr)
int tor_addr_is_v4(const tor_addr_t *addr)
int tor_addr_port_split(int severity, const char *addrport, char **address_out, uint16_t *port_out)
int tor_addr_is_null(const tor_addr_t *addr)
const char * fmt_addrport(const tor_addr_t *addr, uint16_t port)
#define fmt_and_decorate_addr(a)
static sa_family_t tor_addr_family(const tor_addr_t *a)
#define tor_addr_from_ipv4h(dest, v4addr)
#define tor_addr_eq(a, b)
void addressmap_clear_invalid_automaps(const or_options_t *options)
void addressmap_register(const char *address, char *new_address, time_t expires, addressmap_entry_source_t source, const int wildcard_addr, const int wildcard_new_addr, uint64_t stream_id)
void addressmap_clear_configured(void)
void addressmap_clear_excluded_trackexithosts(const or_options_t *options)
int parse_virtual_addr_network(const char *val, sa_family_t family, int validate_only, char **msg)
Header file for directory authority mode.
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen)
void mark_bridge_list(void)
void sweep_bridge_list(void)
int transport_is_needed(const char *transport_name)
void bridge_add_from_config(bridge_line_t *bridge_line)
Header file for circuitbuild.c.
Header file for channel.c.
void circuit_mark_all_dirty_circs_as_unusable(void)
void circuit_mark_all_unused_circs(void)
Header file for circuitlist.c.
Header file for circuitmux.c.
void cmux_ewma_set_options(const or_options_t *options, const networkstatus_t *consensus)
Header file for circuitmux_ewma.c.
int circuit_build_times_disabled_(const or_options_t *options, int ignore_consensus)
Header file for circuitstats.c.
const char * tor_libevent_get_header_version_str(void)
void suppress_libevent_log_msg(const char *msg)
void tor_libevent_initialize(tor_libevent_cfg_t *torcfg)
const char * tor_libevent_get_version_str(void)
void configure_libevent_logging(void)
size_t atomic_counter_exchange(atomic_counter_t *counter, size_t newval)
void atomic_counter_init(atomic_counter_t *counter)
size_t atomic_counter_get(atomic_counter_t *counter)
void atomic_counter_destroy(atomic_counter_t *counter)
const char * tor_compress_version_str(compress_method_t method)
int tor_compress_supports_method(compress_method_t method)
const char * tor_compress_header_version_str(compress_method_t method)
Read configuration files from disk, with full include support.
int config_ensure_bandwidth_cap(uint64_t *value, const char *desc, char **msg)
static config_line_t * get_options_defaults(void)
static void options_commit_listener_transaction(listener_transaction_t *xn)
static int compute_group_readable_flag(const char *datadir, const char *subdir, int datadir_gr, int subdir_gr)
static int validate_transport_socks_arguments(const smartlist_t *args)
void options_init(or_options_t *options)
int options_save_current(void)
static const char * default_fallbacks[]
static void print_usage(void)
STATIC void add_default_trusted_dir_authorities(dirinfo_type_t type)
int pt_parse_transport_line(const or_options_t *options, const char *line, int validate_only, int server)
const char * get_torrc_fname(int defaults_fname)
#define MAX_MAX_CIRCUIT_DIRTINESS
#define MIN_MAX_CIRCUIT_DIRTINESS
static void warn_nonlocal_client_ports(const smartlist_t *ports, const char *portname, const int listener_type)
static void set_protocol_warning_severity_level(int warning_severity)
static int validate_ports_csv(smartlist_t *sl, const char *name, char **msg)
or_options_t * get_options_mutable(void)
void bridge_line_free_(bridge_line_t *bridge_line)
int get_num_cpus(const or_options_t *options)
const smartlist_t * get_configured_ports(void)
static void list_deprecated_options(void)
void add_default_fallback_dir_servers(void)
static const config_var_t option_vars_[]
static atomic_counter_t protocol_warning_severity_level
static int write_configuration_file(const char *fname, const or_options_t *options)
STATIC int options_act_reversible(const or_options_t *old_options, char **msg)
#define MIN_CIRCUIT_STREAM_TIMEOUT
char * options_get_dir_fname2_suffix(const or_options_t *options, directory_root_t roottype, const char *sub1, const char *sub2, const char *suffix)
STATIC void or_options_free_(or_options_t *options)
static bool testing_network_configured
static listener_transaction_t * options_start_listener_transaction(const or_options_t *old_options, char **msg_out)
static void list_torrc_options(void)
static int validate_data_directories(or_options_t *options)
static int in_option_validation
int getinfo_helper_config(control_connection_t *conn, const char *question, char **answer, const char **errmsg)
static void print_library_versions(void)
static int opt_streq(const char *s1, const char *s2)
STATIC int parse_ports(or_options_t *options, int validate_only, char **msg, int *n_ports_out, int *world_writable_control_socket)
int consider_adding_dir_servers(const or_options_t *options, const or_options_t *old_options)
static const char * default_authorities[]
static int options_transition_affects_guards(const or_options_t *old_options, const or_options_t *new_options)
const char * escaped_safe_str_client(const char *address)
static int warn_if_option_path_is_relative(const char *option, const char *filepath)
char * get_first_listener_addrport_string(int listener_type)
#define V_D(member, type, initvalue)
int options_init_from_torrc(int argc, char **argv)
static or_options_t * global_options
static void config_load_geoip_file_(sa_family_t family, const char *fname, const char *default_fname)
static const config_abbrev_t option_abbrevs_[]
#define OBSOLETE(varname)
void port_cfg_free_(port_cfg_t *port)
static int options_switch_id(char **msg_out)
static int handle_cmdline_master_key(tor_cmdline_mode_t command, const char *value)
static char * find_torrc_filename(const config_line_t *cmd_arg, int defaults_file, int *using_default_fname, int *ignore_missing_torrc)
takes_argument_t takes_argument
STATIC void options_commit_log_transaction(log_transaction_t *xn)
static void options_rollback_listener_transaction(struct listener_transaction_t *xn)
STATIC int open_and_add_file_log(const log_severity_list_t *severity, const char *filename, int truncate_log)
static or_options_t * global_default_options
static void cleanup_protocol_warning_severity_level(void)
static int parse_outbound_addresses(or_options_t *options, int validate_only, char **msg)
STATIC int options_create_directories(char **msg_out)
static char * load_torrc_from_stdin(void)
const char * safe_str_client_opts(const or_options_t *options, const char *address)
int portconf_get_first_advertised_port(int listener_type, int address_family)
static char * torrc_defaults_fname
static int handle_cmdline_passphrase_fd(tor_cmdline_mode_t command, const char *value)
int port_cfg_line_extract_addrport(const char *line, char **addrport_out, int *is_unix_out, const char **rest_out)
const char * escaped_safe_str(const char *address)
int check_or_create_data_subdir(const char *subdir)
static const char * get_default_conf_file(int defaults_file)
int options_any_client_port_set(const or_options_t *options)
or_options_t * options_new(void)
int create_keys_directory(const or_options_t *options)
#define MAX_CIRCS_AVAILABLE_TIME
void init_protocol_warning_severity_level(void)
static int check_and_create_data_directory(int create, const char *directory, int group_readable, const char *owner, char **msg_out)
static int handle_cmdline_no_passphrase(tor_cmdline_mode_t command)
char * options_dump(const or_options_t *options, int how_to_dump)
int get_protocol_warning_severity_level(void)
static int warn_about_relative_paths(const or_options_t *options)
static char * torrc_fname
int parse_dir_fallback_line(const char *line, int validate_only)
const or_options_t * get_options(void)
int option_is_recognized(const char *key)
setopt_err_t options_trial_assign(config_line_t *list, unsigned flags, char **msg)
static int options_init_log_granularity(const or_options_t *options, int validate_only)
STATIC int options_act(const or_options_t *old_options)
#define RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT
STATIC int parse_dir_authority_line(const char *line, dirinfo_type_t required_type, int validate_only)
#define VAR(varname, conftype, member, initvalue)
STATIC int options_init_logs(const or_options_t *old_options, const or_options_t *options, int validate_only)
STATIC void options_rollback_log_transaction(log_transaction_t *xn)
static int validate_dir_servers(const or_options_t *options, const or_options_t *old_options)
static int handle_cmdline_format(tor_cmdline_mode_t command, const char *value)
static bool have_set_startup_options
#define GENERATED_FILE_PREFIX
void parsed_cmdline_free_(parsed_cmdline_t *cmdline)
static char * load_torrc_from_disk(const config_line_t *cmd_arg, int defaults_file)
STATIC const config_mgr_t * get_options_mgr(void)
static const config_format_t options_format
static int options_act_once_on_startup(char **msg_out)
static void config_maybe_load_geoip_files_(const or_options_t *options, const or_options_t *old_options)
static const port_cfg_t * portconf_get_first_advertised(int listener_type, int address_family)
static const struct @0 testing_tor_network_defaults[]
static int options_check_transition_cb(const void *old, const void *new, char **msg)
int set_options(or_options_t *new_val, char **msg)
static void warn_nonlocal_controller_ports(smartlist_t *ports, unsigned forbid_nonlocal)
const char * safe_str_opts(const or_options_t *options, const char *address)
port_cfg_t * port_cfg_new(size_t namelen)
static int handle_cmdline_newpass(tor_cmdline_mode_t command)
STATIC log_transaction_t * options_start_log_transaction(const or_options_t *old_options, char **msg_out)
int addressmap_register_auto(const char *from, const char *to, time_t expires, addressmap_entry_source_t addrmap_source, const char **msg)
int options_need_geoip_info(const or_options_t *options, const char **reason_out)
#define UINT64_MAX_STRING
void config_register_addressmaps(const or_options_t *options)
static void options_clear_cb(const config_mgr_t *mgr, void *opts)
void config_free_all(void)
int port_count_real_listeners(const smartlist_t *ports, int listenertype, int count_sockets)
static void init_libevent(const or_options_t *options)
bridge_line_t * parse_bridge_line(const char *line)
int port_exists_by_type_addr_port(int listener_type, const tor_addr_t *addr, int port, int check_wildcard)
static int parse_dirauth_dirport(dir_server_t *ds, const char *flag)
tor_cmdline_mode_t command
int init_cookie_authentication(const char *fname, const char *header, int cookie_len, int group_readable, uint8_t **cookie_out, int *cookie_is_set_out)
static const struct @1 CMDLINE_ONLY_OPTIONS[]
parsed_cmdline_t * config_parse_commandline(int argc, char **argv, int ignore_errors)
const tor_addr_t * portconf_get_first_advertised_addr(int listener_type, int address_family)
setopt_err_t options_init_from_string(const char *cf_defaults, const char *cf, int command, const char *command_arg, char **msg)
static int options_validate_cb(const void *old_options, void *options, char **msg)
const char * option_get_canonical_name(const char *key)
static void list_enabled_modules(void)
static setopt_err_t options_validate_and_set(const or_options_t *old_options, or_options_t *new_options, char **msg_out)
static smartlist_t * configured_ports
config_line_t * option_get_assignment(const or_options_t *options, const char *key)
STATIC int parse_tcp_proxy_line(const char *line, or_options_t *options, char **msg)
#define DOWNLOAD_SCHEDULE(name)
int write_to_data_subdir(const char *subdir, const char *fname, const char *str, const char *descr)
static char * get_data_directory(const char *val)
int port_parse_config(smartlist_t *out, const config_line_t *ports, const char *portname, int listener_type, const char *defaultaddr, int defaultport, const unsigned flags)
static parsed_cmdline_t * global_cmdline
#define GENERATED_FILE_COMMENT
Header file for config.c.
#define MAX_DEFAULT_MEMORY_QUEUE_SIZE
#define CONFIG_BACKUP_PATTERN
#define MIN_HEARTBEAT_PERIOD
const config_line_t * config_line_find(const config_line_t *lines, const char *key)
void config_line_append(config_line_t **lst, const char *key, const char *val)
int config_lines_eq(const config_line_t *a, const config_line_t *b)
#define CONFIG_LINE_APPEND
#define CONFIG_LINE_NORMAL
#define END_OF_CONFIG_VARS
void config_init(const config_mgr_t *mgr, void *options)
void config_mgr_freeze(config_mgr_t *mgr)
void warn_deprecated_option(const char *what, const char *why)
config_line_t * config_get_changes(const config_mgr_t *mgr, const void *options1, const void *options2)
bool config_var_is_listable(const config_var_t *var)
const char * config_find_option_name(const config_mgr_t *mgr, const char *key)
const char * config_expand_abbrev(const config_mgr_t *mgr, const char *option, int command_line, int warn_obsolete)
bool config_var_is_settable(const config_var_t *var)
void * config_dup(const config_mgr_t *mgr, const void *old)
smartlist_t * config_mgr_list_deprecated_vars(const config_mgr_t *mgr)
config_line_t * config_get_assigned_option(const config_mgr_t *mgr, const void *options, const char *key, int escape_val)
smartlist_t * config_mgr_list_vars(const config_mgr_t *mgr)
validation_status_t config_validate(const config_mgr_t *mgr, const void *old_options, void *options, char **msg_out)
int config_assign(const config_mgr_t *mgr, void *options, config_line_t *list, unsigned config_assign_flags, char **msg)
char * config_dump(const config_mgr_t *mgr, const void *default_options, const void *options, int minimal, int comment_defaults)
config_mgr_t * config_mgr_new(const config_format_t *toplevel_fmt)
void * config_new(const config_mgr_t *mgr)
#define CAL_WARN_DEPRECATIONS
char * alloc_http_authenticator(const char *authenticator)
int retry_all_listeners(smartlist_t *new_conns, int close_all_noncontrol)
void connection_bucket_adjust(const or_options_t *options)
int conn_listener_type_supports_af_unix(int type)
void connection_mark_all_noncontrol_connections(void)
void connection_check_oos(int n_socks, int failed)
Header file for connection.c.
#define CONN_TYPE_AP_HTTP_CONNECT_LISTENER
#define CONN_TYPE_CONTROL_LISTENER
#define CONN_TYPE_EXT_OR_LISTENER
#define MAX_SOCKS5_AUTH_SIZE_TOTAL
#define MAX_SOCKS5_AUTH_FIELD_SIZE
#define CONN_TYPE_AP_NATD_LISTENER
#define CONN_TYPE_AP_LISTENER
#define CONN_TYPE_AP_DNS_LISTENER
#define CONN_TYPE_AP_TRANS_LISTENER
Header file for connection_edge.c.
int address_is_invalid_destination(const char *address, int client)
Base connection structure.
void control_ports_write_to_file(void)
int control_connection_add_local_fd(tor_socket_t sock, unsigned flags)
void monitor_owning_controller_process(const char *process_spec)
Header file for control.c.
smartlist_t * decode_hashed_passwords(config_line_t *passwords)
Header file for control_auth.c.
void control_adjust_event_log_severity(void)
void control_event_logmsg_pending(void)
void control_event_logmsg(int severity, log_domain_mask_t domain, const char *msg)
void control_event_conf_changed(const config_line_t *changes)
Header file for control_events.c.
int crypto_digest256(char *digest, const char *m, size_t len, digest_algorithm_t algorithm)
const char * crypto_get_library_version_string(void)
const char * crypto_get_library_name(void)
Headers for crypto_init.c.
Headers for crypto_nss_mgt.c.
Headers for crypto_openssl_mgt.c.
void crypto_rand(char *to, size_t n)
Common functions for using (pseudo-)random number generators.
void memwipe(void *mem, uint8_t byte, size_t sz)
Common functions for cryptographic routines.
const char * unescape_string(const char *s, char **result, size_t *size_out)
bool start_daemon_has_been_called(void)
int finish_daemon(const char *desired_cwd)
int check_private_dir(const char *dirname, cpd_check_t check, const char *effective_user)
int options_act_dirauth_stats(const or_options_t *old_options, bool *print_notice_out)
int options_validate_dirauth_mode(const or_options_t *old_options, or_options_t *options, char **msg)
Header for feature/dirauth/dirauth_config.c.
int dirclient_fetches_dir_info_later(const or_options_t *options)
int dirclient_fetches_dir_info_early(const or_options_t *options)
Header for feature/dirclient/dirclient_modes.c.
void trusted_dir_server_add_dirport(dir_server_t *ds, auth_dirport_usage_t usage, const tor_addr_port_t *dirport)
dir_server_t * fallback_dir_server_new(const tor_addr_t *ipv4_addr, uint16_t ipv4_dirport, uint16_t ipv4_orport, const tor_addr_port_t *addrport_ipv6, const char *id_digest, double weight)
void clear_dir_servers(void)
void dir_server_add(dir_server_t *ent)
dir_server_t * trusted_dir_server_new(const char *nickname, const char *address, uint16_t ipv4_dirport, uint16_t ipv4_orport, const tor_addr_port_t *ipv6_addrport, const char *digest, const char *v3_auth_digest, dirinfo_type_t type, double weight)
Header file for dirlist.c.
Header file for dirserv.c.
int guards_update_all(void)
Header file for circuitbuild.c.
char * esc_for_log(const char *s)
const char * escaped(const char *s)
int geoip_load_file(sa_family_t family, const char *filename, int severity)
int geoip_is_loaded(sa_family_t family)
Header file for geoip_stats.c.
Header for gethostname.c.
void consider_hibernation(time_t now)
int we_are_hibernating(void)
Header file for hibernate.c.
int hs_config_client_auth_all(const or_options_t *options, int validate_only)
int hs_config_service_all(const or_options_t *options, int validate_only)
Header file containing configuration ABI/API for the HS subsystem.
Header file containing PoW denial of service defenses for the HS subsystem for all versions.
int hs_service_load_all_keys(void)
int string_is_key_value(int severity, const char *string)
const char * tor_libc_get_header_version_str(void)
const char * tor_libc_get_version_str(void)
const char * tor_libc_get_name(void)
Header for lib/osinfo/libc.c.
int add_file_log(const log_severity_list_t *severity, const char *filename, int fd)
void flush_log_messages_from_startup(void)
void mark_logs_temp(void)
void rollback_log_changes(void)
void logs_set_pending_callback_callback(pending_callback_callback cb)
int add_callback_log(const log_severity_list_t *severity, log_callback cb)
int get_min_log_level(void)
void set_log_time_granularity(int granularity_msec)
void tor_log_update_sigsafe_err_fds(void)
void add_stream_log(const log_severity_list_t *severity, const char *name, int fd)
void logs_set_domain_logging(int enabled)
int parse_log_severity_config(const char **cfg_ptr, log_severity_list_t *severity_out)
void close_temp_logs(void)
#define log_fn(severity, domain, args,...)
int try_locking(const or_options_t *options, int err_if_locked)
void note_that_we_maybe_cant_complete_circuits(void)
void tor_shutdown_event_loop_and_exit(int exitcode)
void reset_main_loop_counters(void)
int tor_event_loop_shutdown_is_pending(void)
Header file for mainloop.c.
int get_total_system_memory(size_t *mem_out)
int metrics_parse_ports(or_options_t *options, smartlist_t *ports, char **err_msg_out)
Header for feature/metrics/metrics.c.
int net_is_disabled(void)
networkstatus_t * networkstatus_get_latest_consensus(void)
void update_consensus_networkstatus_fetch_time(time_t now)
Header file for networkstatus.c.
int is_legal_nickname(const char *s)
Header file for nickname.c.
void router_dir_info_changed(void)
Header file for nodelist.c.
int compute_num_cpus(void)
Master header file for Tor-specific functionality.
addressmap_entry_source_t
#define SESSION_GROUP_UNSET
@ TCP_PROXY_PROTOCOL_HAPROXY
long tor_parse_long(const char *s, int base, long min, long max, int *ok, char **next)
double tor_parse_double(const char *s, double min, double max, int *ok, char **next)
char * make_path_absolute(const char *fname)
int path_is_relative(const char *filename)
char * expand_filename(const char *filename)
int write_pidfile(const char *filename)
int policies_parse_from_options(const or_options_t *options)
int validate_addr_policies(const or_options_t *options, char **msg)
Header file for policies.c.
Listener port configuration structure.
int tor_asprintf(char **strp, const char *fmt,...)
int tor_snprintf(char *str, size_t size, const char *format,...)
void tor_disable_spawning_background_processes(void)
int tor_validate_process_specifier(const char *process_spec, const char **msg)
quiet_level_t quiet_level
void add_default_log_for_quiet_level(quiet_level_t quiet)
int port_parse_ports_relay(or_options_t *options, char **msg, smartlist_t *ports_out, int *have_low_ports_out)
int options_validate_relay_mode(const or_options_t *old_options, or_options_t *options, char **msg)
Header for feature/relay/relay_config.c.
int tor_addr_port_lookup(const char *s, tor_addr_t *addr_out, uint16_t *port_out)
int set_max_file_descriptors(rlim_t limit, int *max_out)
int tor_disable_debugger_attach(void)
uint16_t router_get_active_listener_port_by_type_af(int listener_type, sa_family_t family)
void refresh_all_country_info(void)
Header file for routerlist.c.
Header file for routermode.c.
int routerset_needs_geoip(const routerset_t *set)
routerset_t * routerset_new(void)
int routerset_equal(const routerset_t *old, const routerset_t *new)
int routerset_is_list(const routerset_t *set)
int routerset_add_unknown_ccs(routerset_t **setp, int only_if_some_cc_set)
int routerset_parse(routerset_t *target, const char *s, const char *description)
int routerset_len(const routerset_t *set)
void routerset_union(routerset_t *target, const routerset_t *source)
Header file for routerset.c.
int sandbox_is_active(void)
Header file for sandbox.c.
void scheduler_conf_changed(void)
Header file for scheduler*.c.
int switch_id(const char *user, const unsigned flags)
#define SWITCH_ID_WARN_IF_NO_CAPS
#define SWITCH_ID_KEEP_BINDLOW
static const char default_fname[]
int smartlist_strings_eq(const smartlist_t *sl1, const smartlist_t *sl2)
void smartlist_add_asprintf(struct smartlist_t *sl, const char *pattern,...)
char * smartlist_join_strings(smartlist_t *sl, const char *join, int terminate, size_t *len_out)
void smartlist_add_all(smartlist_t *s1, const smartlist_t *s2)
void smartlist_add_strdup(struct smartlist_t *sl, const char *string)
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
void smartlist_clear(smartlist_t *sl)
void smartlist_del_keeporder(smartlist_t *sl, int idx)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
#define SMARTLIST_DEL_CURRENT(sl, var)
int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, int flags, int max)
void check_network_configuration(bool server_mode)
int get_n_open_sockets(void)
int or_state_loaded(void)
unsigned int cache_ipv4_answers
unsigned int socks_iso_keep_alive
unsigned int use_cached_ipv4_answers
unsigned int prefer_ipv6_virtaddr
unsigned int socks_prefer_no_auth
unsigned int extended_socks5_codes
smartlist_t * new_listeners
struct config_line_t * ControlPort_lines
tor_addr_t Socks4ProxyAddr
struct config_line_t * MyFamily
struct config_line_t * NATDPort_lines
int DirReqStatistics_option
struct config_line_t * AlternateBridgeAuthority
tor_addr_t HTTPSProxyAddr
int ConnLimit_high_thresh
struct routerset_t * ExcludeExitNodes
int TestingEnableConnBwEvent
struct config_line_t * OutboundBindAddressExit
struct config_line_t * DNSPort_lines
char * BridgePassword_AuthDigest_
char * FamilyKeyDirectory_option
uint64_t MaxMemInQueues_low_threshold
struct smartlist_t * RejectPlaintextPorts
char * FamilyKeyDirectory
struct config_line_t * Logs
struct routerset_t * ExcludeExitNodesUnion_
int TestingDirConnectionMaxStall
int ClientBootstrapConsensusMaxInProgressTries
struct smartlist_t * WarnPlaintextPorts
struct smartlist_t * TrackHostExits
struct smartlist_t * FirewallPorts
int TestingClientMaxIntervalWithoutRequest
struct smartlist_t * Schedulers
tcp_proxy_protocol_t TCPProxyProtocol
int FetchDirInfoExtraEarly
struct config_line_t * ClientTransportPlugin
struct config_line_t * OutboundBindAddressPT
struct smartlist_t * SchedulerTypes_
struct config_line_t * DirAuthorities
struct config_line_t * Bridges
int ControlSocketsGroupWritable
uint64_t OwningControllerFD
double KISTSockBufSizeFactor
struct config_line_t * ControlSocket
struct config_line_t * OutboundBindAddress
int UseDefaultFallbackDirs
struct config_line_t * AlternateDirAuthority
int DataDirectoryGroupReadable
int CacheDirectoryGroupReadable
int KeyDirectoryGroupReadable
char * KeyDirectory_option
struct smartlist_t * NodeFamilySets
uint64_t ConstrainedSockSize
struct config_line_t * AddressMap
struct smartlist_t * FilesOpenedByIncludes
int HiddenServiceStatistics_option
char * HTTPProxyAuthenticator
struct config_line_t * HashedControlPassword
int TokenBucketRefillInterval
int LearnCircuitBuildTimeout
struct config_line_t * FallbackDir
struct routerset_t * EntryNodes
int HiddenServiceStatistics
int UsingTestNetworkDefaults_
int UnixSocksGroupWritable
struct config_line_t * NodeFamilies
char * VirtualAddrNetworkIPv6
struct routerset_t * ExcludeNodes
char * OwningControllerProcess
struct config_line_t * ReachableORAddresses
char * Socks5ProxyUsername
struct config_line_t * HashedControlSessionPassword
char * Socks5ProxyPassword
int CookieAuthFileGroupReadable
int TestingEnableCellStatsEvent
struct routerset_t * ExitNodes
tor_addr_t Socks5ProxyAddr
struct config_line_t * ReachableDirAddresses
int MaxClientCircuitsPending
tor_addr_t OutboundBindAddresses[OUTBOUND_ADDR_MAX][2]
struct routerset_t * HSLayer2Nodes
char * CacheDirectory_option
struct config_line_t * OutboundBindAddressOR
int ReconfigDropsBridgeDescs
int CircuitsAvailableTimeout
enum or_options_t::@2 TransProxyType_parsed
struct smartlist_t * AutomapHostsSuffixes
int ConnDirectionStatistics
char * VirtualAddrNetworkIPv4
int AutomapHostsOnResolve
char * HTTPSProxyAuthenticator
tor_cmdline_mode_t command
int DisableDebuggerAttachment
struct smartlist_t * FamilyIds
struct config_line_t * TransPort_lines
struct smartlist_t * LongLivedPorts
struct config_line_t * RendConfigLines
struct config_line_t * ReachableAddresses
char * ConfluxClientUX_option
int HiddenServiceSingleHopMode
double PathsNeededToBuildCircuits
int UseEntryGuards_option
struct config_line_t * HTTPTunnelPort_lines
char * DataDirectory_option
int ClientDNSRejectInternalAddresses
struct routerset_t * MiddleNodes
struct config_line_t * SocksPort_lines
struct routerset_t * HSLayer3Nodes
quiet_level_t quiet_level
struct config_line_t * cmdline_opts
struct config_line_t * other_opts
tor_cmdline_mode_t command
char unix_addr[FLEXIBLE_ARRAY_MEMBER]
entry_port_cfg_t entry_cfg
const char * struct_var_get_typename(const struct_member_t *member)
Header for lib/confmgt/structvar.c.
int subsystems_set_options(const config_mgr_t *mgr, struct or_options_t *options)
void subsystems_prefork(void)
void subsystems_postfork(void)
void subsystems_dump_list(void)
int subsystems_register_options_formats(config_mgr_t *mgr)
#define MOCK_IMPL(rv, funcname, arglist)
const char * get_version(void)
Header for feature/relay/transport_config.c.
int pt_proxies_configuration_pending(void)
int transport_add_from_config(const tor_addr_t *addr, uint16_t port, const char *name, int socks_ver)
char * pt_stringify_socks_args(const smartlist_t *socks_args)
void pt_configure_remaining_proxies(void)
void sweep_proxy_list(void)
void mark_transport_list(void)
static smartlist_t * transport_list
void sweep_transport_list(void)
void pt_prepare_proxy_list_for_config_read(void)
Headers for transports.c.
const char * get_uname(void)
#define tor_assert_nonfatal_unreached()
int strcasecmpstart(const char *s1, const char *s2)
int strcmpstart(const char *s1, const char *s2)
const char * find_whitespace(const char *s)
int strcasecmpend(const char *s1, const char *s2)
int strcmp_opt(const char *s1, const char *s2)
int string_is_C_identifier(const char *string)
const char * eat_whitespace(const char *s)
int tor_digest_is_zero(const char *digest)